mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-17 05:09:53 +01:00
Address review comments
This commit is contained in:
@@ -33,17 +33,19 @@ import org.briarproject.android.privategroup.creation.CreateGroupActivity;
|
|||||||
import org.briarproject.android.privategroup.creation.CreateGroupFragment;
|
import org.briarproject.android.privategroup.creation.CreateGroupFragment;
|
||||||
import org.briarproject.android.privategroup.creation.CreateGroupMessageFragment;
|
import org.briarproject.android.privategroup.creation.CreateGroupMessageFragment;
|
||||||
import org.briarproject.android.privategroup.creation.GroupInviteActivity;
|
import org.briarproject.android.privategroup.creation.GroupInviteActivity;
|
||||||
|
import org.briarproject.android.privategroup.creation.GroupInviteFragment;
|
||||||
import org.briarproject.android.privategroup.invitation.GroupInvitationActivity;
|
import org.briarproject.android.privategroup.invitation.GroupInvitationActivity;
|
||||||
import org.briarproject.android.privategroup.list.GroupListFragment;
|
import org.briarproject.android.privategroup.list.GroupListFragment;
|
||||||
import org.briarproject.android.privategroup.memberlist.GroupMemberListActivity;
|
import org.briarproject.android.privategroup.memberlist.GroupMemberListActivity;
|
||||||
import org.briarproject.android.sharing.BlogInvitationActivity;
|
import org.briarproject.android.sharing.BlogInvitationActivity;
|
||||||
import org.briarproject.android.sharing.BlogSharingStatusActivity;
|
import org.briarproject.android.sharing.BlogSharingStatusActivity;
|
||||||
import org.briarproject.android.contactselection.ContactSelectorFragment;
|
|
||||||
import org.briarproject.android.sharing.ForumInvitationActivity;
|
import org.briarproject.android.sharing.ForumInvitationActivity;
|
||||||
import org.briarproject.android.sharing.ForumSharingStatusActivity;
|
import org.briarproject.android.sharing.ForumSharingStatusActivity;
|
||||||
import org.briarproject.android.sharing.ShareBlogActivity;
|
import org.briarproject.android.sharing.ShareBlogActivity;
|
||||||
|
import org.briarproject.android.sharing.ShareBlogFragment;
|
||||||
import org.briarproject.android.sharing.ShareBlogMessageFragment;
|
import org.briarproject.android.sharing.ShareBlogMessageFragment;
|
||||||
import org.briarproject.android.sharing.ShareForumActivity;
|
import org.briarproject.android.sharing.ShareForumActivity;
|
||||||
|
import org.briarproject.android.sharing.ShareForumFragment;
|
||||||
import org.briarproject.android.sharing.ShareForumMessageFragment;
|
import org.briarproject.android.sharing.ShareForumMessageFragment;
|
||||||
import org.thoughtcrime.securesms.components.emoji.EmojiProvider;
|
import org.thoughtcrime.securesms.components.emoji.EmojiProvider;
|
||||||
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel;
|
import org.thoughtcrime.securesms.components.emoji.RecentEmojiPageModel;
|
||||||
@@ -142,6 +144,8 @@ public interface ActivityComponent {
|
|||||||
|
|
||||||
void inject(GroupListFragment fragment);
|
void inject(GroupListFragment fragment);
|
||||||
|
|
||||||
|
void inject(GroupInviteFragment fragment);
|
||||||
|
|
||||||
void inject(ForumListFragment fragment);
|
void inject(ForumListFragment fragment);
|
||||||
|
|
||||||
void inject(FeedFragment fragment);
|
void inject(FeedFragment fragment);
|
||||||
@@ -152,10 +156,12 @@ public interface ActivityComponent {
|
|||||||
|
|
||||||
void inject(ContactChooserFragment fragment);
|
void inject(ContactChooserFragment fragment);
|
||||||
|
|
||||||
void inject(ContactSelectorFragment fragment);
|
void inject(ShareForumFragment fragment);
|
||||||
|
|
||||||
void inject(ShareForumMessageFragment fragment);
|
void inject(ShareForumMessageFragment fragment);
|
||||||
|
|
||||||
|
void inject(ShareBlogFragment fragment);
|
||||||
|
|
||||||
void inject(ShareBlogMessageFragment fragment);
|
void inject(ShareBlogMessageFragment fragment);
|
||||||
|
|
||||||
void inject(IntroductionMessageFragment fragment);
|
void inject(IntroductionMessageFragment fragment);
|
||||||
|
|||||||
@@ -2,6 +2,7 @@ package org.briarproject.android;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.IBinder;
|
import android.os.IBinder;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.v7.app.AppCompatActivity;
|
import android.support.v7.app.AppCompatActivity;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.view.inputmethod.InputMethodManager;
|
import android.view.inputmethod.InputMethodManager;
|
||||||
@@ -31,7 +32,7 @@ public abstract class BaseActivity extends AppCompatActivity
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle savedInstanceState) {
|
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||||
super.onCreate(savedInstanceState);
|
super.onCreate(savedInstanceState);
|
||||||
|
|
||||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||||
|
|||||||
@@ -5,10 +5,12 @@ import android.content.Context;
|
|||||||
import org.briarproject.android.contact.BaseContactListAdapter;
|
import org.briarproject.android.contact.BaseContactListAdapter;
|
||||||
import org.briarproject.android.contact.ContactItemViewHolder;
|
import org.briarproject.android.contact.ContactItemViewHolder;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
public abstract class BaseContactSelectorAdapter<I extends SelectableContactItem, H extends ContactItemViewHolder<I>>
|
public abstract class BaseContactSelectorAdapter<I extends SelectableContactItem, H extends ContactItemViewHolder<I>>
|
||||||
extends BaseContactListAdapter<I, H> {
|
extends BaseContactListAdapter<I, H> {
|
||||||
|
|
||||||
|
|||||||
@@ -19,6 +19,8 @@ import org.briarproject.android.fragment.BaseFragment;
|
|||||||
import org.briarproject.android.view.BriarRecyclerView;
|
import org.briarproject.android.view.BriarRecyclerView;
|
||||||
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.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -29,22 +31,22 @@ import static org.briarproject.android.contactselection.ContactSelectorActivity.
|
|||||||
import static org.briarproject.android.contactselection.ContactSelectorActivity.getContactsFromIntegers;
|
import static org.briarproject.android.contactselection.ContactSelectorActivity.getContactsFromIntegers;
|
||||||
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public abstract class BaseContactSelectorFragment<I extends SelectableContactItem, H extends ContactItemViewHolder<I>>
|
public abstract class BaseContactSelectorFragment<I extends SelectableContactItem, H extends ContactItemViewHolder<I>>
|
||||||
extends BaseFragment
|
extends BaseFragment
|
||||||
implements OnContactClickListener<I> {
|
implements OnContactClickListener<I> {
|
||||||
|
|
||||||
protected BriarRecyclerView list;
|
protected BriarRecyclerView list;
|
||||||
protected BaseContactSelectorAdapter<I, H> adapter;
|
protected BaseContactSelectorAdapter<I, H> adapter;
|
||||||
protected Collection<ContactId> selectedContacts;
|
protected Collection<ContactId> selectedContacts = new ArrayList<>();
|
||||||
protected ContactSelectorListener<I> listener;
|
protected ContactSelectorListener<I> listener;
|
||||||
|
|
||||||
private GroupId groupId;
|
private GroupId groupId;
|
||||||
private ContactSelectorController<I> controller;
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onAttach(Context context) {
|
public void onAttach(Context context) {
|
||||||
super.onAttach(context);
|
super.onAttach(context);
|
||||||
//noinspection unchecked
|
|
||||||
listener = (ContactSelectorListener<I>) context;
|
listener = (ContactSelectorListener<I>) context;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,8 +62,9 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
@CallSuper
|
@CallSuper
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
public View onCreateView(LayoutInflater inflater,
|
||||||
Bundle savedInstanceState) {
|
@Nullable ViewGroup container,
|
||||||
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
View contentView = inflater.inflate(R.layout.list, container, false);
|
View contentView = inflater.inflate(R.layout.list, container, false);
|
||||||
|
|
||||||
@@ -87,7 +90,6 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
|
|||||||
@Override
|
@Override
|
||||||
public void onStart() {
|
public void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
controller = listener.getController();
|
|
||||||
loadContacts(selectedContacts);
|
loadContacts(selectedContacts);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -115,10 +117,10 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
|
|||||||
onSelectionChanged();
|
onSelectionChanged();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void loadContacts(@Nullable final Collection<ContactId> selection) {
|
private void loadContacts(final Collection<ContactId> selection) {
|
||||||
controller.loadContacts(groupId, selection,
|
getController().loadContacts(groupId, selection,
|
||||||
new UiResultExceptionHandler<Collection<I>, DbException>(
|
new UiResultExceptionHandler<Collection<I>, DbException>(
|
||||||
listener) {
|
this) {
|
||||||
@Override
|
@Override
|
||||||
public void onResultUi(Collection<I> contacts) {
|
public void onResultUi(Collection<I> contacts) {
|
||||||
if (contacts.isEmpty()) list.showData();
|
if (contacts.isEmpty()) list.showData();
|
||||||
@@ -128,11 +130,14 @@ public abstract class BaseContactSelectorFragment<I extends SelectableContactIte
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onExceptionUi(DbException exception) {
|
public void onExceptionUi(DbException exception) {
|
||||||
|
// TODO error handling
|
||||||
|
finish();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected abstract void onSelectionChanged();
|
protected abstract void onSelectionChanged();
|
||||||
|
|
||||||
|
protected abstract ContactSelectorController<I> getController();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -2,18 +2,23 @@ package org.briarproject.android.contactselection;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.support.annotation.CallSuper;
|
import android.support.annotation.CallSuper;
|
||||||
|
import android.support.annotation.Nullable;
|
||||||
import android.support.annotation.UiThread;
|
import android.support.annotation.UiThread;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.BriarActivity;
|
import org.briarproject.android.BriarActivity;
|
||||||
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
|
import org.briarproject.android.fragment.BaseFragment.BaseFragmentListener;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public abstract class ContactSelectorActivity<I extends SelectableContactItem>
|
public abstract class ContactSelectorActivity<I extends SelectableContactItem>
|
||||||
extends BriarActivity
|
extends BriarActivity
|
||||||
implements BaseFragmentListener, ContactSelectorListener<I> {
|
implements BaseFragmentListener, ContactSelectorListener<I> {
|
||||||
@@ -25,7 +30,7 @@ public abstract class ContactSelectorActivity<I extends SelectableContactItem>
|
|||||||
protected Collection<ContactId> contacts;
|
protected Collection<ContactId> contacts;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(@Nullable Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
|
||||||
setContentView(R.layout.activity_fragment_container);
|
setContentView(R.layout.activity_fragment_container);
|
||||||
|
|||||||
@@ -6,7 +6,9 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
|
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
public class ContactSelectorAdapter extends
|
public class ContactSelectorAdapter extends
|
||||||
BaseContactSelectorAdapter<SelectableContactItem, SelectableContactHolder> {
|
BaseContactSelectorAdapter<SelectableContactItem, SelectableContactHolder> {
|
||||||
|
|
||||||
|
|||||||
@@ -1,19 +1,19 @@
|
|||||||
package org.briarproject.android.contactselection;
|
package org.briarproject.android.contactselection;
|
||||||
|
|
||||||
import android.support.annotation.Nullable;
|
|
||||||
|
|
||||||
import org.briarproject.android.controller.DbController;
|
import org.briarproject.android.controller.DbController;
|
||||||
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
||||||
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.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
public interface ContactSelectorController<I extends SelectableContactItem>
|
public interface ContactSelectorController<I extends SelectableContactItem>
|
||||||
extends DbController {
|
extends DbController {
|
||||||
|
|
||||||
void loadContacts(GroupId g, @Nullable Collection<ContactId> selection,
|
void loadContacts(GroupId g, Collection<ContactId> selection,
|
||||||
ResultExceptionHandler<Collection<I>, DbException> handler);
|
ResultExceptionHandler<Collection<I>, DbException> handler);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -8,22 +8,26 @@ import org.briarproject.api.contact.ContactManager;
|
|||||||
import org.briarproject.api.db.DatabaseExecutor;
|
import org.briarproject.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.jetbrains.annotations.Nullable;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
import java.util.logging.Logger;
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public abstract class ContactSelectorControllerImpl<I extends SelectableContactItem>
|
public abstract class ContactSelectorControllerImpl<I extends SelectableContactItem>
|
||||||
extends DbControllerImpl
|
extends DbControllerImpl
|
||||||
implements ContactSelectorController<I> {
|
implements ContactSelectorController<I> {
|
||||||
|
|
||||||
protected static final Logger LOG =
|
private static final Logger LOG =
|
||||||
Logger.getLogger("ContactSelectorController");
|
Logger.getLogger(ContactSelectorControllerImpl.class.getName());
|
||||||
|
|
||||||
private final ContactManager contactManager;
|
private final ContactManager contactManager;
|
||||||
|
|
||||||
@@ -35,7 +39,7 @@ public abstract class ContactSelectorControllerImpl<I extends SelectableContactI
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void loadContacts(final GroupId g,
|
public void loadContacts(final GroupId g,
|
||||||
@Nullable final Collection<ContactId> selection,
|
final Collection<ContactId> selection,
|
||||||
final ResultExceptionHandler<Collection<I>, DbException> handler) {
|
final ResultExceptionHandler<Collection<I>, DbException> handler) {
|
||||||
runOnDbThread(new Runnable() {
|
runOnDbThread(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
@@ -44,8 +48,8 @@ public abstract class ContactSelectorControllerImpl<I extends SelectableContactI
|
|||||||
Collection<I> contacts = new ArrayList<>();
|
Collection<I> contacts = new ArrayList<>();
|
||||||
for (Contact c : contactManager.getActiveContacts()) {
|
for (Contact c : contactManager.getActiveContacts()) {
|
||||||
// was this contact already selected?
|
// was this contact already selected?
|
||||||
boolean selected = isSelected(c, selection != null &&
|
boolean selected =
|
||||||
selection.contains(c.getId()));
|
isSelected(c, selection.contains(c.getId()));
|
||||||
// can this contact be selected?
|
// can this contact be selected?
|
||||||
boolean disabled = isDisabled(g, c);
|
boolean disabled = isDisabled(g, c);
|
||||||
contacts.add(getItem(c, selected, disabled));
|
contacts.add(getItem(c, selected, disabled));
|
||||||
@@ -61,7 +65,8 @@ public abstract class ContactSelectorControllerImpl<I extends SelectableContactI
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DatabaseExecutor
|
@DatabaseExecutor
|
||||||
protected abstract boolean isSelected(Contact c, boolean wasSelected);
|
protected abstract boolean isSelected(Contact c, boolean wasSelected)
|
||||||
|
throws DbException;
|
||||||
|
|
||||||
@DatabaseExecutor
|
@DatabaseExecutor
|
||||||
protected abstract boolean isDisabled(GroupId g, Contact c)
|
protected abstract boolean isDisabled(GroupId g, Contact c)
|
||||||
|
|||||||
@@ -9,13 +9,14 @@ import android.view.View;
|
|||||||
import android.view.ViewGroup;
|
import android.view.ViewGroup;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.ActivityComponent;
|
|
||||||
import org.briarproject.android.contact.BaseContactListAdapter.OnContactClickListener;
|
import org.briarproject.android.contact.BaseContactListAdapter.OnContactClickListener;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public class ContactSelectorFragment extends
|
public abstract class ContactSelectorFragment extends
|
||||||
BaseContactSelectorFragment<SelectableContactItem, SelectableContactHolder>
|
BaseContactSelectorFragment<SelectableContactItem, SelectableContactHolder>
|
||||||
implements OnContactClickListener<SelectableContactItem> {
|
implements OnContactClickListener<SelectableContactItem> {
|
||||||
|
|
||||||
@@ -23,22 +24,10 @@ public class ContactSelectorFragment extends
|
|||||||
|
|
||||||
private Menu menu;
|
private Menu menu;
|
||||||
|
|
||||||
public static ContactSelectorFragment newInstance(GroupId groupId) {
|
|
||||||
Bundle args = new Bundle();
|
|
||||||
args.putByteArray(GROUP_ID, groupId.getBytes());
|
|
||||||
ContactSelectorFragment fragment = new ContactSelectorFragment();
|
|
||||||
fragment.setArguments(args);
|
|
||||||
return fragment;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void injectFragment(ActivityComponent component) {
|
public View onCreateView(LayoutInflater inflater,
|
||||||
component.inject(this);
|
@Nullable ViewGroup container,
|
||||||
}
|
@Nullable Bundle savedInstanceState) {
|
||||||
|
|
||||||
@Override
|
|
||||||
public View onCreateView(LayoutInflater inflater, ViewGroup container,
|
|
||||||
Bundle savedInstanceState) {
|
|
||||||
View contentView =
|
View contentView =
|
||||||
super.onCreateView(inflater, container, savedInstanceState);
|
super.onCreateView(inflater, container, savedInstanceState);
|
||||||
adapter = new ContactSelectorAdapter(getActivity(), this);
|
adapter = new ContactSelectorAdapter(getActivity(), this);
|
||||||
@@ -67,11 +56,6 @@ public class ContactSelectorFragment extends
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getUniqueTag() {
|
|
||||||
return TAG;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void onSelectionChanged() {
|
protected void onSelectionChanged() {
|
||||||
if (menu == null) return;
|
if (menu == null) return;
|
||||||
|
|||||||
@@ -4,14 +4,14 @@ import android.support.annotation.UiThread;
|
|||||||
|
|
||||||
import org.briarproject.android.DestroyableContext;
|
import org.briarproject.android.DestroyableContext;
|
||||||
import org.briarproject.api.contact.ContactId;
|
import org.briarproject.api.contact.ContactId;
|
||||||
|
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@NotNullByDefault
|
||||||
interface ContactSelectorListener<I extends SelectableContactItem>
|
interface ContactSelectorListener<I extends SelectableContactItem>
|
||||||
extends DestroyableContext {
|
extends DestroyableContext {
|
||||||
|
|
||||||
ContactSelectorController<I> getController();
|
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
void contactsSelected(Collection<ContactId> contacts);
|
void contactsSelected(Collection<ContactId> contacts);
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,8 @@ import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
|||||||
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.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
|
import org.briarproject.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
@@ -16,6 +18,8 @@ import javax.inject.Inject;
|
|||||||
|
|
||||||
import static org.briarproject.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_MSG_LENGTH;
|
import static org.briarproject.api.privategroup.PrivateGroupConstants.MAX_GROUP_INVITATION_MSG_LENGTH;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public abstract class BaseGroupInviteActivity
|
public abstract class BaseGroupInviteActivity
|
||||||
extends ContactSelectorActivity<SelectableContactItem>
|
extends ContactSelectorActivity<SelectableContactItem>
|
||||||
implements MessageFragmentListener {
|
implements MessageFragmentListener {
|
||||||
@@ -23,11 +27,6 @@ public abstract class BaseGroupInviteActivity
|
|||||||
@Inject
|
@Inject
|
||||||
CreateGroupController controller;
|
CreateGroupController controller;
|
||||||
|
|
||||||
@Override
|
|
||||||
public ContactSelectorController<SelectableContactItem> getController() {
|
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void contactsSelected(Collection<ContactId> contacts) {
|
public void contactsSelected(Collection<ContactId> contacts) {
|
||||||
super.contactsSelected(contacts);
|
super.contactsSelected(contacts);
|
||||||
|
|||||||
@@ -67,8 +67,8 @@ public class CreateGroupActivity extends BaseGroupInviteActivity implements
|
|||||||
|
|
||||||
private void switchToContactSelectorFragment(GroupId g) {
|
private void switchToContactSelectorFragment(GroupId g) {
|
||||||
setTitle(R.string.groups_invite_members);
|
setTitle(R.string.groups_invite_members);
|
||||||
ContactSelectorFragment fragment =
|
GroupInviteFragment fragment =
|
||||||
ContactSelectorFragment.newInstance(g);
|
GroupInviteFragment.newInstance(g);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.setCustomAnimations(android.R.anim.fade_in,
|
.setCustomAnimations(android.R.anim.fade_in,
|
||||||
android.R.anim.fade_out,
|
android.R.anim.fade_out,
|
||||||
|
|||||||
@@ -131,7 +131,8 @@ public class CreateGroupControllerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isSelected(Contact c, boolean wasSelected) {
|
protected boolean isSelected(Contact c, boolean wasSelected)
|
||||||
|
throws DbException {
|
||||||
return wasSelected;
|
return wasSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ public class GroupInviteActivity extends BaseGroupInviteActivity
|
|||||||
groupId = new GroupId(g);
|
groupId = new GroupId(g);
|
||||||
|
|
||||||
if (bundle == null) {
|
if (bundle == null) {
|
||||||
ContactSelectorFragment fragment =
|
GroupInviteFragment fragment =
|
||||||
ContactSelectorFragment.newInstance(groupId);
|
GroupInviteFragment.newInstance(groupId);
|
||||||
getSupportFragmentManager().beginTransaction()
|
getSupportFragmentManager().beginTransaction()
|
||||||
.replace(R.id.fragmentContainer, fragment)
|
.replace(R.id.fragmentContainer, fragment)
|
||||||
.commit();
|
.commit();
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.briarproject.android.privategroup.creation;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.briarproject.android.ActivityComponent;
|
||||||
|
import org.briarproject.android.contactselection.ContactSelectorController;
|
||||||
|
import org.briarproject.android.contactselection.ContactSelectorFragment;
|
||||||
|
import org.briarproject.android.contactselection.SelectableContactItem;
|
||||||
|
import org.briarproject.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
|
public class GroupInviteFragment extends ContactSelectorFragment {
|
||||||
|
|
||||||
|
public static final String TAG = GroupInviteFragment.class.getName();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
CreateGroupController controller;
|
||||||
|
|
||||||
|
public static GroupInviteFragment newInstance(GroupId groupId) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putByteArray(GROUP_ID, groupId.getBytes());
|
||||||
|
GroupInviteFragment fragment = new GroupInviteFragment();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectFragment(ActivityComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContactSelectorController<SelectableContactItem> getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUniqueTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -2,7 +2,6 @@ package org.briarproject.android.sharing;
|
|||||||
|
|
||||||
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
||||||
import org.briarproject.api.blogs.Blog;
|
import org.briarproject.api.blogs.Blog;
|
||||||
import org.briarproject.api.blogs.BlogManager;
|
|
||||||
import org.briarproject.api.blogs.BlogSharingManager;
|
import org.briarproject.api.blogs.BlogSharingManager;
|
||||||
import org.briarproject.api.contact.Contact;
|
import org.briarproject.api.contact.Contact;
|
||||||
import org.briarproject.api.db.DatabaseExecutor;
|
import org.briarproject.api.db.DatabaseExecutor;
|
||||||
@@ -22,19 +21,18 @@ import javax.inject.Inject;
|
|||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
import static org.briarproject.api.blogs.BlogManager.CLIENT_ID;
|
import static org.briarproject.api.blogs.BlogManager.CLIENT_ID;
|
||||||
|
|
||||||
|
|
||||||
public class BlogInvitationControllerImpl
|
public class BlogInvitationControllerImpl
|
||||||
extends InvitationControllerImpl<SharingInvitationItem>
|
extends InvitationControllerImpl<SharingInvitationItem>
|
||||||
implements BlogInvitationController {
|
implements BlogInvitationController {
|
||||||
|
|
||||||
private final BlogManager blogManager;
|
|
||||||
private final BlogSharingManager blogSharingManager;
|
private final BlogSharingManager blogSharingManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
BlogInvitationControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
BlogInvitationControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||||
LifecycleManager lifecycleManager, EventBus eventBus,
|
LifecycleManager lifecycleManager, EventBus eventBus,
|
||||||
BlogManager blogManager, BlogSharingManager blogSharingManager) {
|
BlogSharingManager blogSharingManager) {
|
||||||
super(dbExecutor, lifecycleManager, eventBus);
|
super(dbExecutor, lifecycleManager, eventBus);
|
||||||
this.blogManager = blogManager;
|
|
||||||
this.blogSharingManager = blogSharingManager;
|
this.blogSharingManager = blogSharingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -8,7 +8,6 @@ import org.briarproject.api.event.Event;
|
|||||||
import org.briarproject.api.event.EventBus;
|
import org.briarproject.api.event.EventBus;
|
||||||
import org.briarproject.api.event.ForumInvitationReceivedEvent;
|
import org.briarproject.api.event.ForumInvitationReceivedEvent;
|
||||||
import org.briarproject.api.forum.Forum;
|
import org.briarproject.api.forum.Forum;
|
||||||
import org.briarproject.api.forum.ForumManager;
|
|
||||||
import org.briarproject.api.forum.ForumSharingManager;
|
import org.briarproject.api.forum.ForumSharingManager;
|
||||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
import org.briarproject.api.sharing.SharingInvitationItem;
|
import org.briarproject.api.sharing.SharingInvitationItem;
|
||||||
@@ -26,16 +25,13 @@ public class ForumInvitationControllerImpl
|
|||||||
extends InvitationControllerImpl<SharingInvitationItem>
|
extends InvitationControllerImpl<SharingInvitationItem>
|
||||||
implements ForumInvitationController {
|
implements ForumInvitationController {
|
||||||
|
|
||||||
private final ForumManager forumManager;
|
|
||||||
private final ForumSharingManager forumSharingManager;
|
private final ForumSharingManager forumSharingManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
ForumInvitationControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
ForumInvitationControllerImpl(@DatabaseExecutor Executor dbExecutor,
|
||||||
LifecycleManager lifecycleManager, EventBus eventBus,
|
LifecycleManager lifecycleManager, EventBus eventBus,
|
||||||
ForumManager forumManager,
|
|
||||||
ForumSharingManager forumSharingManager) {
|
ForumSharingManager forumSharingManager) {
|
||||||
super(dbExecutor, lifecycleManager, eventBus);
|
super(dbExecutor, lifecycleManager, eventBus);
|
||||||
this.forumManager = forumManager;
|
|
||||||
this.forumSharingManager = forumSharingManager;
|
this.forumSharingManager = forumSharingManager;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -10,31 +10,28 @@ import org.briarproject.android.contactselection.ContactSelectorFragment;
|
|||||||
import org.briarproject.android.contactselection.SelectableContactItem;
|
import org.briarproject.android.contactselection.SelectableContactItem;
|
||||||
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.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
import org.jetbrains.annotations.NotNull;
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public abstract class ShareActivity
|
public abstract class ShareActivity
|
||||||
extends ContactSelectorActivity<SelectableContactItem>
|
extends ContactSelectorActivity<SelectableContactItem>
|
||||||
implements MessageFragmentListener {
|
implements MessageFragmentListener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onCreate(Bundle bundle) {
|
public void onCreate(@Nullable Bundle bundle) {
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
|
||||||
Intent i = getIntent();
|
Intent i = getIntent();
|
||||||
byte[] b = i.getByteArrayExtra(GROUP_ID);
|
byte[] b = i.getByteArrayExtra(GROUP_ID);
|
||||||
if (b == null) throw new IllegalStateException("No GroupId");
|
if (b == null) throw new IllegalStateException("No GroupId");
|
||||||
groupId = new GroupId(b);
|
groupId = new GroupId(b);
|
||||||
|
|
||||||
if (bundle == null) {
|
|
||||||
ContactSelectorFragment contactSelectorFragment =
|
|
||||||
ContactSelectorFragment.newInstance(groupId);
|
|
||||||
getSupportFragmentManager().beginTransaction()
|
|
||||||
.add(R.id.fragmentContainer, contactSelectorFragment)
|
|
||||||
.commit();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@UiThread
|
@UiThread
|
||||||
|
|||||||
@@ -1,14 +1,16 @@
|
|||||||
package org.briarproject.android.sharing;
|
package org.briarproject.android.sharing;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
import android.widget.Toast;
|
import android.widget.Toast;
|
||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.ActivityComponent;
|
import org.briarproject.android.ActivityComponent;
|
||||||
import org.briarproject.android.contactselection.ContactSelectorController;
|
|
||||||
import org.briarproject.android.contactselection.SelectableContactItem;
|
|
||||||
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
||||||
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.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -17,6 +19,8 @@ import javax.inject.Inject;
|
|||||||
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.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public class ShareBlogActivity extends ShareActivity {
|
public class ShareBlogActivity extends ShareActivity {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -33,8 +37,15 @@ public class ShareBlogActivity extends ShareActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContactSelectorController<SelectableContactItem> getController() {
|
public void onCreate(@Nullable Bundle bundle) {
|
||||||
return controller;
|
super.onCreate(bundle);
|
||||||
|
|
||||||
|
if (bundle == null) {
|
||||||
|
ShareBlogFragment fragment = ShareBlogFragment.newInstance(groupId);
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.add(R.id.fragmentContainer, fragment)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -9,20 +9,30 @@ import org.briarproject.api.contact.ContactId;
|
|||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
import org.briarproject.api.db.DatabaseExecutor;
|
import org.briarproject.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
|
import org.briarproject.api.db.NoSuchGroupException;
|
||||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public class ShareBlogControllerImpl
|
public class ShareBlogControllerImpl
|
||||||
extends ContactSelectorControllerImpl<SelectableContactItem>
|
extends ContactSelectorControllerImpl<SelectableContactItem>
|
||||||
implements ShareBlogController {
|
implements ShareBlogController {
|
||||||
|
|
||||||
|
private final static Logger LOG =
|
||||||
|
Logger.getLogger(ShareBlogControllerImpl.class.getName());
|
||||||
|
|
||||||
private final BlogSharingManager blogSharingManager;
|
private final BlogSharingManager blogSharingManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -36,7 +46,8 @@ public class ShareBlogControllerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isSelected(Contact c, boolean wasSelected) {
|
protected boolean isSelected(Contact c, boolean wasSelected)
|
||||||
|
throws DbException {
|
||||||
return wasSelected;
|
return wasSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +71,12 @@ public class ShareBlogControllerImpl
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
for (ContactId c : contacts) {
|
for (ContactId c : contacts) {
|
||||||
blogSharingManager.sendInvitation(g, c, msg);
|
try {
|
||||||
|
blogSharingManager.sendInvitation(g, c, msg);
|
||||||
|
} catch (NoSuchContactException | NoSuchGroupException e) {
|
||||||
|
if (LOG.isLoggable(WARNING))
|
||||||
|
LOG.log(WARNING, e.toString(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.briarproject.android.sharing;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.briarproject.android.ActivityComponent;
|
||||||
|
import org.briarproject.android.contactselection.ContactSelectorController;
|
||||||
|
import org.briarproject.android.contactselection.ContactSelectorFragment;
|
||||||
|
import org.briarproject.android.contactselection.SelectableContactItem;
|
||||||
|
import org.briarproject.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
|
public class ShareBlogFragment extends ContactSelectorFragment {
|
||||||
|
|
||||||
|
public static final String TAG = ShareBlogFragment.class.getName();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ShareBlogController controller;
|
||||||
|
|
||||||
|
public static ShareBlogFragment newInstance(GroupId groupId) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putByteArray(GROUP_ID, groupId.getBytes());
|
||||||
|
ShareBlogFragment fragment = new ShareBlogFragment();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectFragment(ActivityComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContactSelectorController<SelectableContactItem> getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUniqueTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -5,11 +5,12 @@ import android.widget.Toast;
|
|||||||
|
|
||||||
import org.briarproject.R;
|
import org.briarproject.R;
|
||||||
import org.briarproject.android.ActivityComponent;
|
import org.briarproject.android.ActivityComponent;
|
||||||
import org.briarproject.android.contactselection.ContactSelectorController;
|
|
||||||
import org.briarproject.android.contactselection.SelectableContactItem;
|
|
||||||
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
||||||
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.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.jetbrains.annotations.Nullable;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
|
|
||||||
@@ -18,6 +19,8 @@ import javax.inject.Inject;
|
|||||||
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.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
public class ShareForumActivity extends ShareActivity {
|
public class ShareForumActivity extends ShareActivity {
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -34,13 +37,16 @@ public class ShareForumActivity extends ShareActivity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ContactSelectorController<SelectableContactItem> getController() {
|
public void onCreate(@Nullable Bundle bundle) {
|
||||||
return controller;
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void onCreate(Bundle bundle) {
|
|
||||||
super.onCreate(bundle);
|
super.onCreate(bundle);
|
||||||
|
|
||||||
|
if (bundle == null) {
|
||||||
|
ShareForumFragment fragment =
|
||||||
|
ShareForumFragment.newInstance(groupId);
|
||||||
|
getSupportFragmentManager().beginTransaction()
|
||||||
|
.add(R.id.fragmentContainer, fragment)
|
||||||
|
.commit();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -8,21 +8,31 @@ import org.briarproject.api.contact.ContactId;
|
|||||||
import org.briarproject.api.contact.ContactManager;
|
import org.briarproject.api.contact.ContactManager;
|
||||||
import org.briarproject.api.db.DatabaseExecutor;
|
import org.briarproject.api.db.DatabaseExecutor;
|
||||||
import org.briarproject.api.db.DbException;
|
import org.briarproject.api.db.DbException;
|
||||||
|
import org.briarproject.api.db.NoSuchContactException;
|
||||||
|
import org.briarproject.api.db.NoSuchGroupException;
|
||||||
import org.briarproject.api.forum.ForumSharingManager;
|
import org.briarproject.api.forum.ForumSharingManager;
|
||||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||||
|
import org.briarproject.api.nullsafety.NotNullByDefault;
|
||||||
import org.briarproject.api.sync.GroupId;
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
import java.util.Collection;
|
import java.util.Collection;
|
||||||
import java.util.concurrent.Executor;
|
import java.util.concurrent.Executor;
|
||||||
|
import java.util.logging.Logger;
|
||||||
|
|
||||||
|
import javax.annotation.concurrent.Immutable;
|
||||||
import javax.inject.Inject;
|
import javax.inject.Inject;
|
||||||
|
|
||||||
import static java.util.logging.Level.WARNING;
|
import static java.util.logging.Level.WARNING;
|
||||||
|
|
||||||
|
@Immutable
|
||||||
|
@NotNullByDefault
|
||||||
public class ShareForumControllerImpl
|
public class ShareForumControllerImpl
|
||||||
extends ContactSelectorControllerImpl<SelectableContactItem>
|
extends ContactSelectorControllerImpl<SelectableContactItem>
|
||||||
implements ShareForumController {
|
implements ShareForumController {
|
||||||
|
|
||||||
|
private final static Logger LOG =
|
||||||
|
Logger.getLogger(ShareForumControllerImpl.class.getName());
|
||||||
|
|
||||||
private final ForumSharingManager forumSharingManager;
|
private final ForumSharingManager forumSharingManager;
|
||||||
|
|
||||||
@Inject
|
@Inject
|
||||||
@@ -36,7 +46,8 @@ public class ShareForumControllerImpl
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected boolean isSelected(Contact c, boolean wasSelected) {
|
protected boolean isSelected(Contact c, boolean wasSelected)
|
||||||
|
throws DbException {
|
||||||
return wasSelected;
|
return wasSelected;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +71,12 @@ public class ShareForumControllerImpl
|
|||||||
public void run() {
|
public void run() {
|
||||||
try {
|
try {
|
||||||
for (ContactId c : contacts) {
|
for (ContactId c : contacts) {
|
||||||
forumSharingManager.sendInvitation(g, c, msg);
|
try {
|
||||||
|
forumSharingManager.sendInvitation(g, c, msg);
|
||||||
|
} catch (NoSuchContactException | NoSuchGroupException e) {
|
||||||
|
if (LOG.isLoggable(WARNING))
|
||||||
|
LOG.log(WARNING, e.toString(), e);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} catch (DbException e) {
|
} catch (DbException e) {
|
||||||
if (LOG.isLoggable(WARNING))
|
if (LOG.isLoggable(WARNING))
|
||||||
|
|||||||
@@ -0,0 +1,49 @@
|
|||||||
|
package org.briarproject.android.sharing;
|
||||||
|
|
||||||
|
import android.os.Bundle;
|
||||||
|
|
||||||
|
import org.briarproject.android.ActivityComponent;
|
||||||
|
import org.briarproject.android.contactselection.ContactSelectorController;
|
||||||
|
import org.briarproject.android.contactselection.ContactSelectorFragment;
|
||||||
|
import org.briarproject.android.contactselection.SelectableContactItem;
|
||||||
|
import org.briarproject.api.nullsafety.MethodsNotNullByDefault;
|
||||||
|
import org.briarproject.api.nullsafety.ParametersNotNullByDefault;
|
||||||
|
import org.briarproject.api.sync.GroupId;
|
||||||
|
|
||||||
|
import javax.inject.Inject;
|
||||||
|
|
||||||
|
import static org.briarproject.api.sharing.SharingConstants.GROUP_ID;
|
||||||
|
|
||||||
|
@MethodsNotNullByDefault
|
||||||
|
@ParametersNotNullByDefault
|
||||||
|
public class ShareForumFragment extends ContactSelectorFragment {
|
||||||
|
|
||||||
|
public static final String TAG = ShareForumFragment.class.getName();
|
||||||
|
|
||||||
|
@Inject
|
||||||
|
ShareForumController controller;
|
||||||
|
|
||||||
|
public static ShareForumFragment newInstance(GroupId groupId) {
|
||||||
|
Bundle args = new Bundle();
|
||||||
|
args.putByteArray(GROUP_ID, groupId.getBytes());
|
||||||
|
ShareForumFragment fragment = new ShareForumFragment();
|
||||||
|
fragment.setArguments(args);
|
||||||
|
return fragment;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void injectFragment(ActivityComponent component) {
|
||||||
|
component.inject(this);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected ContactSelectorController<SelectableContactItem> getController() {
|
||||||
|
return controller;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getUniqueTag() {
|
||||||
|
return TAG;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user