diff --git a/briar-android/src/org/briarproject/android/ActivityComponent.java b/briar-android/src/org/briarproject/android/ActivityComponent.java index 4032d7bd7641457e6d065d3cd5240647d871c814..ca2e8b3340930a9e6567b50b412654c2d7bb4888 100644 --- a/briar-android/src/org/briarproject/android/ActivityComponent.java +++ b/briar-android/src/org/briarproject/android/ActivityComponent.java @@ -1,8 +1,6 @@ package org.briarproject.android; import android.app.Activity; -import android.os.Bundle; -import android.support.v4.app.Fragment; import org.briarproject.android.contact.ContactListFragment; import org.briarproject.android.contact.ConversationActivity; @@ -16,13 +14,15 @@ import org.briarproject.android.forum.WriteForumPostActivity; import org.briarproject.android.fragment.BaseFragment; import org.briarproject.android.identity.CreateIdentityActivity; import org.briarproject.android.invitation.AddContactActivity; +import org.briarproject.android.keyagreement.ChooseIdentityFragment; +import org.briarproject.android.keyagreement.KeyAgreementActivity; +import org.briarproject.android.keyagreement.ShowQrCodeFragment; import org.briarproject.android.panic.PanicPreferencesActivity; import org.briarproject.android.panic.PanicResponderActivity; import javax.inject.Named; import dagger.Component; -import dagger.Provides; @ActivityScope @Component(modules = ActivityModule.class, @@ -44,6 +44,8 @@ public interface ActivityComponent { void inject(AddContactActivity activity); + void inject(KeyAgreementActivity activity); + void inject(ConversationActivity activity); void inject(CreateIdentityActivity activity); @@ -64,13 +66,23 @@ public interface ActivityComponent { void inject(SettingsActivity activity); + void inject(ContactListFragment fragment); + + void inject(ForumListFragment fragment); + + void inject(ChooseIdentityFragment fragment); + + void inject(ShowQrCodeFragment fragment); + @Named("ContactListFragment") BaseFragment newContactListFragment(); @Named("ForumListFragment") BaseFragment newForumListFragment(); -// void inject(ContactListFragment fragment); + @Named("ChooseIdentityFragment") + BaseFragment newChooseIdentityFragment(); -// void inject(ForumListFragment fragment); + @Named("ShowQrCodeFragment") + BaseFragment newShowQrCodeFragment(); } diff --git a/briar-android/src/org/briarproject/android/ActivityModule.java b/briar-android/src/org/briarproject/android/ActivityModule.java index 3ae6e004c3b9eacadc9d525566ac64f75a38397e..1f398b8e57aa052f9beb8bed6179b020ea7e5853 100644 --- a/briar-android/src/org/briarproject/android/ActivityModule.java +++ b/briar-android/src/org/briarproject/android/ActivityModule.java @@ -14,6 +14,8 @@ import org.briarproject.android.helper.SetupHelper; import org.briarproject.android.helper.SetupHelperImp; import org.briarproject.android.helper.ConfigHelper; import org.briarproject.android.helper.ConfigHelperImp; +import org.briarproject.android.keyagreement.ChooseIdentityFragment; +import org.briarproject.android.keyagreement.ShowQrCodeFragment; import javax.inject.Named; @@ -75,4 +77,21 @@ public class ActivityModule { return contactListFragment; } + @Provides + @Named("ChooseIdentityFragment") + BaseFragment provideChooseIdendityFragment() { + ChooseIdentityFragment fragment = new ChooseIdentityFragment(); + fragment.setArguments(new Bundle()); + return fragment; + } + + @Provides + @Named("ShowQrCodeFragment") + BaseFragment provideShowQrCodeFragment() { + ShowQrCodeFragment fragment = new ShowQrCodeFragment(); + fragment.setArguments(new Bundle()); + return fragment; + } + + } diff --git a/briar-android/src/org/briarproject/android/AndroidComponent.java b/briar-android/src/org/briarproject/android/AndroidComponent.java index 02469114f417c96a1e2fd521beeb9ef5ea08aee9..f482e52981752f83f01ec2536e761ce2bb6f8246 100644 --- a/briar-android/src/org/briarproject/android/AndroidComponent.java +++ b/briar-android/src/org/briarproject/android/AndroidComponent.java @@ -7,25 +7,7 @@ import org.briarproject.android.api.ReferenceManager; import org.briarproject.android.contact.ContactListFragment; import org.briarproject.android.contact.ConversationActivity; import org.briarproject.android.event.AppBus; -import org.briarproject.android.forum.AvailableForumsActivity; -import org.briarproject.android.forum.ContactSelectorFragment; -import org.briarproject.android.forum.CreateForumActivity; -import org.briarproject.android.forum.ForumActivity; -import org.briarproject.android.forum.ForumListFragment; -import org.briarproject.android.forum.ReadForumPostActivity; -import org.briarproject.android.forum.ShareForumActivity; -import org.briarproject.android.forum.ShareForumMessageFragment; -import org.briarproject.android.forum.WriteForumPostActivity; -import org.briarproject.android.identity.CreateIdentityActivity; -import org.briarproject.android.introduction.ContactChooserFragment; -import org.briarproject.android.introduction.IntroductionActivity; -import org.briarproject.android.introduction.IntroductionMessageFragment; -import org.briarproject.android.invitation.AddContactActivity; -import org.briarproject.android.keyagreement.ChooseIdentityFragment; -import org.briarproject.android.keyagreement.KeyAgreementActivity; -import org.briarproject.android.keyagreement.ShowQrCodeFragment; -import org.briarproject.android.panic.PanicPreferencesActivity; -import org.briarproject.android.panic.PanicResponderActivity; +import org.briarproject.api.contact.ContactExchangeTask; import org.briarproject.api.contact.ContactManager; import org.briarproject.api.crypto.CryptoComponent; import org.briarproject.api.crypto.CryptoExecutor; @@ -39,6 +21,9 @@ import org.briarproject.api.forum.ForumSharingManager; import org.briarproject.api.identity.AuthorFactory; import org.briarproject.api.identity.IdentityManager; import org.briarproject.api.invitation.InvitationTaskFactory; +import org.briarproject.api.keyagreement.KeyAgreementTaskFactory; +import org.briarproject.api.keyagreement.PayloadEncoder; +import org.briarproject.api.keyagreement.PayloadParser; import org.briarproject.api.lifecycle.LifecycleManager; import org.briarproject.api.messaging.MessagingManager; import org.briarproject.api.messaging.PrivateMessageFactory; @@ -71,67 +56,51 @@ public interface AndroidComponent extends CoreEagerSingletons { DatabaseConfig databaseConfig(); AuthorFactory authFactory(); ReferenceManager referenceMangager(); - @DatabaseExecutor Executor databaseExecutor(); - LifecycleManager lifecycleManager(); - IdentityManager identityManager(); - PluginManager pluginManager(); - EventBus eventBus(); - AppBus appEventBus(); - InvitationTaskFactory invitationTaskFactory(); - AndroidNotificationManager androidNotificationManager(); - ConnectionRegistry connectionRegistry(); - ContactManager contactManager(); - MessagingManager messagingManager(); - PrivateMessageFactory privateMessageFactory(); - TransportPropertyManager transportPropertyManager(); - ForumManager forumManager(); - ForumSharingManager forumSharingManager(); - ForumPostFactory forumPostFactory(); - SettingsManager settingsManager(); - void inject(BriarService activity); + @DatabaseExecutor + Executor databaseExecutor(); - void inject(PanicResponderActivity activity); + LifecycleManager lifecycleManager(); - void inject(PanicPreferencesActivity activity); + IdentityManager identityManager(); - void inject(AddContactActivity activity); + PluginManager pluginManager(); - void inject(KeyAgreementActivity activity); + EventBus eventBus(); - void inject(ConversationActivity activity); + AppBus appEventBus(); - void inject(CreateIdentityActivity activity); + InvitationTaskFactory invitationTaskFactory(); - void inject(TestingActivity activity); + AndroidNotificationManager androidNotificationManager(); - void inject(AvailableForumsActivity activity); + ConnectionRegistry connectionRegistry(); - void inject(WriteForumPostActivity activity); + ContactManager contactManager(); - void inject(CreateForumActivity activity); + MessagingManager messagingManager(); - void inject(ShareForumActivity activity); + PrivateMessageFactory privateMessageFactory(); - void inject(ContactSelectorFragment fragment); + TransportPropertyManager transportPropertyManager(); - void inject(ShareForumMessageFragment fragment); + ForumManager forumManager(); - void inject(ReadForumPostActivity activity); + ForumSharingManager forumSharingManager(); - void inject(ForumActivity activity); + ForumPostFactory forumPostFactory(); - void inject(SettingsActivity activity); + SettingsManager settingsManager(); - void inject(ContactListFragment fragment); + ContactExchangeTask contactExchangeTask(); - void inject(ForumListFragment fragment); + KeyAgreementTaskFactory keyAgreementTaskFactory(); - void inject(ChooseIdentityFragment fragment); + PayloadEncoder payloadEncoder(); - void inject(ShowQrCodeFragment fragment); + PayloadParser payloadParser(); - void inject(IntroductionActivity activity); + void inject(BriarService activity); void inject(ContactChooserFragment fragment); diff --git a/briar-android/src/org/briarproject/android/contact/ContactListFragment.java b/briar-android/src/org/briarproject/android/contact/ContactListFragment.java index 62e1e349fde78b0d6dfcb31b45fb0b9f1647dbaa..bb22af3bf7cf90e068b57f3f7107c58f33096b9b 100644 --- a/briar-android/src/org/briarproject/android/contact/ContactListFragment.java +++ b/briar-android/src/org/briarproject/android/contact/ContactListFragment.java @@ -15,6 +15,7 @@ import org.briarproject.R; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarApplication; import org.briarproject.android.fragment.BaseEventFragment; +import org.briarproject.android.fragment.BaseFragment; import org.briarproject.android.keyagreement.KeyAgreementActivity; import org.briarproject.android.util.BriarRecyclerView; import org.briarproject.api.contact.Contact; @@ -62,17 +63,6 @@ public class ContactListFragment extends BaseFragment implements EventListener { public final static String TAG = "ContactListFragment"; - /* - public static ContactListFragment newInstance() { - - Bundle args = new Bundle(); - - ContactListFragment fragment = new ContactListFragment(); - fragment.setArguments(args); - return fragment; - } - */ - @Override public String getUniqueTag() { return TAG; @@ -98,10 +88,6 @@ public class ContactListFragment extends BaseFragment implements EventListener { protected volatile EventBus eventBus; -// @Override -// public void injectActivity(AndroidComponent component) { -// component.inject(this); -// } @Inject public ContactListFragment() { diff --git a/briar-android/src/org/briarproject/android/keyagreement/ChooseIdentityFragment.java b/briar-android/src/org/briarproject/android/keyagreement/ChooseIdentityFragment.java index 16818d36a83d84a1159a651eee0cbc5a582c2c82..40206766ed660e72b846596dd34cc57c8493aa55 100644 --- a/briar-android/src/org/briarproject/android/keyagreement/ChooseIdentityFragment.java +++ b/briar-android/src/org/briarproject/android/keyagreement/ChooseIdentityFragment.java @@ -13,6 +13,7 @@ import android.widget.AdapterView.OnItemSelectedListener; import android.widget.Spinner; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.fragment.BaseFragment; import org.briarproject.android.identity.CreateIdentityActivity; @@ -59,11 +60,9 @@ public class ChooseIdentityFragment extends BaseFragment @Inject protected volatile IdentityManager identityManager; - public static ChooseIdentityFragment newInstance() { - Bundle args = new Bundle(); - ChooseIdentityFragment fragment = new ChooseIdentityFragment(); - fragment.setArguments(args); - return fragment; + @Inject + public ChooseIdentityFragment() { + } @Override @@ -82,11 +81,6 @@ public class ChooseIdentityFragment extends BaseFragment return TAG; } - @Override - public void injectActivity(AndroidComponent component) { - component.inject(this); - } - @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container, diff --git a/briar-android/src/org/briarproject/android/keyagreement/KeyAgreementActivity.java b/briar-android/src/org/briarproject/android/keyagreement/KeyAgreementActivity.java index 185d3c0b1efc3d4f14daca2d1b312d417a79aadb..b2395eaa2fe985529914fe17384c434361c6d711 100644 --- a/briar-android/src/org/briarproject/android/keyagreement/KeyAgreementActivity.java +++ b/briar-android/src/org/briarproject/android/keyagreement/KeyAgreementActivity.java @@ -7,6 +7,7 @@ import android.widget.TextView; import android.widget.Toast; import org.briarproject.R; +import org.briarproject.android.ActivityComponent; import org.briarproject.android.AndroidComponent; import org.briarproject.android.BriarFragmentActivity; import org.briarproject.android.fragment.BaseFragment; @@ -63,7 +64,7 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements protected volatile IdentityManager identityManager; @Override - public void injectActivity(AndroidComponent component) { + public void injectActivity(ActivityComponent component) { component.inject(this); } @@ -96,11 +97,11 @@ public class KeyAgreementActivity extends BriarFragmentActivity implements STEPS)); switch (step) { case STEP_QR: - startFragment(ShowQrCodeFragment.newInstance()); + startFragment(activityComponent.newShowQrCodeFragment()); break; case STEP_ID: default: - startFragment(ChooseIdentityFragment.newInstance()); + startFragment(activityComponent.newChooseIdentityFragment()); break; } } diff --git a/briar-android/src/org/briarproject/android/keyagreement/ShowQrCodeFragment.java b/briar-android/src/org/briarproject/android/keyagreement/ShowQrCodeFragment.java index cbe175d8e124c968002e17b3e2184a287485bb88..8a997168d94403c77ad8395fef40d11b1af9f1d4 100644 --- a/briar-android/src/org/briarproject/android/keyagreement/ShowQrCodeFragment.java +++ b/briar-android/src/org/briarproject/android/keyagreement/ShowQrCodeFragment.java @@ -86,11 +86,9 @@ public class ShowQrCodeFragment extends BaseEventFragment private volatile KeyAgreementTask task; private volatile boolean waitingForBluetooth; - public static ShowQrCodeFragment newInstance() { - Bundle args = new Bundle(); - ShowQrCodeFragment fragment = new ShowQrCodeFragment(); - fragment.setArguments(args); - return fragment; + @Inject + public ShowQrCodeFragment() { + } @Override @@ -98,11 +96,6 @@ public class ShowQrCodeFragment extends BaseEventFragment return TAG; } - @Override - public void injectActivity(AndroidComponent component) { - component.inject(this); - } - @Nullable @Override public View onCreateView(LayoutInflater inflater, ViewGroup container,