From 5d8ba660c2592c74427a5b84ba6ff4d5e047894c Mon Sep 17 00:00:00 2001
From: Ernir Erlingsson <ernir@ymirmobile.com>
Date: Fri, 1 Apr 2016 14:52:17 +0200
Subject: [PATCH] merge

---
 .../android/ActivityComponent.java            | 22 +++--
 .../briarproject/android/ActivityModule.java  | 19 +++++
 .../android/AndroidComponent.java             | 85 ++++++-------------
 .../android/contact/ContactListFragment.java  | 16 +---
 .../keyagreement/ChooseIdentityFragment.java  | 14 +--
 .../keyagreement/KeyAgreementActivity.java    |  7 +-
 .../keyagreement/ShowQrCodeFragment.java      | 13 +--
 7 files changed, 75 insertions(+), 101 deletions(-)

diff --git a/briar-android/src/org/briarproject/android/ActivityComponent.java b/briar-android/src/org/briarproject/android/ActivityComponent.java
index 4032d7bd76..ca2e8b3340 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 3ae6e004c3..1f398b8e57 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 02469114f4..f482e52981 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 62e1e349fd..bb22af3bf7 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 16818d36a8..40206766ed 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 185d3c0b1e..b2395eaa2f 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 cbe175d8e1..8a997168d9 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,
-- 
GitLab