mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-12 10:49:06 +01:00
Merge branch '247-dagger-2' into 'master'
247 dagger 2 This MR in a nutshell replaces Guice and Roboguice with Dagger 2, which offers a lot more possibilities than is implemented in this branch, such as using lazy injections for performance purposes. With Dagger 2 all the magic happens at compile time, so no need to worry about unfulfilled injections at runtime, but due to restrictions I was forced to put injected test code into an Android module. We therefore have a new test module, `android-test`. A consequence of using Dagger 2 is that we no longer have a view injector and I therefore had to replace those with manual references. Closes #247 See merge request !118
This commit is contained in:
5
briar-android-tests/.gitignore
vendored
Normal file
5
briar-android-tests/.gitignore
vendored
Normal file
@@ -0,0 +1,5 @@
|
||||
bin
|
||||
gen
|
||||
build
|
||||
local.properties
|
||||
.settings
|
||||
49
briar-android-tests/build.gradle
Normal file
49
briar-android-tests/build.gradle
Normal file
@@ -0,0 +1,49 @@
|
||||
apply plugin: 'com.android.library'
|
||||
sourceCompatibility = 1.6
|
||||
targetCompatibility = 1.6
|
||||
apply plugin: 'witness'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
repositories {
|
||||
maven { url 'http://repo1.maven.org/maven2' }
|
||||
}
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
buildToolsVersion "23.0.2"
|
||||
|
||||
defaultConfig {
|
||||
minSdkVersion 9
|
||||
targetSdkVersion 22
|
||||
versionCode 1
|
||||
versionName "1.0"
|
||||
}
|
||||
buildTypes {
|
||||
release {
|
||||
minifyEnabled false
|
||||
proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro'
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
compile project(':briar-api')
|
||||
compile project(':briar-core')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.2.0'
|
||||
testApt 'com.google.dagger:dagger-compiler:2.0.2'
|
||||
provided 'javax.annotation:jsr250-api:1.0'
|
||||
testCompile project(':briar-tests')
|
||||
}
|
||||
|
||||
dependencyVerification {
|
||||
verify = [
|
||||
'com.android.support:appcompat-v7:14ab04eb2e3f302a082b79c308f6283d21909d1feb831a4e117cdacdad70adb7',
|
||||
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
|
||||
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
|
||||
'com.android.support:support-v4:992666398b80724a2f95ea3d7bf7c3d94fb810dcba7ae1aa6e38c0d6120d2603',
|
||||
'com.android.support:support-annotations:7f21659b084da073b77b6f7fe7ab250c4f23346238d4efdbbbb937e017ae4693',
|
||||
]
|
||||
|
||||
}
|
||||
17
briar-android-tests/proguard-rules.pro
vendored
Normal file
17
briar-android-tests/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,17 @@
|
||||
# Add project specific ProGuard rules here.
|
||||
# By default, the flags in this file are appended to flags specified
|
||||
# in /home/ernir/dev/sdk/tools/proguard/proguard-android.txt
|
||||
# You can edit the include path and order by changing the proguardFiles
|
||||
# directive in build.gradle.
|
||||
#
|
||||
# For more details, see
|
||||
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||
|
||||
# Add any project specific keep options here:
|
||||
|
||||
# If your project uses WebView with JS, uncomment the following
|
||||
# and specify the fully qualified class name to the JavaScript interface
|
||||
# class:
|
||||
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||
# public *;
|
||||
#}
|
||||
@@ -0,0 +1,13 @@
|
||||
package com.ymirmobile.briar_android_tests;
|
||||
|
||||
import android.app.Application;
|
||||
import android.test.ApplicationTestCase;
|
||||
|
||||
/**
|
||||
* <a href="http://d.android.com/tools/testing/testing_android.html">Testing Fundamentals</a>
|
||||
*/
|
||||
public class ApplicationTest extends ApplicationTestCase<Application> {
|
||||
public ApplicationTest() {
|
||||
super(Application.class);
|
||||
}
|
||||
}
|
||||
12
briar-android-tests/src/main/AndroidManifest.xml
Normal file
12
briar-android-tests/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,12 @@
|
||||
<manifest package="org.briarproject"
|
||||
xmlns:android="http://schemas.android.com/apk/res/android">
|
||||
|
||||
<application
|
||||
android:allowBackup="true"
|
||||
android:label="@string/app_name"
|
||||
android:supportsRtl="true"
|
||||
>
|
||||
|
||||
</application>
|
||||
|
||||
</manifest>
|
||||
3
briar-android-tests/src/main/res/values/strings.xml
Normal file
3
briar-android-tests/src/main/res/values/strings.xml
Normal file
@@ -0,0 +1,3 @@
|
||||
<resources>
|
||||
<string name="app_name">briar-android-tests</string>
|
||||
</resources>
|
||||
@@ -1,8 +1,7 @@
|
||||
package org.briarproject;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
package org.briarproject.protocol;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.SecretKey;
|
||||
@@ -22,21 +21,8 @@ import org.briarproject.api.sync.Request;
|
||||
import org.briarproject.api.transport.StreamContext;
|
||||
import org.briarproject.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.api.transport.StreamWriterFactory;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.sync.SyncModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_GROUP_DESCRIPTOR_LENGTH;
|
||||
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
||||
import static org.junit.Assert.assertArrayEquals;
|
||||
@@ -44,41 +30,50 @@ import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ProtocolIntegrationTest extends BriarTestCase {
|
||||
|
||||
private final StreamReaderFactory streamReaderFactory;
|
||||
private final StreamWriterFactory streamWriterFactory;
|
||||
private final PacketReaderFactory packetReaderFactory;
|
||||
private final PacketWriterFactory packetWriterFactory;
|
||||
@Inject
|
||||
StreamReaderFactory streamReaderFactory;
|
||||
@Inject
|
||||
StreamWriterFactory streamWriterFactory;
|
||||
@Inject
|
||||
PacketReaderFactory packetReaderFactory;
|
||||
@Inject
|
||||
PacketWriterFactory packetWriterFactory;
|
||||
|
||||
private final ContactId contactId;
|
||||
private final TransportId transportId;
|
||||
private final SecretKey tagKey, headerKey;
|
||||
private final Message message, message1;
|
||||
private final Collection<MessageId> messageIds;
|
||||
private final ProtocolTestComponent component;
|
||||
|
||||
public ProtocolIntegrationTest() throws Exception {
|
||||
Injector i = Guice.createInjector(new TestDatabaseModule(),
|
||||
new TestLifecycleModule(), new TestSystemModule(),
|
||||
new CryptoModule(), new DatabaseModule(), new EventModule(),
|
||||
new SyncModule(), new DataModule(),
|
||||
new TransportModule());
|
||||
streamReaderFactory = i.getInstance(StreamReaderFactory.class);
|
||||
streamWriterFactory = i.getInstance(StreamWriterFactory.class);
|
||||
packetReaderFactory = i.getInstance(PacketReaderFactory.class);
|
||||
packetWriterFactory = i.getInstance(PacketWriterFactory.class);
|
||||
|
||||
component = DaggerProtocolTestComponent.builder().build();
|
||||
component.inject(this);
|
||||
|
||||
contactId = new ContactId(234);
|
||||
transportId = new TransportId("id");
|
||||
// Create the transport keys
|
||||
tagKey = TestUtils.createSecretKey();
|
||||
headerKey = TestUtils.createSecretKey();
|
||||
// Create a group
|
||||
GroupFactory groupFactory = i.getInstance(GroupFactory.class);
|
||||
GroupFactory groupFactory = component.getGroupFactory();
|
||||
ClientId clientId = new ClientId(TestUtils.getRandomId());
|
||||
byte[] descriptor = new byte[MAX_GROUP_DESCRIPTOR_LENGTH];
|
||||
Group group = groupFactory.createGroup(clientId, descriptor);
|
||||
// Add two messages to the group
|
||||
MessageFactory messageFactory = i.getInstance(MessageFactory.class);
|
||||
MessageFactory messageFactory = component.getMessageFactory();
|
||||
long timestamp = System.currentTimeMillis();
|
||||
String messageBody = "Hello world";
|
||||
message = messageFactory.createMessage(group.getId(), timestamp,
|
||||
@@ -159,4 +154,5 @@ public class ProtocolIntegrationTest extends BriarTestCase {
|
||||
assertEquals(m1.getTimestamp(), m2.getTimestamp());
|
||||
assertArrayEquals(m1.getRaw(), m2.getRaw());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,26 @@
|
||||
package org.briarproject.protocol;
|
||||
|
||||
import org.briarproject.TestDatabaseModule;
|
||||
import org.briarproject.TestSystemModule;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.api.sync.MessageFactory;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.sync.SyncModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Component;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {TestDatabaseModule.class, TestSystemModule.class,
|
||||
CryptoModule.class, DatabaseModule.class, EventModule.class,
|
||||
SyncModule.class, DataModule.class, TransportModule.class})
|
||||
public interface ProtocolTestComponent {
|
||||
void inject(ProtocolIntegrationTest testCase);
|
||||
GroupFactory getGroupFactory();
|
||||
MessageFactory getMessageFactory();
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
package org.briarproject.sync;
|
||||
|
||||
import org.briarproject.TestDatabaseModule;
|
||||
import org.briarproject.TestLifecycleModule;
|
||||
import org.briarproject.TestSystemModule;
|
||||
import org.briarproject.clients.ClientsModule;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.forum.ForumModule;
|
||||
import org.briarproject.identity.IdentityModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Component;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {TestDatabaseModule.class, TestLifecycleModule.class,
|
||||
TestSystemModule.class, ContactModule.class, CryptoModule.class,
|
||||
DatabaseModule.class, EventModule.class, SyncModule.class,
|
||||
DataModule.class, TransportModule.class, ForumModule.class,
|
||||
IdentityModule.class, MessagingModule.class, ClientsModule.class})
|
||||
public interface ConstantsComponent {
|
||||
void inject(ConstantsTest testCase);
|
||||
}
|
||||
@@ -1,12 +1,6 @@
|
||||
package org.briarproject.sync;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.TestDatabaseModule;
|
||||
import org.briarproject.TestLifecycleModule;
|
||||
import org.briarproject.TestSystemModule;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.UniqueId;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -21,22 +15,6 @@ import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.messaging.MessagingConstants;
|
||||
import org.briarproject.api.messaging.PrivateMessage;
|
||||
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.clients.ClientsModule;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.forum.ForumModule;
|
||||
import org.briarproject.identity.IdentityModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import static org.briarproject.api.forum.ForumConstants.MAX_FORUM_POST_BODY_LENGTH;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
@@ -45,26 +23,32 @@ import static org.briarproject.api.messaging.MessagingConstants.MAX_PRIVATE_MESS
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_PACKET_PAYLOAD_LENGTH;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.junit.Test;
|
||||
|
||||
import java.util.Random;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ConstantsTest extends BriarTestCase {
|
||||
|
||||
// TODO: Break this up into tests that are relevant for each package
|
||||
@Inject
|
||||
CryptoComponent crypto;
|
||||
@Inject
|
||||
AuthorFactory authorFactory;
|
||||
@Inject
|
||||
PrivateMessageFactory privateMessageFactory;
|
||||
@Inject
|
||||
ForumPostFactory forumPostFactory;
|
||||
|
||||
private final CryptoComponent crypto;
|
||||
private final AuthorFactory authorFactory;
|
||||
private final PrivateMessageFactory privateMessageFactory;
|
||||
private final ForumPostFactory forumPostFactory;
|
||||
private final ConstantsComponent component;
|
||||
|
||||
public ConstantsTest() throws Exception {
|
||||
Injector i = Guice.createInjector(new TestDatabaseModule(),
|
||||
new TestLifecycleModule(), new TestSystemModule(),
|
||||
new ClientsModule(), new ContactModule(), new CryptoModule(),
|
||||
new DatabaseModule(), new DataModule(), new EventModule(),
|
||||
new ForumModule(), new IdentityModule(), new MessagingModule(),
|
||||
new SyncModule(), new TransportModule());
|
||||
crypto = i.getInstance(CryptoComponent.class);
|
||||
authorFactory = i.getInstance(AuthorFactory.class);
|
||||
privateMessageFactory = i.getInstance(PrivateMessageFactory.class);
|
||||
forumPostFactory = i.getInstance(ForumPostFactory.class);
|
||||
|
||||
component = DaggerConstantsComponent.builder().build();
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -0,0 +1,52 @@
|
||||
package org.briarproject.sync;
|
||||
|
||||
import org.briarproject.TestDatabaseModule;
|
||||
import org.briarproject.TestSystemModule;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.messaging.MessagingManager;
|
||||
import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||
import org.briarproject.api.sync.PacketReaderFactory;
|
||||
import org.briarproject.api.sync.PacketWriterFactory;
|
||||
import org.briarproject.api.transport.KeyManager;
|
||||
import org.briarproject.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.api.transport.StreamWriterFactory;
|
||||
import org.briarproject.clients.ClientsModule;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.identity.IdentityModule;
|
||||
import org.briarproject.lifecycle.LifecycleModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Component;
|
||||
|
||||
@Singleton
|
||||
@Component(modules = {TestDatabaseModule.class, TestSystemModule.class,
|
||||
LifecycleModule.class, ContactModule.class, CryptoModule.class,
|
||||
DatabaseModule.class, EventModule.class, SyncModule.class,
|
||||
DataModule.class, TransportModule.class, IdentityModule.class,
|
||||
MessagingModule.class, ClientsModule.class})
|
||||
public interface SimplexMessagingComponent {
|
||||
void inject(SimplexMessagingIntegrationTest testCase);
|
||||
LifecycleManager getLifeCycleManager();
|
||||
DatabaseComponent getDatabaseComponent();
|
||||
IdentityManager getIdentityManager();
|
||||
ContactManager getContactManager();
|
||||
MessagingManager getMessagingManager();
|
||||
KeyManager getKeyManager();
|
||||
PrivateMessageFactory getPrivateMessageFactory();
|
||||
PacketWriterFactory getPacketWriterFactory();
|
||||
EventBus getEventBus();
|
||||
StreamWriterFactory getStreamWriterFactory();
|
||||
StreamReaderFactory getStreamReaderFactory();
|
||||
PacketReaderFactory getPacketReaderFactory();
|
||||
}
|
||||
@@ -1,12 +1,8 @@
|
||||
package org.briarproject.sync;
|
||||
|
||||
import com.google.inject.Guice;
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import org.briarproject.BriarTestCase;
|
||||
import org.briarproject.ImmediateExecutor;
|
||||
import org.briarproject.TestDatabaseModule;
|
||||
import org.briarproject.TestSystemModule;
|
||||
import org.briarproject.TestUtils;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
@@ -36,33 +32,23 @@ import org.briarproject.api.transport.KeyManager;
|
||||
import org.briarproject.api.transport.StreamContext;
|
||||
import org.briarproject.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.api.transport.StreamWriterFactory;
|
||||
import org.briarproject.clients.ClientsModule;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.identity.IdentityModule;
|
||||
import org.briarproject.lifecycle.LifecycleModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
import org.junit.After;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
||||
|
||||
import java.io.ByteArrayInputStream;
|
||||
import java.io.ByteArrayOutputStream;
|
||||
import java.io.File;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_PUBLIC_KEY_LENGTH;
|
||||
import static org.briarproject.api.transport.TransportConstants.TAG_LENGTH;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertFalse;
|
||||
import static org.junit.Assert.assertNotNull;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
private static final int MAX_LATENCY = 2 * 60 * 1000; // 2 minutes
|
||||
@@ -76,22 +62,15 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
private final AuthorId aliceId = new AuthorId(TestUtils.getRandomId());
|
||||
private final AuthorId bobId = new AuthorId(TestUtils.getRandomId());
|
||||
|
||||
private Injector alice, bob;
|
||||
private SimplexMessagingComponent alice, bob;
|
||||
|
||||
@Before
|
||||
public void setUp() {
|
||||
assertTrue(testDir.mkdirs());
|
||||
alice = createInjector(aliceDir);
|
||||
bob = createInjector(bobDir);
|
||||
}
|
||||
|
||||
private Injector createInjector(File dir) {
|
||||
return Guice.createInjector(new TestDatabaseModule(dir),
|
||||
new TestSystemModule(), new ClientsModule(),
|
||||
new ContactModule(), new CryptoModule(), new DatabaseModule(),
|
||||
new DataModule(), new EventModule(), new IdentityModule(),
|
||||
new LifecycleModule(), new MessagingModule(), new SyncModule(),
|
||||
new TransportModule());
|
||||
alice = DaggerSimplexMessagingComponent.builder()
|
||||
.testDatabaseModule(new TestDatabaseModule(aliceDir)).build();
|
||||
bob = DaggerSimplexMessagingComponent.builder()
|
||||
.testDatabaseModule(new TestDatabaseModule(bobDir)).build();
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -101,22 +80,19 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
private byte[] write() throws Exception {
|
||||
// Instantiate Alice's services
|
||||
LifecycleManager lifecycleManager =
|
||||
alice.getInstance(LifecycleManager.class);
|
||||
DatabaseComponent db = alice.getInstance(DatabaseComponent.class);
|
||||
IdentityManager identityManager =
|
||||
alice.getInstance(IdentityManager.class);
|
||||
ContactManager contactManager = alice.getInstance(ContactManager.class);
|
||||
MessagingManager messagingManager =
|
||||
alice.getInstance(MessagingManager.class);
|
||||
KeyManager keyManager = alice.getInstance(KeyManager.class);
|
||||
LifecycleManager lifecycleManager = alice.getLifeCycleManager();
|
||||
DatabaseComponent db = alice.getDatabaseComponent();
|
||||
IdentityManager identityManager = alice.getIdentityManager();
|
||||
ContactManager contactManager = alice.getContactManager();
|
||||
MessagingManager messagingManager = alice.getMessagingManager();
|
||||
KeyManager keyManager = alice.getKeyManager();
|
||||
PrivateMessageFactory privateMessageFactory =
|
||||
alice.getInstance(PrivateMessageFactory.class);
|
||||
alice.getPrivateMessageFactory();
|
||||
PacketWriterFactory packetWriterFactory =
|
||||
alice.getInstance(PacketWriterFactory.class);
|
||||
EventBus eventBus = alice.getInstance(EventBus.class);
|
||||
alice.getPacketWriterFactory();
|
||||
EventBus eventBus = alice.getEventBus();
|
||||
StreamWriterFactory streamWriterFactory =
|
||||
alice.getInstance(StreamWriterFactory.class);
|
||||
alice.getStreamWriterFactory();
|
||||
|
||||
// Start the lifecycle manager
|
||||
lifecycleManager.startServices();
|
||||
@@ -172,20 +148,16 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
private void read(byte[] stream) throws Exception {
|
||||
// Instantiate Bob's services
|
||||
LifecycleManager lifecycleManager =
|
||||
bob.getInstance(LifecycleManager.class);
|
||||
DatabaseComponent db = bob.getInstance(DatabaseComponent.class);
|
||||
IdentityManager identityManager =
|
||||
bob.getInstance(IdentityManager.class);
|
||||
ContactManager contactManager = bob.getInstance(ContactManager.class);
|
||||
KeyManager keyManager = bob.getInstance(KeyManager.class);
|
||||
StreamReaderFactory streamReaderFactory =
|
||||
bob.getInstance(StreamReaderFactory.class);
|
||||
PacketReaderFactory packetReaderFactory =
|
||||
bob.getInstance(PacketReaderFactory.class);
|
||||
EventBus eventBus = bob.getInstance(EventBus.class);
|
||||
LifecycleManager lifecycleManager = bob.getLifeCycleManager();
|
||||
DatabaseComponent db = bob.getDatabaseComponent();
|
||||
IdentityManager identityManager = bob.getIdentityManager();
|
||||
ContactManager contactManager = bob.getContactManager();
|
||||
KeyManager keyManager = bob.getKeyManager();
|
||||
StreamReaderFactory streamReaderFactory = bob.getStreamReaderFactory();
|
||||
PacketReaderFactory packetReaderFactory = bob.getPacketReaderFactory();
|
||||
EventBus eventBus = bob.getEventBus();
|
||||
// Bob needs a MessagingManager even though we're not using it directly
|
||||
bob.getInstance(MessagingManager.class);
|
||||
bob.getMessagingManager();
|
||||
|
||||
// Start the lifecyle manager
|
||||
lifecycleManager.startServices();
|
||||
@@ -210,7 +182,7 @@ public class SimplexMessagingIntegrationTest extends BriarTestCase {
|
||||
|
||||
// Set up an event listener
|
||||
MessageListener listener = new MessageListener();
|
||||
bob.getInstance(EventBus.class).addListener(listener);
|
||||
bob.getEventBus().addListener(listener);
|
||||
// Read and recognise the tag
|
||||
ByteArrayInputStream in = new ByteArrayInputStream(stream);
|
||||
byte[] tag = new byte[TAG_LENGTH];
|
||||
@@ -67,6 +67,7 @@
|
||||
</activity>
|
||||
<activity
|
||||
android:name=".android.SplashScreenActivity"
|
||||
android:theme="@style/BriarThemeNoActionBar.Default"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
apply plugin: 'com.android.application'
|
||||
apply plugin: 'witness'
|
||||
apply plugin: 'com.neenbedankt.android-apt'
|
||||
|
||||
repositories {
|
||||
jcenter()
|
||||
@@ -27,10 +28,11 @@ dependencies {
|
||||
exclude module: 'support-v4'
|
||||
exclude module: 'recyclerview-v7'
|
||||
}
|
||||
compile "org.roboguice:roboguice:2.0"
|
||||
compile "info.guardianproject.panic:panic:0.5"
|
||||
compile "info.guardianproject.trustedintents:trustedintents:0.2"
|
||||
compile "de.hdodenhof:circleimageview:2.0.0"
|
||||
apt 'com.google.dagger:dagger-compiler:2.0.2'
|
||||
provided 'javax.annotation:jsr250-api:1.0'
|
||||
}
|
||||
|
||||
dependencyVerification {
|
||||
@@ -42,9 +44,9 @@ dependencyVerification {
|
||||
'com.android.support:design:41a9cd75ca78f25df5f573db7cedf8bb66beae00c330943923ba9f3e2051736d',
|
||||
'com.android.support:support-annotations:f347a35b9748a4103b39a6714a77e2100f488d623fd6268e259c177b200e9d82',
|
||||
'com.android.support:recyclerview-v7:7606373da0931a1e62588335465a0e390cd676c98117edab29220317495faefd',
|
||||
'org.roboguice:roboguice:c5302f2648170ee6015a0d18fe0fcc87e09e415a34aeae3566e8d1a9dbb53f28',
|
||||
'info.guardianproject.panic:panic:a7ed9439826db2e9901649892cf9afbe76f00991b768d8f4c26332d7c9406cb2',
|
||||
'info.guardianproject.trustedintents:trustedintents:6221456d8821a8d974c2acf86306900237cf6afaaa94a4c9c44e161350f80f3e',
|
||||
'com.android.support:support-annotations:f347a35b9748a4103b39a6714a77e2100f488d623fd6268e259c177b200e9d82'
|
||||
]
|
||||
}
|
||||
|
||||
@@ -95,4 +97,4 @@ android {
|
||||
lintOptions {
|
||||
abortOnError false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -46,6 +46,8 @@
|
||||
-keep class javax.inject.** { *; }
|
||||
-keep class javax.annotation.** { *; }
|
||||
-keep class roboguice.** { *; }
|
||||
-keep class dagger.** { *; }
|
||||
-keep class com.google.** { *; }
|
||||
|
||||
-dontwarn org.h2.**
|
||||
-dontnote org.h2.**
|
||||
@@ -53,4 +55,7 @@
|
||||
-dontwarn org.briarproject.plugins.tcp.**
|
||||
-dontwarn roboguice.**
|
||||
-dontwarn net.sourceforge.jsocks.**
|
||||
-dontnote android.support.**
|
||||
-dontnote android.support.**
|
||||
-dontnote dagger.**
|
||||
-dontwarn dagger.**
|
||||
-dontwarn com.google.common.**
|
||||
@@ -1,23 +0,0 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<resources>
|
||||
<string-array name="roboguice_modules">
|
||||
<item>org.briarproject.android.AndroidModule</item>
|
||||
<item>org.briarproject.clients.ClientsModule</item>
|
||||
<item>org.briarproject.contact.ContactModule</item>
|
||||
<item>org.briarproject.crypto.CryptoModule</item>
|
||||
<item>org.briarproject.data.DataModule</item>
|
||||
<item>org.briarproject.db.DatabaseModule</item>
|
||||
<item>org.briarproject.event.EventModule</item>
|
||||
<item>org.briarproject.forum.ForumModule</item>
|
||||
<item>org.briarproject.identity.IdentityModule</item>
|
||||
<item>org.briarproject.invitation.InvitationModule</item>
|
||||
<item>org.briarproject.lifecycle.LifecycleModule</item>
|
||||
<item>org.briarproject.messaging.MessagingModule</item>
|
||||
<item>org.briarproject.plugins.AndroidPluginsModule</item>
|
||||
<item>org.briarproject.properties.PropertiesModule</item>
|
||||
<item>org.briarproject.sync.SyncModule</item>
|
||||
<item>org.briarproject.system.AndroidSystemModule</item>
|
||||
<item>org.briarproject.transport.TransportModule</item>
|
||||
<item>org.briarproject.settings.SettingsModule</item>
|
||||
</string-array>
|
||||
</resources>
|
||||
@@ -23,11 +23,8 @@ import org.briarproject.api.crypto.CryptoComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
|
||||
public class AsymmetricIdenticon extends IdenticonView {
|
||||
|
||||
@Inject private CryptoComponent mCrypto;
|
||||
private IdenticonBase mDelegate;
|
||||
|
||||
public AsymmetricIdenticon(Context context) {
|
||||
@@ -51,12 +48,7 @@ public class AsymmetricIdenticon extends IdenticonView {
|
||||
}
|
||||
|
||||
private void initDelegate() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return mCrypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
|
||||
@@ -10,7 +10,6 @@ import org.briarproject.api.crypto.CryptoComponent;
|
||||
* Created by saiimons on 05/10/14.
|
||||
*/
|
||||
public abstract class IdenticonBase {
|
||||
private final CryptoComponent mCrypto;
|
||||
private final int mRowCount;
|
||||
private final int mColumnCount;
|
||||
private final Paint mPaint;
|
||||
@@ -21,7 +20,6 @@ public abstract class IdenticonBase {
|
||||
private volatile boolean mReady;
|
||||
|
||||
public IdenticonBase() {
|
||||
mCrypto = getCrypto();
|
||||
mRowCount = getRowCount();
|
||||
mColumnCount = getColumnCount();
|
||||
mPaint = new Paint();
|
||||
@@ -32,20 +30,7 @@ public abstract class IdenticonBase {
|
||||
}
|
||||
|
||||
public byte[] getHash(byte[] input) {
|
||||
byte[] mHash;
|
||||
// if the input was null
|
||||
if (input == null) {
|
||||
// we can't create a hash value and have nothing to show (draw to the view)
|
||||
mHash = null;
|
||||
} else {
|
||||
// generate a hash from the input to get unique but deterministic byte values
|
||||
try {
|
||||
mHash = mCrypto.hash(input);
|
||||
} catch (Exception e) {
|
||||
mHash = null;
|
||||
}
|
||||
}
|
||||
return mHash;
|
||||
return input;
|
||||
}
|
||||
|
||||
protected void setupColors() {
|
||||
@@ -65,11 +50,8 @@ public abstract class IdenticonBase {
|
||||
}
|
||||
|
||||
public void show(byte[] input) {
|
||||
if(input != null) {
|
||||
mHash = getHash(input);
|
||||
} else {
|
||||
mHash = null;
|
||||
}
|
||||
mHash = input;
|
||||
|
||||
// set up the cell colors according to the input that was provided via show(...)
|
||||
setupColors();
|
||||
|
||||
@@ -85,8 +67,6 @@ public abstract class IdenticonBase {
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected CryptoComponent getCrypto();
|
||||
|
||||
abstract protected int getRowCount();
|
||||
|
||||
abstract protected int getColumnCount();
|
||||
|
||||
@@ -6,8 +6,6 @@ import android.graphics.Rect;
|
||||
import android.graphics.drawable.Drawable;
|
||||
import android.util.Log;
|
||||
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
|
||||
/**
|
||||
* Created by saiimons on 05/10/14.
|
||||
*/
|
||||
@@ -16,13 +14,9 @@ public class IdenticonDrawable extends Drawable {
|
||||
|
||||
private static final int CENTER_COLUMN_INDEX = 5;
|
||||
|
||||
public IdenticonDrawable(final CryptoComponent crypto, byte[] toShow) {
|
||||
public IdenticonDrawable(byte[] toShow) {
|
||||
super();
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return crypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
|
||||
@@ -23,13 +23,10 @@ import org.briarproject.api.crypto.CryptoComponent;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
|
||||
public class SymmetricIdenticon extends IdenticonView {
|
||||
|
||||
private static final int CENTER_COLUMN_INDEX = 5;
|
||||
|
||||
@Inject private CryptoComponent mCrypto;
|
||||
|
||||
private IdenticonBase mDelegate;
|
||||
|
||||
public SymmetricIdenticon(Context context) {
|
||||
@@ -48,12 +45,7 @@ public class SymmetricIdenticon extends IdenticonView {
|
||||
}
|
||||
|
||||
private void initDelegate() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return mCrypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
|
||||
@@ -0,0 +1,75 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import org.briarproject.CoreEagerSingletons;
|
||||
import org.briarproject.CoreModule;
|
||||
import org.briarproject.android.contact.ContactListFragment;
|
||||
import org.briarproject.android.contact.ConversationActivity;
|
||||
import org.briarproject.android.forum.AvailableForumsActivity;
|
||||
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.WriteForumPostActivity;
|
||||
import org.briarproject.android.fragment.SettingsFragment;
|
||||
import org.briarproject.android.identity.CreateIdentityActivity;
|
||||
import org.briarproject.android.invitation.AddContactActivity;
|
||||
import org.briarproject.android.panic.PanicPreferencesActivity;
|
||||
import org.briarproject.android.panic.PanicResponderActivity;
|
||||
import org.briarproject.plugins.AndroidPluginsModule;
|
||||
import org.briarproject.system.AndroidSystemModule;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Component;
|
||||
|
||||
@Singleton
|
||||
@Component(
|
||||
modules = {CoreModule.class, AppModule.class, AndroidModule.class,
|
||||
AndroidPluginsModule.class, AndroidSystemModule.class})
|
||||
public interface AndroidComponent extends CoreEagerSingletons {
|
||||
|
||||
void inject(SplashScreenActivity activity);
|
||||
|
||||
void inject(SetupActivity activity);
|
||||
|
||||
void inject(NavDrawerActivity activity);
|
||||
|
||||
void inject(PasswordActivity activity);
|
||||
|
||||
void inject(BriarService activity);
|
||||
|
||||
void inject(PanicResponderActivity activity);
|
||||
|
||||
void inject(PanicPreferencesActivity activity);
|
||||
|
||||
void inject(AddContactActivity activity);
|
||||
|
||||
void inject(ConversationActivity activity);
|
||||
|
||||
void inject(CreateIdentityActivity activity);
|
||||
|
||||
void inject(TestingActivity activity);
|
||||
|
||||
void inject(AvailableForumsActivity activity);
|
||||
|
||||
void inject(WriteForumPostActivity activity);
|
||||
|
||||
void inject(CreateForumActivity activity);
|
||||
|
||||
void inject(ShareForumActivity activity);
|
||||
|
||||
void inject(ReadForumPostActivity activity);
|
||||
|
||||
void inject(ForumActivity activity);
|
||||
|
||||
void inject(ContactListFragment fragment);
|
||||
|
||||
void inject(SettingsFragment fragment);
|
||||
|
||||
void inject(ForumListFragment fragment);
|
||||
|
||||
// Eager singleton load
|
||||
void inject(AndroidModule.EagerSingletons init);
|
||||
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
public class AndroidEagerSingletons {
|
||||
|
||||
public static void initEagerSingletons(AndroidComponent c) {
|
||||
c.inject(new AndroidModule.EagerSingletons());
|
||||
}
|
||||
}
|
||||
@@ -1,13 +1,10 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.android.api.ReferenceManager;
|
||||
import org.briarproject.api.crypto.SecretKey;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
@@ -16,11 +13,19 @@ import org.briarproject.api.ui.UiCallback;
|
||||
|
||||
import java.io.File;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import static android.content.Context.MODE_PRIVATE;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
public class AndroidModule extends AbstractModule {
|
||||
@Module
|
||||
public class AndroidModule {
|
||||
|
||||
static class EagerSingletons {
|
||||
@Inject
|
||||
AndroidNotificationManager androidNotificationManager;
|
||||
}
|
||||
|
||||
private final UiCallback uiCallback;
|
||||
|
||||
@@ -42,18 +47,15 @@ public class AndroidModule extends AbstractModule {
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AndroidExecutor.class).to(AndroidExecutorImpl.class).in(
|
||||
Singleton.class);
|
||||
bind(ReferenceManager.class).to(ReferenceManagerImpl.class).in(
|
||||
Singleton.class);
|
||||
bind(UiCallback.class).toInstance(uiCallback);
|
||||
@Provides
|
||||
public UiCallback provideUICallback() {
|
||||
return uiCallback;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
DatabaseConfig getDatabaseConfig(final Application app) {
|
||||
final File dir = app.getApplicationContext().getDir("db", MODE_PRIVATE);
|
||||
@Provides
|
||||
@Singleton
|
||||
public DatabaseConfig provideDatabaseConfig(Application app) {
|
||||
final File dir = app.getApplicationContext().getDir("db", Context.MODE_PRIVATE);
|
||||
return new DatabaseConfig() {
|
||||
|
||||
private volatile SecretKey key = null;
|
||||
@@ -80,12 +82,21 @@ public class AndroidModule extends AbstractModule {
|
||||
};
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
AndroidNotificationManager getAndroidNotificationManager(
|
||||
@Provides
|
||||
@Singleton
|
||||
ReferenceManager provideReferenceManager() {
|
||||
return new ReferenceManagerImpl();
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
AndroidNotificationManager provideAndroidNotificationManager(
|
||||
LifecycleManager lifecycleManager, EventBus eventBus,
|
||||
AndroidNotificationManagerImpl notificationManager) {
|
||||
lifecycleManager.register(notificationManager);
|
||||
eventBus.addListener(notificationManager);
|
||||
|
||||
return notificationManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -12,8 +12,8 @@ import android.support.v4.app.TaskStackBuilder;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.contact.ConversationActivity;
|
||||
import org.briarproject.android.forum.ForumActivity;
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.event.Event;
|
||||
|
||||
24
briar-android/src/org/briarproject/android/AppModule.java
Normal file
24
briar-android/src/org/briarproject/android/AppModule.java
Normal file
@@ -0,0 +1,24 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.app.Application;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class AppModule {
|
||||
|
||||
Application application;
|
||||
|
||||
public AppModule(Application application) {
|
||||
this.application = application;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
Application providesApplication() {
|
||||
return application;
|
||||
}
|
||||
}
|
||||
@@ -9,125 +9,31 @@ import android.support.v7.app.AppCompatActivity;
|
||||
import android.view.View;
|
||||
import android.view.inputmethod.InputMethodManager;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
import com.google.inject.Key;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
import roboguice.activity.event.OnActivityResultEvent;
|
||||
import roboguice.activity.event.OnConfigurationChangedEvent;
|
||||
import roboguice.activity.event.OnContentChangedEvent;
|
||||
import roboguice.activity.event.OnCreateEvent;
|
||||
import roboguice.activity.event.OnDestroyEvent;
|
||||
import roboguice.activity.event.OnNewIntentEvent;
|
||||
import roboguice.activity.event.OnPauseEvent;
|
||||
import roboguice.activity.event.OnRestartEvent;
|
||||
import roboguice.activity.event.OnResumeEvent;
|
||||
import roboguice.activity.event.OnStartEvent;
|
||||
import roboguice.activity.event.OnStopEvent;
|
||||
import roboguice.event.EventManager;
|
||||
import roboguice.inject.RoboInjector;
|
||||
import roboguice.util.RoboContext;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static android.view.inputmethod.InputMethodManager.SHOW_IMPLICIT;
|
||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||
|
||||
public abstract class BaseActivity extends AppCompatActivity
|
||||
implements RoboContext {
|
||||
public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
public final static String PREFS_NAME = "db";
|
||||
public final static String PREF_DB_KEY = "key";
|
||||
public final static String PREF_SEEN_WELCOME_MESSAGE = "welcome_message";
|
||||
|
||||
private final HashMap<Key<?>, Object> scopedObjects =
|
||||
new HashMap<Key<?>, Object>();
|
||||
|
||||
@Inject private EventManager eventManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
RoboInjector injector = RoboGuice.getInjector(this);
|
||||
injector.injectMembersWithoutViews(this);
|
||||
super.onCreate(savedInstanceState);
|
||||
eventManager.fire(new OnCreateEvent(savedInstanceState));
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
AndroidComponent component =
|
||||
((BriarApplication) getApplication()).getApplicationComponent();
|
||||
injectActivity(component);
|
||||
}
|
||||
|
||||
protected void onRestart() {
|
||||
super.onRestart();
|
||||
eventManager.fire(new OnRestartEvent());
|
||||
}
|
||||
|
||||
protected void onStart() {
|
||||
super.onStart();
|
||||
eventManager.fire(new OnStartEvent());
|
||||
}
|
||||
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
eventManager.fire(new OnResumeEvent());
|
||||
}
|
||||
|
||||
protected void onPause() {
|
||||
super.onPause();
|
||||
eventManager.fire(new OnPauseEvent());
|
||||
}
|
||||
|
||||
protected void onNewIntent(Intent intent) {
|
||||
super.onNewIntent(intent);
|
||||
eventManager.fire(new OnNewIntentEvent());
|
||||
}
|
||||
|
||||
protected void onStop() {
|
||||
try {
|
||||
eventManager.fire(new OnStopEvent());
|
||||
} finally {
|
||||
super.onStop();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
protected void onDestroy() {
|
||||
try {
|
||||
eventManager.fire(new OnDestroyEvent());
|
||||
} finally {
|
||||
try {
|
||||
RoboGuice.destroyInjector(this);
|
||||
} finally {
|
||||
super.onDestroy();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
public void onConfigurationChanged(Configuration newConfig) {
|
||||
Configuration currentConfig = getResources().getConfiguration();
|
||||
super.onConfigurationChanged(newConfig);
|
||||
eventManager.fire(new OnConfigurationChangedEvent(currentConfig,
|
||||
newConfig));
|
||||
}
|
||||
|
||||
public void onContentChanged() {
|
||||
super.onContentChanged();
|
||||
RoboGuice.getInjector(this).injectViewMembers(this);
|
||||
eventManager.fire(new OnContentChangedEvent());
|
||||
}
|
||||
|
||||
protected void onActivityResult(int requestCode, int resultCode,
|
||||
Intent data) {
|
||||
super.onActivityResult(requestCode, resultCode, data);
|
||||
eventManager.fire(new OnActivityResultEvent(requestCode, resultCode,
|
||||
data));
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Key<?>, Object> getScopedObjectMap() {
|
||||
return scopedObjects;
|
||||
}
|
||||
public abstract void injectActivity(AndroidComponent component);
|
||||
|
||||
private SharedPreferences getSharedPrefs() {
|
||||
return getSharedPreferences(PREFS_NAME, MODE_PRIVATE);
|
||||
|
||||
@@ -27,7 +27,8 @@ import static android.content.Intent.FLAG_ACTIVITY_SINGLE_TOP;
|
||||
@SuppressLint("Registered")
|
||||
public abstract class BriarActivity extends BaseActivity {
|
||||
|
||||
public static final String KEY_LOCAL_AUTHOR_HANDLE = "briar.LOCAL_AUTHOR_HANDLE";
|
||||
public static final String KEY_LOCAL_AUTHOR_HANDLE =
|
||||
"briar.LOCAL_AUTHOR_HANDLE";
|
||||
public static final String KEY_STARTUP_FAILED = "briar.STARTUP_FAILED";
|
||||
|
||||
public static final int REQUEST_PASSWORD = 1;
|
||||
@@ -38,16 +39,21 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
private final BriarServiceConnection serviceConnection =
|
||||
new BriarServiceConnection();
|
||||
|
||||
@Inject private DatabaseConfig databaseConfig;
|
||||
@Inject
|
||||
DatabaseConfig databaseConfig;
|
||||
private boolean bound = false;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject @DatabaseExecutor private volatile Executor dbExecutor;
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
@Inject
|
||||
@DatabaseExecutor
|
||||
protected volatile Executor dbExecutor;
|
||||
@Inject
|
||||
protected volatile LifecycleManager lifecycleManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (databaseConfig.getEncryptionKey() != null) startAndBindService();
|
||||
}
|
||||
|
||||
|
||||
@@ -6,19 +6,37 @@ import java.util.logging.Logger;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import org.briarproject.CoreModule;
|
||||
|
||||
public class BriarApplication extends Application {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BriarApplication.class.getName());
|
||||
|
||||
private AndroidComponent applicationComponent;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
LOG.info("Created");
|
||||
LOG.info("Application Created");
|
||||
UncaughtExceptionHandler oldHandler =
|
||||
Thread.getDefaultUncaughtExceptionHandler();
|
||||
Context ctx = getApplicationContext();
|
||||
CrashHandler newHandler = new CrashHandler(ctx, oldHandler);
|
||||
Thread.setDefaultUncaughtExceptionHandler(newHandler);
|
||||
|
||||
applicationComponent = DaggerAndroidComponent.builder()
|
||||
.appModule(new AppModule(this))
|
||||
.androidModule(new AndroidModule())
|
||||
.build();
|
||||
|
||||
// We need to load the eager singletons directly after making the
|
||||
// dependency graphs
|
||||
CoreModule.initEagerSingletons(applicationComponent);
|
||||
AndroidEagerSingletons.initEagerSingletons(applicationComponent);
|
||||
}
|
||||
|
||||
public AndroidComponent getApplicationComponent() {
|
||||
return applicationComponent;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,6 +2,7 @@ package org.briarproject.android;
|
||||
|
||||
import android.app.NotificationManager;
|
||||
import android.app.PendingIntent;
|
||||
import android.app.Service;
|
||||
import android.content.ComponentName;
|
||||
import android.content.Intent;
|
||||
import android.content.ServiceConnection;
|
||||
@@ -11,7 +12,7 @@ import android.os.IBinder;
|
||||
import android.support.v4.app.NotificationCompat;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager.StartResult;
|
||||
@@ -22,8 +23,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.service.RoboService;
|
||||
|
||||
import static android.app.PendingIntent.FLAG_UPDATE_CURRENT;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_CLEAR_TOP;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
@@ -34,7 +33,7 @@ import static java.util.logging.Level.WARNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.ALREADY_RUNNING;
|
||||
import static org.briarproject.api.lifecycle.LifecycleManager.StartResult.SUCCESS;
|
||||
|
||||
public class BriarService extends RoboService {
|
||||
public class BriarService extends Service {
|
||||
|
||||
private static final int ONGOING_NOTIFICATION_ID = 1;
|
||||
private static final int FAILURE_NOTIFICATION_ID = 2;
|
||||
@@ -45,16 +44,20 @@ public class BriarService extends RoboService {
|
||||
private final AtomicBoolean created = new AtomicBoolean(false);
|
||||
private final Binder binder = new BriarBinder();
|
||||
|
||||
@Inject private DatabaseConfig databaseConfig;
|
||||
@Inject protected DatabaseConfig databaseConfig;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile LifecycleManager lifecycleManager;
|
||||
@Inject private volatile AndroidExecutor androidExecutor;
|
||||
@Inject protected volatile LifecycleManager lifecycleManager;
|
||||
@Inject protected volatile AndroidExecutor androidExecutor;
|
||||
private volatile boolean started = false;
|
||||
|
||||
@Override
|
||||
public void onCreate() {
|
||||
super.onCreate();
|
||||
|
||||
((BriarApplication) this.getApplication())
|
||||
.getApplicationComponent().inject(this);
|
||||
|
||||
LOG.info("Created");
|
||||
if (created.getAndSet(true)) {
|
||||
LOG.info("Already created");
|
||||
|
||||
@@ -8,12 +8,12 @@ import android.os.Bundle;
|
||||
import android.support.v4.view.GravityCompat;
|
||||
import android.support.v4.widget.DrawerLayout;
|
||||
import android.support.v7.app.ActionBarDrawerToggle;
|
||||
import android.support.v7.widget.AppCompatButton;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.view.LayoutInflater;
|
||||
import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
import android.widget.BaseAdapter;
|
||||
import android.widget.Button;
|
||||
import android.widget.GridView;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.TextView;
|
||||
@@ -24,7 +24,7 @@ import org.briarproject.android.forum.ForumListFragment;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.android.util.CustomAnimations;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.android.api.ReferenceManager;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
@@ -42,9 +42,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
import roboguice.inject.InjectView;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
@@ -60,33 +57,23 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
||||
@Inject
|
||||
private ReferenceManager referenceManager;
|
||||
protected ReferenceManager referenceManager;
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
private volatile IdentityManager identityManager;
|
||||
protected volatile IdentityManager identityManager;
|
||||
@Inject
|
||||
private PluginManager pluginManager;
|
||||
protected PluginManager pluginManager;
|
||||
@Inject
|
||||
protected volatile EventBus eventBus;
|
||||
|
||||
@InjectView(R.id.toolbar)
|
||||
private Toolbar toolbar;
|
||||
@InjectView(R.id.drawer_layout)
|
||||
private DrawerLayout drawerLayout;
|
||||
@InjectView(R.id.nav_btn_contacts)
|
||||
private AppCompatButton contactButton;
|
||||
@InjectView(R.id.nav_btn_contacts)
|
||||
private AppCompatButton forumsButton;
|
||||
@InjectView(R.id.nav_btn_contacts)
|
||||
private AppCompatButton settingsButton;
|
||||
@InjectView(R.id.nav_menu_header)
|
||||
private TextView menuHeader;
|
||||
@InjectView(R.id.title_progress_bar)
|
||||
private TextView progressTitle;
|
||||
@InjectView(R.id.container_progress)
|
||||
ViewGroup progressViewGroup;
|
||||
@InjectView(R.id.transportsView)
|
||||
private Button contactButton;
|
||||
private Button forumsButton;
|
||||
private Button settingsButton;
|
||||
private GridView transportsView;
|
||||
private TextView progressTitle;
|
||||
private ViewGroup progressViewGroup;
|
||||
|
||||
private List<Transport> transports;
|
||||
private BaseAdapter transportsAdapter;
|
||||
@@ -104,6 +91,11 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@SuppressWarnings("ConstantConditions")
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -112,9 +104,16 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
if (isStartupFailed(getIntent()))
|
||||
return;
|
||||
|
||||
// TODO inflate and inject with @ContentView with RoboGuice 3.0 and later
|
||||
setContentView(R.layout.activity_nav_drawer);
|
||||
RoboGuice.getInjector(this).injectViewMembers(this);
|
||||
|
||||
toolbar = (Toolbar)findViewById(R.id.toolbar);
|
||||
drawerLayout = (DrawerLayout)findViewById(R.id.drawer_layout);
|
||||
contactButton = (Button)findViewById(R.id.nav_btn_contacts);
|
||||
forumsButton = (Button)findViewById(R.id.nav_btn_forums);
|
||||
settingsButton = (Button)findViewById(R.id.nav_btn_settings);
|
||||
transportsView = (GridView)findViewById(R.id.transportsView);
|
||||
progressTitle = (TextView)findViewById(R.id.title_progress_bar);
|
||||
progressViewGroup = (ViewGroup)findViewById(R.id.container_progress);
|
||||
|
||||
setSupportActionBar(toolbar);
|
||||
getSupportActionBar().setDisplayHomeAsUpEnabled(true);
|
||||
|
||||
@@ -34,7 +34,7 @@ import static android.view.View.VISIBLE;
|
||||
|
||||
public class PasswordActivity extends BaseActivity {
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private Button signInButton;
|
||||
private ProgressBar progress;
|
||||
private TextInputLayout input;
|
||||
@@ -43,8 +43,8 @@ public class PasswordActivity extends BaseActivity {
|
||||
private byte[] encrypted;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile DatabaseConfig databaseConfig;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
@Inject protected volatile DatabaseConfig databaseConfig;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -74,7 +74,8 @@ public class PasswordActivity extends BaseActivity {
|
||||
password.addTextChangedListener(new TextWatcher() {
|
||||
@Override
|
||||
public void beforeTextChanged(CharSequence s, int start, int count,
|
||||
int after) {}
|
||||
int after) {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onTextChanged(CharSequence s, int start, int before,
|
||||
@@ -83,10 +84,16 @@ public class PasswordActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void afterTextChanged(Editable s) {}
|
||||
public void afterTextChanged(Editable s) {
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onBackPressed() {
|
||||
// Show the home screen rather than another password prompt
|
||||
|
||||
@@ -8,7 +8,7 @@ import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.android.api.ReferenceManager;
|
||||
|
||||
class ReferenceManagerImpl implements ReferenceManager {
|
||||
|
||||
|
||||
@@ -17,7 +17,7 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.AndroidUtils;
|
||||
import org.briarproject.android.util.StrengthMeter;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.android.api.ReferenceManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.crypto.KeyPair;
|
||||
@@ -33,8 +33,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.inject.InjectView;
|
||||
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
@@ -50,29 +48,40 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SetupActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject private PasswordStrengthEstimator strengthEstimator;
|
||||
@InjectView(R.id.nickname_entry_wrapper) TextInputLayout nicknameEntryWrapper;
|
||||
@InjectView(R.id.password_entry_wrapper) TextInputLayout passwordEntryWrapper;
|
||||
@InjectView(R.id.password_confirm_wrapper) TextInputLayout passwordConfirmationWrapper;
|
||||
@InjectView(R.id.nickname_entry) EditText nicknameEntry;
|
||||
@InjectView(R.id.password_entry) EditText passwordEntry;
|
||||
@InjectView(R.id.password_confirm) EditText passwordConfirmation;
|
||||
@InjectView(R.id.strength_meter) StrengthMeter strengthMeter;
|
||||
@InjectView(R.id.create_account) Button createAccountButton;
|
||||
@InjectView(R.id.progress_wheel) ProgressBar progress;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
@Inject protected PasswordStrengthEstimator strengthEstimator;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile DatabaseConfig databaseConfig;
|
||||
@Inject private volatile AuthorFactory authorFactory;
|
||||
@Inject private volatile ReferenceManager referenceManager;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
@Inject protected volatile DatabaseConfig databaseConfig;
|
||||
@Inject protected volatile AuthorFactory authorFactory;
|
||||
@Inject protected volatile ReferenceManager referenceManager;
|
||||
|
||||
TextInputLayout nicknameEntryWrapper;
|
||||
TextInputLayout passwordEntryWrapper;
|
||||
TextInputLayout passwordConfirmationWrapper;
|
||||
EditText nicknameEntry;
|
||||
EditText passwordEntry;
|
||||
EditText passwordConfirmation;
|
||||
StrengthMeter strengthMeter;
|
||||
Button createAccountButton;
|
||||
ProgressBar progress;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
setContentView(R.layout.activity_setup);
|
||||
|
||||
nicknameEntryWrapper = (TextInputLayout)findViewById(R.id.nickname_entry_wrapper);
|
||||
passwordEntryWrapper = (TextInputLayout)findViewById(R.id.password_entry_wrapper);
|
||||
passwordConfirmationWrapper = (TextInputLayout)findViewById(R.id.password_confirm_wrapper);
|
||||
nicknameEntry = (EditText)findViewById(R.id.nickname_entry);
|
||||
passwordEntry = (EditText)findViewById(R.id.password_entry);
|
||||
passwordConfirmation = (EditText)findViewById(R.id.password_confirm);
|
||||
strengthMeter = (StrengthMeter)findViewById(R.id.strength_meter);
|
||||
createAccountButton = (Button)findViewById(R.id.create_account);
|
||||
progress = (ProgressBar)findViewById(R.id.progress_wheel);
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
TextWatcher tw = new TextWatcher() {
|
||||
@@ -99,6 +108,11 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
createAccountButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void enableOrDisableContinueButton() {
|
||||
if (progress == null) return; // Not created yet
|
||||
if (passwordEntry.getText().length() > 0 && passwordEntry.hasFocus())
|
||||
|
||||
@@ -1,9 +1,9 @@
|
||||
package org.briarproject.android;
|
||||
|
||||
import android.content.Intent;
|
||||
import android.content.SharedPreferences;
|
||||
import android.graphics.Color;
|
||||
import android.os.Bundle;
|
||||
import android.os.Handler;
|
||||
import android.os.StrictMode;
|
||||
import android.os.StrictMode.ThreadPolicy;
|
||||
import android.os.StrictMode.VmPolicy;
|
||||
@@ -11,29 +11,22 @@ import android.support.v7.preference.PreferenceManager;
|
||||
import android.widget.ImageView;
|
||||
import android.widget.LinearLayout;
|
||||
|
||||
import com.google.inject.Injector;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.util.AndroidUtils;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.util.FileUtils;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
import roboguice.activity.RoboSplashActivity;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.view.Gravity.CENTER;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static org.briarproject.android.BaseActivity.PREFS_NAME;
|
||||
import static org.briarproject.android.BaseActivity.PREF_DB_KEY;
|
||||
import static org.briarproject.android.TestingConstants.DEFAULT_LOG_LEVEL;
|
||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||
import static org.briarproject.android.TestingConstants.TESTING;
|
||||
import static org.briarproject.android.util.CommonLayoutParams.MATCH_MATCH;
|
||||
|
||||
public class SplashScreenActivity extends RoboSplashActivity {
|
||||
public class SplashScreenActivity extends BaseActivity {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SplashScreenActivity.class.getName());
|
||||
@@ -43,18 +36,20 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
|
||||
private long now = System.currentTimeMillis();
|
||||
|
||||
@Inject
|
||||
DatabaseConfig dbConfig;
|
||||
|
||||
|
||||
|
||||
public SplashScreenActivity() {
|
||||
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);
|
||||
enableStrictMode();
|
||||
minDisplayMs = 500;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
LinearLayout layout = new LinearLayout(this);
|
||||
layout.setLayoutParams(MATCH_MATCH);
|
||||
layout.setGravity(CENTER);
|
||||
@@ -70,26 +65,31 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
setPreferencesDefaults();
|
||||
|
||||
setContentView(layout);
|
||||
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
startNextActivity();
|
||||
}
|
||||
}, 500);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
protected void startNextActivity() {
|
||||
long duration = System.currentTimeMillis() - now;
|
||||
if (LOG.isLoggable(INFO))
|
||||
LOG.info("Guice startup took " + duration + " ms");
|
||||
if (System.currentTimeMillis() >= EXPIRY_DATE) {
|
||||
LOG.info("Expired");
|
||||
startActivity(new Intent(this, ExpiredActivity.class));
|
||||
} else {
|
||||
SharedPreferences prefs = getSharedPreferences(PREFS_NAME,
|
||||
MODE_PRIVATE);
|
||||
String hex = prefs.getString(PREF_DB_KEY, null);
|
||||
Injector i = RoboGuice.getBaseApplicationInjector(getApplication());
|
||||
DatabaseConfig databaseConfig = i.getInstance(DatabaseConfig.class);
|
||||
if (hex != null && databaseConfig.databaseExists()) {
|
||||
String hex = getEncryptedDatabaseKey();
|
||||
|
||||
if (hex != null && dbConfig.databaseExists()) {
|
||||
startActivity(new Intent(this, NavDrawerActivity.class));
|
||||
} else {
|
||||
prefs.edit().clear().apply();
|
||||
clearSharedPrefs();
|
||||
AndroidUtils.deleteAppData(this);
|
||||
startActivity(new Intent(this, SetupActivity.class));
|
||||
}
|
||||
@@ -114,7 +114,7 @@ public class SplashScreenActivity extends RoboSplashActivity {
|
||||
@Override
|
||||
public void run() {
|
||||
PreferenceManager.setDefaultValues(SplashScreenActivity.this,
|
||||
R.xml.panic_preferences, false);
|
||||
R.xml.panic_preferences, false);
|
||||
}
|
||||
}.start();
|
||||
}
|
||||
|
||||
@@ -19,6 +19,11 @@ public class StartupFailureActivity extends BaseActivity {
|
||||
handleIntent(getIntent());
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
|
||||
}
|
||||
|
||||
private void handleIntent(Intent i) {
|
||||
StartResult result = (StartResult) i.getSerializableExtra("briar.START_RESULT");
|
||||
int notificationId = i.getIntExtra("briar.FAILURE_NOTIFICATION_ID", -1);
|
||||
|
||||
@@ -75,9 +75,9 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(TestingActivity.class.getName());
|
||||
|
||||
@Inject private PluginManager pluginManager;
|
||||
@Inject private LifecycleManager lifecycleManager;
|
||||
@Inject private TransportPropertyManager transportPropertyManager;
|
||||
@Inject protected PluginManager pluginManager;
|
||||
@Inject protected LifecycleManager lifecycleManager;
|
||||
@Inject protected TransportPropertyManager transportPropertyManager;
|
||||
private ScrollView scroll = null;
|
||||
private ListLoadingProgressBar progress = null;
|
||||
private LinearLayout status = null;
|
||||
@@ -137,6 +137,11 @@ public class TestingActivity extends BriarActivity implements OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.android;
|
||||
package org.briarproject.android.api;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.android;
|
||||
package org.briarproject.android.api;
|
||||
|
||||
import org.briarproject.api.sync.GroupId;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.api.android;
|
||||
package org.briarproject.android.api;
|
||||
|
||||
/**
|
||||
* Manages mappings between object references and serialisable handles. This
|
||||
@@ -87,11 +87,9 @@ public class ContactListAdapter
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private CryptoComponent crypto;
|
||||
|
||||
public ContactListAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||
public ContactListAdapter(Context context) {
|
||||
ctx = context;
|
||||
crypto = cryptoComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +119,7 @@ public class ContactListAdapter
|
||||
|
||||
Author author = item.getContact().getAuthor();
|
||||
ui.avatar.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, author.getId().getBytes()));
|
||||
new IdenticonDrawable(author.getId().getBytes()));
|
||||
String contactName = author.getName();
|
||||
if (unread > 0) {
|
||||
ui.name.setText(contactName + " (" + unread + ")");
|
||||
|
||||
@@ -10,6 +10,8 @@ import android.view.View;
|
||||
import android.view.ViewGroup;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarApplication;
|
||||
import org.briarproject.android.fragment.BaseEventFragment;
|
||||
import org.briarproject.android.invitation.AddContactActivity;
|
||||
import org.briarproject.android.util.BriarRecyclerView;
|
||||
@@ -64,19 +66,22 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
}
|
||||
|
||||
@Inject
|
||||
private CryptoComponent crypto;
|
||||
@Inject
|
||||
private ConnectionRegistry connectionRegistry;
|
||||
protected ConnectionRegistry connectionRegistry;
|
||||
private ContactListAdapter adapter = null;
|
||||
private BriarRecyclerView list = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject
|
||||
private volatile ContactManager contactManager;
|
||||
protected volatile ContactManager contactManager;
|
||||
@Inject
|
||||
private volatile MessagingManager messagingManager;
|
||||
protected volatile MessagingManager messagingManager;
|
||||
@Inject
|
||||
private volatile EventBus eventBus;
|
||||
protected volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -86,7 +91,7 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
inflater.inflate(R.layout.activity_contact_list, container,
|
||||
false);
|
||||
|
||||
adapter = new ContactListAdapter(getContext(), crypto);
|
||||
adapter = new ContactListAdapter(getContext());
|
||||
list = (BriarRecyclerView) contentView.findViewById(R.id.contactList);
|
||||
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
@@ -17,14 +17,14 @@ import android.widget.ImageButton;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.BriarRecyclerView;
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchContactException;
|
||||
@@ -71,10 +71,9 @@ public class ConversationActivity extends BriarActivity
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationActivity.class.getName());
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private AndroidNotificationManager notificationManager;
|
||||
@Inject private ConnectionRegistry connectionRegistry;
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject protected AndroidNotificationManager notificationManager;
|
||||
@Inject protected ConnectionRegistry connectionRegistry;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
||||
private ConversationAdapter adapter = null;
|
||||
private BriarRecyclerView list = null;
|
||||
@@ -82,10 +81,10 @@ public class ConversationActivity extends BriarActivity
|
||||
private ImageButton sendButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ContactManager contactManager;
|
||||
@Inject private volatile MessagingManager messagingManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@Inject private volatile PrivateMessageFactory privateMessageFactory;
|
||||
@Inject protected volatile ContactManager contactManager;
|
||||
@Inject protected volatile MessagingManager messagingManager;
|
||||
@Inject protected volatile EventBus eventBus;
|
||||
@Inject protected volatile PrivateMessageFactory privateMessageFactory;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile ContactId contactId = null;
|
||||
private volatile String contactName = null;
|
||||
@@ -103,7 +102,7 @@ public class ConversationActivity extends BriarActivity
|
||||
|
||||
setContentView(R.layout.activity_conversation);
|
||||
|
||||
adapter = new ConversationAdapter(this, crypto);
|
||||
adapter = new ConversationAdapter(this);
|
||||
list = (BriarRecyclerView) findViewById(R.id.conversationView);
|
||||
list.setLayoutManager(new LinearLayoutManager(this));
|
||||
list.setAdapter(adapter);
|
||||
@@ -115,6 +114,11 @@ public class ConversationActivity extends BriarActivity
|
||||
sendButton.setOnClickListener(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -73,12 +73,10 @@ class ConversationAdapter extends
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private CryptoComponent crypto;
|
||||
private byte[] identiconKey;
|
||||
|
||||
public ConversationAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||
public ConversationAdapter(Context context) {
|
||||
ctx = context;
|
||||
crypto = cryptoComponent;
|
||||
}
|
||||
|
||||
public void setIdenticonKey(byte[] key) {
|
||||
@@ -133,7 +131,7 @@ class ConversationAdapter extends
|
||||
} else {
|
||||
if (identiconKey != null)
|
||||
ui.avatar.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, identiconKey));
|
||||
new IdenticonDrawable(identiconKey));
|
||||
if (!header.isRead()) {
|
||||
int left = ui.layout.getPaddingLeft();
|
||||
int top = ui.layout.getPaddingTop();
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.widget.ListView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
@@ -47,9 +48,9 @@ implements EventListener, OnItemClickListener {
|
||||
private ListView list = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -66,6 +67,11 @@ implements EventListener, OnItemClickListener {
|
||||
setContentView(loading);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.db.DbException;
|
||||
@@ -51,7 +52,7 @@ implements OnEditorActionListener, OnClickListener {
|
||||
private TextView feedback = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -102,6 +103,11 @@ implements OnEditorActionListener, OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void enableOrDisableCreateButton() {
|
||||
if (progress == null) return; // Not created yet
|
||||
createForumButton.setEnabled(validateName());
|
||||
|
||||
@@ -13,11 +13,12 @@ import android.widget.ListView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.ListLoadingProgressBar;
|
||||
import org.briarproject.api.android.AndroidNotificationManager;
|
||||
import org.briarproject.android.api.AndroidNotificationManager;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.NoSuchGroupException;
|
||||
import org.briarproject.api.db.NoSuchMessageException;
|
||||
@@ -62,7 +63,7 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ForumActivity.class.getName());
|
||||
|
||||
@Inject private AndroidNotificationManager notificationManager;
|
||||
@Inject protected AndroidNotificationManager notificationManager;
|
||||
private Map<MessageId, byte[]> bodyCache = new HashMap<MessageId, byte[]>();
|
||||
private TextView empty = null;
|
||||
private ForumAdapter adapter = null;
|
||||
@@ -71,8 +72,8 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
private ImageButton composeButton = null, shareButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile EventBus eventBus;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile EventBus eventBus;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile Forum forum = null;
|
||||
|
||||
@@ -139,6 +140,11 @@ public class ForumActivity extends BriarActivity implements EventListener,
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.fragment.BaseEventFragment;
|
||||
import org.briarproject.android.util.HorizontalBorder;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
@@ -83,8 +84,8 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
private ImageButton newForumButton = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
|
||||
@Nullable
|
||||
@Override
|
||||
@@ -152,6 +153,11 @@ public class ForumListFragment extends BaseEventFragment implements
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -12,6 +12,7 @@ import android.widget.ScrollView;
|
||||
import android.widget.TextView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.AuthorView;
|
||||
import org.briarproject.android.util.ElasticHorizontalSpace;
|
||||
@@ -59,7 +60,7 @@ implements OnClickListener {
|
||||
private int position = -1;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
private volatile MessageId messageId = null;
|
||||
|
||||
@Override
|
||||
@@ -164,6 +165,11 @@ implements OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
|
||||
@@ -11,6 +11,7 @@ import android.widget.RadioButton;
|
||||
import android.widget.RadioGroup;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.contact.SelectContactsDialog;
|
||||
import org.briarproject.android.invitation.AddContactActivity;
|
||||
@@ -51,8 +52,8 @@ SelectContactsDialog.Listener {
|
||||
private boolean changed = false;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile ContactManager contactManager;
|
||||
@Inject private volatile ForumSharingManager forumSharingManager;
|
||||
@Inject protected volatile ContactManager contactManager;
|
||||
@Inject protected volatile ForumSharingManager forumSharingManager;
|
||||
private volatile GroupId groupId = null;
|
||||
private volatile Collection<Contact> contacts = null;
|
||||
private volatile Collection<ContactId> selected = null;
|
||||
@@ -109,6 +110,11 @@ SelectContactsDialog.Listener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
if (view == shareWithAll) {
|
||||
changed = true;
|
||||
|
||||
@@ -16,6 +16,7 @@ import android.widget.TextView;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.identity.CreateIdentityActivity;
|
||||
import org.briarproject.android.identity.LocalAuthorItem;
|
||||
@@ -67,7 +68,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(WriteForumPostActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private LocalAuthorSpinnerAdapter adapter = null;
|
||||
private Spinner spinner = null;
|
||||
private ImageButton sendButton = null;
|
||||
@@ -76,10 +77,10 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
private GroupId groupId = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject private volatile ForumManager forumManager;
|
||||
@Inject private volatile ForumPostFactory forumPostFactory;
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject protected volatile IdentityManager identityManager;
|
||||
@Inject protected volatile ForumManager forumManager;
|
||||
@Inject protected volatile ForumPostFactory forumPostFactory;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
private volatile MessageId parentId = null;
|
||||
private volatile long minTimestamp = -1;
|
||||
private volatile LocalAuthor localAuthor = null;
|
||||
@@ -123,7 +124,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
left.addRule(CENTER_VERTICAL);
|
||||
header.addView(from, left);
|
||||
|
||||
adapter = new LocalAuthorSpinnerAdapter(this, crypto, true);
|
||||
adapter = new LocalAuthorSpinnerAdapter(this, true);
|
||||
spinner = new Spinner(this);
|
||||
spinner.setId(2);
|
||||
spinner.setAdapter(adapter);
|
||||
@@ -157,6 +158,11 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
package org.briarproject.android.fragment;
|
||||
|
||||
import android.content.Context;
|
||||
import android.os.Bundle;
|
||||
import android.support.v4.app.Fragment;
|
||||
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.BriarApplication;
|
||||
|
||||
import roboguice.fragment.RoboFragment;
|
||||
|
||||
public abstract class BaseFragment extends RoboFragment {
|
||||
public abstract class BaseFragment extends Fragment {
|
||||
|
||||
public abstract String getUniqueTag();
|
||||
|
||||
@@ -25,10 +27,25 @@ public abstract class BaseFragment extends RoboFragment {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
|
||||
AndroidComponent component =
|
||||
((BriarApplication) getActivity().getApplication())
|
||||
.getApplicationComponent();
|
||||
injectActivity(component);
|
||||
}
|
||||
|
||||
public abstract void injectActivity(AndroidComponent component);
|
||||
|
||||
public interface BaseFragmentListener {
|
||||
void showLoadingScreen(boolean isBlocking, int stringId);
|
||||
|
||||
void hideLoadingScreen();
|
||||
|
||||
void runOnUiThread(Runnable runnable);
|
||||
|
||||
void runOnDbThread(Runnable runnable);
|
||||
}
|
||||
|
||||
|
||||
@@ -9,6 +9,7 @@ import android.view.ViewGroup;
|
||||
import android.widget.GridView;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.api.event.Event;
|
||||
import org.briarproject.api.plugins.PluginManager;
|
||||
|
||||
@@ -16,8 +17,6 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.inject.InjectView;
|
||||
|
||||
public class DashboardFragment extends BaseEventFragment {
|
||||
|
||||
public final static String TAG = "DashboardFragment";
|
||||
@@ -26,10 +25,7 @@ public class DashboardFragment extends BaseEventFragment {
|
||||
Logger.getLogger(DashboardFragment.class.getName());
|
||||
|
||||
@Inject
|
||||
private PluginManager pluginManager;
|
||||
|
||||
@InjectView(R.id.transportsView)
|
||||
private GridView transportsView;
|
||||
protected PluginManager pluginManager;
|
||||
|
||||
public static DashboardFragment newInstance() {
|
||||
|
||||
@@ -59,6 +55,11 @@ public class DashboardFragment extends BaseEventFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void eventOccurred(Event e) {
|
||||
|
||||
|
||||
@@ -14,6 +14,7 @@ import android.widget.TextView.OnEditorActionListener;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.LayoutUtils;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -50,16 +51,16 @@ implements OnEditorActionListener, OnClickListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(CreateIdentityActivity.class.getName());
|
||||
|
||||
@Inject @CryptoExecutor private Executor cryptoExecutor;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
private EditText nicknameEntry = null;
|
||||
private Button createIdentityButton = null;
|
||||
private ProgressBar progress = null;
|
||||
private TextView feedback = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile CryptoComponent crypto;
|
||||
@Inject private volatile AuthorFactory authorFactory;
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject protected volatile CryptoComponent crypto;
|
||||
@Inject protected volatile AuthorFactory authorFactory;
|
||||
@Inject protected volatile IdentityManager identityManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -112,6 +113,11 @@ implements OnEditorActionListener, OnClickListener {
|
||||
setContentView(layout);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void enableOrDisableCreateButton() {
|
||||
if (progress == null) return; // Not created yet
|
||||
createIdentityButton.setEnabled(validateNickname());
|
||||
|
||||
@@ -23,17 +23,14 @@ import static org.briarproject.android.identity.LocalAuthorItem.ANONYMOUS;
|
||||
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
||||
|
||||
public class LocalAuthorSpinnerAdapter extends BaseAdapter
|
||||
implements SpinnerAdapter {
|
||||
implements SpinnerAdapter {
|
||||
|
||||
private final Context ctx;
|
||||
private final CryptoComponent crypto;
|
||||
private final boolean includeAnonymous;
|
||||
private final List<LocalAuthorItem> list = new ArrayList<LocalAuthorItem>();
|
||||
|
||||
public LocalAuthorSpinnerAdapter(Context ctx,
|
||||
CryptoComponent crypto, boolean includeAnonymous) {
|
||||
public LocalAuthorSpinnerAdapter(Context ctx, boolean includeAnonymous) {
|
||||
this.ctx = ctx;
|
||||
this.crypto = crypto;
|
||||
this.includeAnonymous = includeAnonymous;
|
||||
}
|
||||
|
||||
@@ -78,7 +75,7 @@ implements SpinnerAdapter {
|
||||
} else {
|
||||
name.setText(item.getLocalAuthor().getName());
|
||||
avatar.setVisibility(View.VISIBLE);
|
||||
avatar.setImageDrawable(new IdenticonDrawable(crypto,
|
||||
avatar.setImageDrawable(new IdenticonDrawable(
|
||||
item.getLocalAuthor().getId().getBytes()));
|
||||
}
|
||||
return view;
|
||||
|
||||
@@ -5,8 +5,9 @@ import android.os.Bundle;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.api.android.ReferenceManager;
|
||||
import org.briarproject.android.api.ReferenceManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
@@ -38,9 +39,9 @@ implements InvitationListener {
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(AddContactActivity.class.getName());
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
@Inject private InvitationTaskFactory invitationTaskFactory;
|
||||
@Inject private ReferenceManager referenceManager;
|
||||
@Inject protected CryptoComponent crypto;
|
||||
@Inject protected InvitationTaskFactory invitationTaskFactory;
|
||||
@Inject protected ReferenceManager referenceManager;
|
||||
private AddContactView view = null;
|
||||
private InvitationTask task = null;
|
||||
private long taskHandle = -1;
|
||||
@@ -53,7 +54,7 @@ implements InvitationListener {
|
||||
private String contactName = null;
|
||||
|
||||
// Fields that are accessed from background threads must be volatile
|
||||
@Inject private volatile IdentityManager identityManager;
|
||||
@Inject protected volatile IdentityManager identityManager;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
@@ -138,6 +139,11 @@ implements InvitationListener {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void showToastAndFinish() {
|
||||
String format = getString(R.string.contact_added_toast);
|
||||
String text = String.format(format, contactName);
|
||||
|
||||
@@ -16,16 +16,11 @@ import org.briarproject.android.identity.CreateIdentityActivity;
|
||||
import org.briarproject.android.identity.LocalAuthorItem;
|
||||
import org.briarproject.android.identity.LocalAuthorItemComparator;
|
||||
import org.briarproject.android.identity.LocalAuthorSpinnerAdapter;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.identity.AuthorId;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
|
||||
import java.util.Collection;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import roboguice.RoboGuice;
|
||||
|
||||
import static android.bluetooth.BluetoothAdapter.ACTION_REQUEST_DISCOVERABLE;
|
||||
import static android.bluetooth.BluetoothAdapter.EXTRA_DISCOVERABLE_DURATION;
|
||||
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
||||
@@ -35,7 +30,6 @@ import static org.briarproject.android.invitation.AddContactActivity.REQUEST_CRE
|
||||
class ChooseIdentityView extends AddContactView
|
||||
implements OnItemSelectedListener, OnClickListener {
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
private LocalAuthorSpinnerAdapter adapter = null;
|
||||
private Spinner spinner = null;
|
||||
|
||||
@@ -46,7 +40,6 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
void populate() {
|
||||
removeAllViews();
|
||||
Context ctx = getContext();
|
||||
RoboGuice.injectMembers(ctx, this);
|
||||
|
||||
LayoutInflater inflater = (LayoutInflater) ctx.getSystemService
|
||||
(Context.LAYOUT_INFLATER_SERVICE);
|
||||
@@ -57,7 +50,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
TextView step = (TextView) view.findViewById(R.id.stepView);
|
||||
step.setText(String.format(ctx.getString(R.string.step), 1, 3));
|
||||
|
||||
adapter = new LocalAuthorSpinnerAdapter(ctx, crypto, false);
|
||||
adapter = new LocalAuthorSpinnerAdapter(ctx, false);
|
||||
spinner = (Spinner) view.findViewById(R.id.spinner);
|
||||
spinner.setAdapter(adapter);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
|
||||
@@ -3,6 +3,7 @@ package org.briarproject.android.panic;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BaseActivity;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
@@ -20,4 +21,9 @@ public class ExitActivity extends BaseActivity {
|
||||
LOG.info("Exiting");
|
||||
System.exit(0);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -5,6 +5,7 @@ import android.support.v7.app.ActionBar;
|
||||
import android.view.MenuItem;
|
||||
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
|
||||
public class PanicPreferencesActivity extends BriarActivity {
|
||||
@@ -22,6 +23,11 @@ public class PanicPreferencesActivity extends BriarActivity {
|
||||
setContentView(R.layout.activity_panic_preferences);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
public boolean onOptionsItemSelected(MenuItem item) {
|
||||
if (item.getItemId() == android.R.id.home) {
|
||||
onBackPressed();
|
||||
|
||||
@@ -7,12 +7,17 @@ import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.preference.PreferenceManager;
|
||||
|
||||
import org.briarproject.android.AndroidComponent;
|
||||
import org.briarproject.android.BriarActivity;
|
||||
import org.briarproject.android.util.AndroidUtils;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.util.FileUtils;
|
||||
import org.iilab.IilabEngineeringRSA2048Pin;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import info.guardianproject.GuardianProjectRSA4096;
|
||||
import info.guardianproject.panic.Panic;
|
||||
import info.guardianproject.panic.PanicResponder;
|
||||
@@ -26,6 +31,7 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(PanicResponderActivity.class.getName());
|
||||
@Inject protected DatabaseConfig databaseConfig;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle savedInstanceState) {
|
||||
@@ -95,6 +101,11 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
}
|
||||
|
||||
private void deleteAllData() {
|
||||
new Thread() {
|
||||
@Override
|
||||
|
||||
@@ -16,11 +16,9 @@ import org.briarproject.api.identity.AuthorId;
|
||||
import javax.inject.Inject;
|
||||
|
||||
import im.delight.android.identicons.IdenticonDrawable;
|
||||
import roboguice.RoboGuice;
|
||||
|
||||
public class AuthorView extends FrameLayout {
|
||||
|
||||
@Inject private CryptoComponent crypto;
|
||||
private ImageView avatarView;
|
||||
private TextView nameView;
|
||||
private ImageView statusView;
|
||||
@@ -45,7 +43,6 @@ public class AuthorView extends FrameLayout {
|
||||
}
|
||||
|
||||
private void initViews() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
if (isInEditMode())
|
||||
return;
|
||||
|
||||
@@ -63,7 +60,7 @@ public class AuthorView extends FrameLayout {
|
||||
} else {
|
||||
nameView.setText(name);
|
||||
avatarView.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, id.getBytes()));
|
||||
new IdenticonDrawable(id.getBytes()));
|
||||
}
|
||||
|
||||
switch(status) {
|
||||
|
||||
@@ -3,9 +3,7 @@ package org.briarproject.plugins;
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.plugins.BackoffFactory;
|
||||
@@ -24,10 +22,14 @@ import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class AndroidPluginsModule extends PluginsModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class AndroidPluginsModule {
|
||||
|
||||
@Provides
|
||||
SimplexPluginConfig getSimplexPluginConfig() {
|
||||
SimplexPluginConfig provideSimplexPluginConfig() {
|
||||
return new SimplexPluginConfig() {
|
||||
public Collection<SimplexPluginFactory> getFactories() {
|
||||
return Collections.emptyList();
|
||||
@@ -36,9 +38,9 @@ public class AndroidPluginsModule extends PluginsModule {
|
||||
}
|
||||
|
||||
@Provides
|
||||
DuplexPluginConfig getDuplexPluginConfig(@IoExecutor Executor ioExecutor,
|
||||
AndroidExecutor androidExecutor, Application app,
|
||||
SecureRandom random, BackoffFactory backoffFactory,
|
||||
public DuplexPluginConfig provideDuplexPluginConfig(
|
||||
@IoExecutor Executor ioExecutor, AndroidExecutor androidExecutor,
|
||||
SecureRandom random, BackoffFactory backoffFactory, Application app,
|
||||
LocationUtils locationUtils, EventBus eventBus) {
|
||||
Context appContext = app.getApplicationContext();
|
||||
DuplexPluginFactory bluetooth = new DroidtoothPluginFactory(ioExecutor,
|
||||
@@ -55,4 +57,5 @@ public class AndroidPluginsModule extends PluginsModule {
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -11,7 +11,7 @@ import android.content.IntentFilter;
|
||||
|
||||
import org.briarproject.android.util.AndroidUtils;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.crypto.PseudoRandom;
|
||||
import org.briarproject.api.plugins.Backoff;
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.briarproject.plugins.droidtooth;
|
||||
import android.content.Context;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
import org.briarproject.api.plugins.Backoff;
|
||||
import org.briarproject.api.plugins.BackoffFactory;
|
||||
import org.briarproject.api.plugins.duplex.DuplexPlugin;
|
||||
|
||||
@@ -1,4 +1,4 @@
|
||||
package org.briarproject.android;
|
||||
package org.briarproject.system;
|
||||
|
||||
import android.app.Application;
|
||||
import android.content.Context;
|
||||
@@ -6,19 +6,16 @@ import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.os.Message;
|
||||
|
||||
import org.briarproject.api.android.AndroidExecutor;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
|
||||
import java.util.concurrent.Callable;
|
||||
import java.util.concurrent.Future;
|
||||
import java.util.concurrent.FutureTask;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
class AndroidExecutorImpl implements AndroidExecutor {
|
||||
|
||||
private final Handler handler;
|
||||
|
||||
@Inject
|
||||
AndroidExecutorImpl(Application app) {
|
||||
Context ctx = app.getApplicationContext();
|
||||
handler = new FutureTaskHandler(ctx.getMainLooper());
|
||||
@@ -6,13 +6,13 @@ import android.content.Context;
|
||||
import android.telephony.TelephonyManager;
|
||||
import android.text.TextUtils;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.system.LocationUtils;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static android.content.Context.TELEPHONY_SERVICE;
|
||||
|
||||
class AndroidLocationUtils implements LocationUtils {
|
||||
|
||||
@@ -1,18 +1,29 @@
|
||||
package org.briarproject.system;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import android.app.Application;
|
||||
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.android.api.AndroidExecutor;
|
||||
import org.briarproject.api.system.LocationUtils;
|
||||
import org.briarproject.api.system.SeedProvider;
|
||||
import org.briarproject.api.system.Timer;
|
||||
|
||||
public class AndroidSystemModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
protected void configure() {
|
||||
bind(Clock.class).to(SystemClock.class);
|
||||
bind(Timer.class).to(SystemTimer.class);
|
||||
bind(SeedProvider.class).to(AndroidSeedProvider.class);
|
||||
bind(LocationUtils.class).to(AndroidLocationUtils.class);
|
||||
@Module
|
||||
public class AndroidSystemModule {
|
||||
|
||||
@Provides
|
||||
public SeedProvider provideSeedProvider(Application app) {
|
||||
return new AndroidSeedProvider(app);
|
||||
}
|
||||
|
||||
@Provides
|
||||
public LocationUtils provideLocationUtils(Application app) {
|
||||
return new AndroidLocationUtils(app);
|
||||
}
|
||||
|
||||
@Provides
|
||||
public AndroidExecutor providePlatformExecutor(Application app) {
|
||||
return new AndroidExecutorImpl(app);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,17 +9,17 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compile "javax.inject:javax.inject:1"
|
||||
compile "com.google.inject:guice:3.0:no_aop"
|
||||
compile "com.google.dagger:dagger:2.0.2"
|
||||
compile 'com.google.dagger:dagger-compiler:2.0.2'
|
||||
}
|
||||
|
||||
dependencyVerification {
|
||||
verify = [
|
||||
'com.google.dagger:dagger:84c0282ed8be73a29e0475d639da030b55dee72369e58dd35ae7d4fe6243dcf9',
|
||||
'com.google.dagger:dagger-compiler:b74bc9de063dd4c6400b232231f2ef5056145b8fbecbf5382012007dd1c071b3',
|
||||
'javax.inject:javax.inject:91c77044a50c481636c32d916fd89c9118a72195390452c81065080f957de7ff',
|
||||
'com.google.inject:guice:7c0624d0986ae2bd7a8f1cf4789bcaae5b82a042a7e3d27ba3041ed7b7f2cd3a',
|
||||
'aopalliance:aopalliance:0addec670fedcd3f113c5c8091d783280d23f75e3acb841b61a9cdb079376a08',
|
||||
'org.sonatype.sisu.inject:cglib:42e1dfb26becbf1a633f25b47e39fcc422b85e77e4c0468d9a44f885f5fa0be2',
|
||||
'asm:asm:333ff5369043975b7e031b8b27206937441854738e038c1f47f98d072a20437a',
|
||||
'com.google.dagger:dagger-producers:99ec15e8a0507ba569e7655bc1165ee5e5ca5aa914b3c8f7e2c2458f724edd6b',
|
||||
'com.google.guava:guava:d664fbfc03d2e5ce9cab2a44fb01f1d0bf9dfebeccc1a473b1f9ea31f79f6f99',
|
||||
]
|
||||
}
|
||||
|
||||
|
||||
@@ -8,10 +8,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/** Annotation for injecting the executor for long-running crypto tasks. */
|
||||
@BindingAnnotation
|
||||
@Target({ FIELD, METHOD, PARAMETER })
|
||||
@Qualifier
|
||||
@Target({FIELD, METHOD, PARAMETER})
|
||||
@Retention(RUNTIME)
|
||||
public @interface CryptoExecutor {}
|
||||
|
||||
@@ -8,7 +8,7 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/**
|
||||
* Annotation for injecting the executor for database tasks.
|
||||
@@ -17,7 +17,7 @@ import com.google.inject.BindingAnnotation;
|
||||
* they're submitted, tasks are not executed concurrently, and submitting a
|
||||
* task will never block.
|
||||
*/
|
||||
@BindingAnnotation
|
||||
@Qualifier
|
||||
@Target({ FIELD, METHOD, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface DatabaseExecutor {}
|
||||
|
||||
@@ -8,10 +8,10 @@ import static java.lang.annotation.RetentionPolicy.RUNTIME;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
import com.google.inject.BindingAnnotation;
|
||||
import javax.inject.Qualifier;
|
||||
|
||||
/** Annotation for injecting the executor used by long-lived IO tasks. */
|
||||
@BindingAnnotation
|
||||
@Qualifier
|
||||
@Target({ FIELD, METHOD, PARAMETER })
|
||||
@Retention(RUNTIME)
|
||||
public @interface IoExecutor {}
|
||||
26
briar-core/src/org/briarproject/CoreEagerSingletons.java
Normal file
26
briar-core/src/org/briarproject/CoreEagerSingletons.java
Normal file
@@ -0,0 +1,26 @@
|
||||
package org.briarproject;
|
||||
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.forum.ForumModule;
|
||||
import org.briarproject.lifecycle.LifecycleModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.plugins.PluginsModule;
|
||||
import org.briarproject.properties.PropertiesModule;
|
||||
import org.briarproject.sync.SyncModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
|
||||
public interface CoreEagerSingletons {
|
||||
void inject(ContactModule.EagerSingletons init);
|
||||
void inject(CryptoModule.EagerSingletons init);
|
||||
void inject(DatabaseModule.EagerSingletons init);
|
||||
void inject(ForumModule.EagerSingletons init);
|
||||
void inject(LifecycleModule.EagerSingletons init);
|
||||
void inject(MessagingModule.EagerSingletons init);
|
||||
void inject(PluginsModule.EagerSingletons init);
|
||||
void inject(PropertiesModule.EagerSingletons init);
|
||||
void inject(SyncModule.EagerSingletons init);
|
||||
void inject(TransportModule.EagerSingletons init);
|
||||
|
||||
}
|
||||
45
briar-core/src/org/briarproject/CoreModule.java
Normal file
45
briar-core/src/org/briarproject/CoreModule.java
Normal file
@@ -0,0 +1,45 @@
|
||||
package org.briarproject;
|
||||
|
||||
import org.briarproject.clients.ClientsModule;
|
||||
import org.briarproject.contact.ContactModule;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.event.EventModule;
|
||||
import org.briarproject.forum.ForumModule;
|
||||
import org.briarproject.identity.IdentityModule;
|
||||
import org.briarproject.invitation.InvitationModule;
|
||||
import org.briarproject.lifecycle.LifecycleModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.plugins.PluginsModule;
|
||||
import org.briarproject.properties.PropertiesModule;
|
||||
import org.briarproject.reliability.ReliabilityModule;
|
||||
import org.briarproject.settings.SettingsModule;
|
||||
import org.briarproject.sync.SyncModule;
|
||||
import org.briarproject.system.SystemModule;
|
||||
import org.briarproject.transport.TransportModule;
|
||||
|
||||
import dagger.Module;
|
||||
|
||||
@Module(includes = {DatabaseModule.class,
|
||||
CryptoModule.class, LifecycleModule.class, ReliabilityModule.class,
|
||||
MessagingModule.class, InvitationModule.class, ForumModule.class,
|
||||
IdentityModule.class, EventModule.class, DataModule.class,
|
||||
ContactModule.class, PropertiesModule.class, TransportModule.class,
|
||||
SyncModule.class, SettingsModule.class, ClientsModule.class,
|
||||
SystemModule.class, PluginsModule.class})
|
||||
public class CoreModule {
|
||||
|
||||
public static void initEagerSingletons(CoreEagerSingletons c) {
|
||||
c.inject(new ContactModule.EagerSingletons());
|
||||
c.inject(new CryptoModule.EagerSingletons());
|
||||
c.inject(new DatabaseModule.EagerSingletons());
|
||||
c.inject(new ForumModule.EagerSingletons());
|
||||
c.inject(new LifecycleModule.EagerSingletons());
|
||||
c.inject(new MessagingModule.EagerSingletons());
|
||||
c.inject(new PluginsModule.EagerSingletons());
|
||||
c.inject(new PropertiesModule.EagerSingletons());
|
||||
c.inject(new SyncModule.EagerSingletons());
|
||||
c.inject(new TransportModule.EagerSingletons());
|
||||
}
|
||||
}
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.clients;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
@@ -30,6 +28,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||
|
||||
class ClientHelperImpl implements ClientHelper {
|
||||
|
||||
@@ -1,19 +1,40 @@
|
||||
package org.briarproject.clients;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.clients.MessageQueueManager;
|
||||
import org.briarproject.api.clients.PrivateGroupFactory;
|
||||
import org.briarproject.api.clients.QueueMessageFactory;
|
||||
import org.briarproject.api.data.BdfReaderFactory;
|
||||
import org.briarproject.api.data.BdfWriterFactory;
|
||||
import org.briarproject.api.data.MetadataEncoder;
|
||||
import org.briarproject.api.data.MetadataParser;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.api.sync.MessageFactory;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
import org.briarproject.messaging.MessagingModule;
|
||||
import org.briarproject.sync.SyncModule;
|
||||
|
||||
public class ClientsModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ClientHelper.class).to(ClientHelperImpl.class);
|
||||
bind(MessageQueueManager.class).to(MessageQueueManagerImpl.class);
|
||||
bind(PrivateGroupFactory.class).to(PrivateGroupFactoryImpl.class);
|
||||
bind(QueueMessageFactory.class).to(QueueMessageFactoryImpl.class);
|
||||
@Module
|
||||
public class ClientsModule {
|
||||
|
||||
@Provides
|
||||
ClientHelper provideClientHelper(DatabaseComponent db,
|
||||
MessageFactory messageFactory, BdfReaderFactory bdfReaderFactory,
|
||||
BdfWriterFactory bdfWriterFactory, MetadataParser metadataParser,
|
||||
MetadataEncoder metadataEncoder) {
|
||||
return new ClientHelperImpl(db, messageFactory, bdfReaderFactory,
|
||||
bdfWriterFactory, metadataParser, metadataEncoder);
|
||||
}
|
||||
|
||||
@Provides
|
||||
PrivateGroupFactory providePrivateGroupFactory(GroupFactory groupFactory,
|
||||
BdfWriterFactory bdfWriterFactory) {
|
||||
return new PrivateGroupFactoryImpl(groupFactory, bdfWriterFactory);
|
||||
}
|
||||
|
||||
bind(QueueMessageFactory.class).to(QueueMessageFactoryImpl.class);
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.contact;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.contact.Contact;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
@@ -21,6 +19,8 @@ import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
class ContactManagerImpl implements ContactManager, RemoveIdentityHook {
|
||||
|
||||
private final DatabaseComponent db;
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
package org.briarproject.contact;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
public class ContactModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {}
|
||||
@Module
|
||||
public class ContactModule {
|
||||
|
||||
@Provides @Singleton
|
||||
ContactManager getContactManager(IdentityManager identityManager,
|
||||
public static class EagerSingletons {
|
||||
@Inject ContactManager contactManager;
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ContactManager getContactManager(LifecycleManager lifecycleManager,
|
||||
IdentityManager identityManager,
|
||||
ContactManagerImpl contactManager) {
|
||||
identityManager.registerRemoveIdentityHook(contactManager);
|
||||
return contactManager;
|
||||
|
||||
@@ -1,14 +1,12 @@
|
||||
package org.briarproject.crypto;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.crypto.CryptoExecutor;
|
||||
import org.briarproject.api.crypto.PasswordStrengthEstimator;
|
||||
import org.briarproject.api.crypto.StreamDecrypterFactory;
|
||||
import org.briarproject.api.crypto.StreamEncrypterFactory;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.system.SeedProvider;
|
||||
|
||||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.BlockingQueue;
|
||||
@@ -18,13 +16,26 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Provider;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class CryptoModule extends AbstractModule {
|
||||
@Module
|
||||
public class CryptoModule {
|
||||
|
||||
/** The maximum number of executor threads. */
|
||||
public static class EagerSingletons {
|
||||
@Inject
|
||||
@CryptoExecutor Executor cryptoExecutor;
|
||||
}
|
||||
|
||||
/**
|
||||
* The maximum number of executor threads.
|
||||
*/
|
||||
private static final int MAX_EXECUTOR_THREADS =
|
||||
Runtime.getRuntime().availableProcessors();
|
||||
|
||||
@@ -41,19 +52,37 @@ public class CryptoModule extends AbstractModule {
|
||||
60, SECONDS, queue, policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AuthenticatedCipher.class).to(
|
||||
XSalsa20Poly1305AuthenticatedCipher.class);
|
||||
bind(CryptoComponent.class).to(
|
||||
CryptoComponentImpl.class).in(Singleton.class);
|
||||
bind(PasswordStrengthEstimator.class).to(
|
||||
PasswordStrengthEstimatorImpl.class);
|
||||
bind(StreamDecrypterFactory.class).to(StreamDecrypterFactoryImpl.class);
|
||||
bind(StreamEncrypterFactory.class).to(StreamEncrypterFactoryImpl.class);
|
||||
@Provides
|
||||
AuthenticatedCipher provideAuthenticatedCipher() {
|
||||
return new XSalsa20Poly1305AuthenticatedCipher();
|
||||
}
|
||||
|
||||
@Provides @Singleton @CryptoExecutor
|
||||
@Provides
|
||||
@Singleton
|
||||
CryptoComponent provideCryptoComponent(SeedProvider seedProvider) {
|
||||
return new CryptoComponentImpl(seedProvider);
|
||||
}
|
||||
|
||||
@Provides
|
||||
PasswordStrengthEstimator providePasswordStrengthEstimator() {
|
||||
return new PasswordStrengthEstimatorImpl();
|
||||
}
|
||||
|
||||
@Provides
|
||||
StreamDecrypterFactory provideStreamDecrypterFactory(
|
||||
Provider<AuthenticatedCipher> cipherProvider) {
|
||||
return new StreamDecrypterFactoryImpl(cipherProvider);
|
||||
}
|
||||
|
||||
@Provides
|
||||
StreamEncrypterFactory provideStreamEncrypterFactory(CryptoComponent crypto,
|
||||
Provider<AuthenticatedCipher> cipherProvider) {
|
||||
return new StreamEncrypterFactoryImpl(crypto, cipherProvider);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@CryptoExecutor
|
||||
Executor getCryptoExecutor(LifecycleManager lifecycleManager) {
|
||||
lifecycleManager.registerForShutdown(cryptoExecutor);
|
||||
return cryptoExecutor;
|
||||
@@ -63,4 +92,5 @@ public class CryptoModule extends AbstractModule {
|
||||
SecureRandom getSecureRandom(CryptoComponent crypto) {
|
||||
return crypto.getSecureRandom();
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,19 +1,35 @@
|
||||
package org.briarproject.data;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import org.briarproject.api.data.BdfReaderFactory;
|
||||
import org.briarproject.api.data.BdfWriterFactory;
|
||||
import org.briarproject.api.data.MetadataEncoder;
|
||||
import org.briarproject.api.data.MetadataParser;
|
||||
|
||||
public class DataModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(BdfReaderFactory.class).to(BdfReaderFactoryImpl.class);
|
||||
bind(BdfWriterFactory.class).to(BdfWriterFactoryImpl.class);
|
||||
bind(MetadataParser.class).to(MetadataParserImpl.class);
|
||||
bind(MetadataEncoder.class).to(MetadataEncoderImpl.class);
|
||||
@Module
|
||||
public class DataModule {
|
||||
|
||||
@Provides
|
||||
BdfReaderFactory provideBdfReaderFactory() {
|
||||
return new BdfReaderFactoryImpl();
|
||||
}
|
||||
|
||||
@Provides
|
||||
BdfWriterFactory provideBdfWriterFactory() {
|
||||
return new BdfWriterFactoryImpl();
|
||||
}
|
||||
|
||||
@Provides
|
||||
MetadataParser provideMetaDataParser(BdfReaderFactory bdfReaderFactory) {
|
||||
return new MetadataParserImpl(bdfReaderFactory);
|
||||
}
|
||||
|
||||
@Provides
|
||||
MetadataEncoder provideMetaDataEncoder(BdfWriterFactory bdfWriterFactory) {
|
||||
return new MetadataEncoderImpl(bdfWriterFactory);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.data;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.Bytes;
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
@@ -16,6 +14,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.data.BdfDictionary.NULL_VALUE;
|
||||
import static org.briarproject.api.db.Metadata.REMOVE;
|
||||
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.data;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.data.BdfDictionary;
|
||||
import org.briarproject.api.data.BdfReader;
|
||||
@@ -13,6 +11,8 @@ import java.io.ByteArrayInputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.data.BdfDictionary.NULL_VALUE;
|
||||
import static org.briarproject.api.db.Metadata.REMOVE;
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.db;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DatabaseConfig;
|
||||
import org.briarproject.api.db.DatabaseExecutor;
|
||||
@@ -20,11 +17,21 @@ import java.util.concurrent.LinkedBlockingQueue;
|
||||
import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static java.util.concurrent.TimeUnit.SECONDS;
|
||||
|
||||
public class DatabaseModule extends AbstractModule {
|
||||
@Module
|
||||
public class DatabaseModule {
|
||||
|
||||
public static class EagerSingletons {
|
||||
@Inject
|
||||
@DatabaseExecutor ExecutorService executorService;
|
||||
}
|
||||
|
||||
private final ExecutorService databaseExecutor;
|
||||
|
||||
@@ -39,30 +46,28 @@ public class DatabaseModule extends AbstractModule {
|
||||
policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {}
|
||||
|
||||
@Provides @Singleton
|
||||
Database<Connection> getDatabase(DatabaseConfig config,
|
||||
@Provides
|
||||
@Singleton
|
||||
Database<Connection> provideDatabase(DatabaseConfig config,
|
||||
SecureRandom random, Clock clock) {
|
||||
return new H2Database(config, random, clock);
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
DatabaseComponent getDatabaseComponent(Database<Connection> db,
|
||||
DatabaseComponent provideDatabaseComponent(Database<Connection> db,
|
||||
EventBus eventBus, ShutdownManager shutdown) {
|
||||
return new DatabaseComponentImpl<Connection>(db, Connection.class,
|
||||
eventBus, shutdown);
|
||||
}
|
||||
|
||||
@Provides @Singleton @DatabaseExecutor
|
||||
ExecutorService getDatabaseExecutor(LifecycleManager lifecycleManager) {
|
||||
ExecutorService provideDatabaseExecutorService(LifecycleManager lifecycleManager) {
|
||||
lifecycleManager.registerForShutdown(databaseExecutor);
|
||||
return databaseExecutor;
|
||||
}
|
||||
|
||||
@Provides @Singleton @DatabaseExecutor
|
||||
Executor getDatabaseExecutor(@DatabaseExecutor ExecutorService dbExecutor) {
|
||||
Executor provideDatabaseExecutor(@DatabaseExecutor ExecutorService dbExecutor) {
|
||||
return dbExecutor;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,13 +2,17 @@ package org.briarproject.event;
|
||||
|
||||
import org.briarproject.api.event.EventBus;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Singleton;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
public class EventModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(EventBus.class).to(EventBusImpl.class).in(Singleton.class);
|
||||
@Module
|
||||
public class EventModule {
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
EventBus provideEventBus() {
|
||||
return new EventBusImpl();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.forum;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.contact.Contact;
|
||||
@@ -32,6 +30,8 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.identity.Author.Status.ANONYMOUS;
|
||||
import static org.briarproject.api.identity.Author.Status.UNKNOWN;
|
||||
import static org.briarproject.api.identity.Author.Status.VERIFIED;
|
||||
|
||||
@@ -1,12 +1,12 @@
|
||||
package org.briarproject.forum;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.data.BdfReaderFactory;
|
||||
import org.briarproject.api.data.MetadataEncoder;
|
||||
import org.briarproject.api.data.MetadataParser;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.forum.ForumManager;
|
||||
import org.briarproject.api.forum.ForumPostFactory;
|
||||
import org.briarproject.api.forum.ForumSharingManager;
|
||||
@@ -14,18 +14,40 @@ import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.sync.ValidationManager;
|
||||
import org.briarproject.api.system.Clock;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
public class ForumModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ForumManager.class).to(ForumManagerImpl.class).in(Singleton.class);
|
||||
bind(ForumPostFactory.class).to(ForumPostFactoryImpl.class);
|
||||
@Module
|
||||
public class ForumModule {
|
||||
|
||||
public static class EagerSingletons {
|
||||
@Inject
|
||||
ForumListValidator forumListValidator;
|
||||
@Inject
|
||||
ForumPostValidator forumPostValidator;
|
||||
@Inject
|
||||
ForumSharingManager forumSharingManager;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
ForumPostValidator getForumPostValidator(
|
||||
@Provides
|
||||
@Singleton
|
||||
ForumManager provideForumManager(DatabaseComponent db,
|
||||
ClientHelper clientHelper) {
|
||||
return new ForumManagerImpl(db, clientHelper);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ForumPostFactory provideForumPostFactory(CryptoComponent crypto,
|
||||
ClientHelper clientHelper) {
|
||||
return new ForumPostFactoryImpl(crypto, clientHelper);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ForumPostValidator provideForumPostValidator(
|
||||
ValidationManager validationManager, CryptoComponent crypto,
|
||||
AuthorFactory authorFactory, ClientHelper clientHelper,
|
||||
MetadataEncoder metadataEncoder, Clock clock) {
|
||||
@@ -36,8 +58,9 @@ public class ForumModule extends AbstractModule {
|
||||
return validator;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
ForumListValidator getForumListValidator(
|
||||
@Provides
|
||||
@Singleton
|
||||
ForumListValidator provideForumListValidator(
|
||||
ValidationManager validationManager, ClientHelper clientHelper,
|
||||
MetadataEncoder metadataEncoder, Clock clock) {
|
||||
ForumListValidator validator = new ForumListValidator(clientHelper,
|
||||
@@ -47,8 +70,10 @@ public class ForumModule extends AbstractModule {
|
||||
return validator;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
ForumSharingManager getForumSharingManager(ContactManager contactManager,
|
||||
@Provides
|
||||
@Singleton
|
||||
ForumSharingManager provideForumSharingManager(
|
||||
ContactManager contactManager,
|
||||
ValidationManager validationManager,
|
||||
ForumSharingManagerImpl forumSharingManager) {
|
||||
contactManager.registerAddContactHook(forumSharingManager);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.forum;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.clients.PrivateGroupFactory;
|
||||
@@ -39,6 +37,8 @@ import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.forum.ForumConstants.FORUM_SALT_LENGTH;
|
||||
import static org.briarproject.api.forum.ForumConstants.MAX_FORUM_NAME_LENGTH;
|
||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.identity;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.db.Transaction;
|
||||
@@ -13,8 +11,9 @@ import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
|
||||
class IdentityManagerImpl implements IdentityManager {
|
||||
import javax.inject.Inject;
|
||||
|
||||
class IdentityManagerImpl implements IdentityManager {
|
||||
private final DatabaseComponent db;
|
||||
private final List<AddIdentityHook> addHooks;
|
||||
private final List<RemoveIdentityHook> removeHooks;
|
||||
|
||||
@@ -1,23 +1,39 @@
|
||||
package org.briarproject.identity;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.data.BdfWriterFactory;
|
||||
import org.briarproject.api.data.ObjectReader;
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.identity.Author;
|
||||
import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.crypto.CryptoModule;
|
||||
import org.briarproject.data.DataModule;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
|
||||
public class IdentityModule extends AbstractModule {
|
||||
import javax.inject.Singleton;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(AuthorFactory.class).to(AuthorFactoryImpl.class);
|
||||
bind(IdentityManager.class).to(IdentityManagerImpl.class);
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class IdentityModule {
|
||||
|
||||
@Provides
|
||||
AuthorFactory provideAuthorFactory(CryptoComponent crypto,
|
||||
BdfWriterFactory bdfWriterFactory, Clock clock) {
|
||||
return new AuthorFactoryImpl(crypto, bdfWriterFactory, clock);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ObjectReader<Author> getAuthorReader(AuthorFactory authorFactory) {
|
||||
IdentityManager provideIdendityModule(DatabaseComponent db) {
|
||||
return new IdentityManagerImpl(db);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ObjectReader<Author> provideAuthorReader(AuthorFactory authorFactory) {
|
||||
return new AuthorReader(authorFactory);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -2,14 +2,40 @@ package org.briarproject.invitation;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
import org.briarproject.api.data.BdfReaderFactory;
|
||||
import org.briarproject.api.data.BdfWriterFactory;
|
||||
import org.briarproject.api.identity.AuthorFactory;
|
||||
import org.briarproject.api.identity.IdentityManager;
|
||||
import org.briarproject.api.invitation.InvitationTaskFactory;
|
||||
import org.briarproject.api.plugins.ConnectionManager;
|
||||
import org.briarproject.api.plugins.PluginManager;
|
||||
import org.briarproject.api.sync.GroupFactory;
|
||||
import org.briarproject.api.system.Clock;
|
||||
import org.briarproject.api.transport.KeyManager;
|
||||
import org.briarproject.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.api.transport.StreamWriterFactory;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
public class InvitationModule extends AbstractModule {
|
||||
@Module
|
||||
public class InvitationModule {
|
||||
|
||||
protected void configure() {
|
||||
bind(InvitationTaskFactory.class).to(
|
||||
InvitationTaskFactoryImpl.class).in(Singleton.class);
|
||||
@Provides
|
||||
@Singleton
|
||||
InvitationTaskFactory provideInvitationTaskFactory(CryptoComponent crypto,
|
||||
BdfReaderFactory bdfReaderFactory,
|
||||
BdfWriterFactory bdfWriterFactory,
|
||||
StreamReaderFactory streamReaderFactory,
|
||||
StreamWriterFactory streamWriterFactory,
|
||||
AuthorFactory authorFactory, ConnectionManager connectionManager,
|
||||
IdentityManager identityManager, ContactManager contactManager,
|
||||
Clock clock, PluginManager pluginManager) {
|
||||
return new InvitationTaskFactoryImpl(crypto, bdfReaderFactory,
|
||||
bdfWriterFactory, streamReaderFactory, streamWriterFactory,
|
||||
authorFactory, connectionManager, identityManager,
|
||||
contactManager, clock, pluginManager);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,16 +9,26 @@ import java.util.concurrent.RejectedExecutionHandler;
|
||||
import java.util.concurrent.SynchronousQueue;
|
||||
import java.util.concurrent.ThreadPoolExecutor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.lifecycle.ShutdownManager;
|
||||
import org.briarproject.api.system.Clock;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
public class LifecycleModule extends AbstractModule {
|
||||
@Module
|
||||
public class LifecycleModule {
|
||||
|
||||
public static class EagerSingletons {
|
||||
@Inject
|
||||
@IoExecutor Executor executor;
|
||||
}
|
||||
|
||||
private final ExecutorService ioExecutor;
|
||||
|
||||
@@ -33,17 +43,25 @@ public class LifecycleModule extends AbstractModule {
|
||||
60, SECONDS, queue, policy);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(LifecycleManager.class).to(
|
||||
LifecycleManagerImpl.class).in(Singleton.class);
|
||||
bind(ShutdownManager.class).to(
|
||||
ShutdownManagerImpl.class).in(Singleton.class);
|
||||
@Provides
|
||||
@Singleton
|
||||
ShutdownManager provideShutdownManager() {
|
||||
return new ShutdownManagerImpl();
|
||||
}
|
||||
|
||||
@Provides @Singleton @IoExecutor
|
||||
@Provides
|
||||
@Singleton
|
||||
LifecycleManager provideLifeCycleManager(Clock clock, DatabaseComponent db,
|
||||
EventBus eventBus) {
|
||||
return new LifecycleManagerImpl(clock, db, eventBus);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
@IoExecutor
|
||||
Executor getIoExecutor(LifecycleManager lifecycleManager) {
|
||||
lifecycleManager.registerForShutdown(ioExecutor);
|
||||
return ioExecutor;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.messaging;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.clients.PrivateGroupFactory;
|
||||
@@ -28,6 +26,8 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
class MessagingManagerImpl implements MessagingManager, AddContactHook,
|
||||
RemoveContactHook {
|
||||
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.messaging;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.data.MetadataEncoder;
|
||||
@@ -11,18 +8,30 @@ import org.briarproject.api.messaging.PrivateMessageFactory;
|
||||
import org.briarproject.api.sync.ValidationManager;
|
||||
import org.briarproject.api.system.Clock;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static org.briarproject.messaging.MessagingManagerImpl.CLIENT_ID;
|
||||
|
||||
public class MessagingModule extends AbstractModule {
|
||||
@Module
|
||||
public class MessagingModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(PrivateMessageFactory.class).to(PrivateMessageFactoryImpl.class);
|
||||
public static class EagerSingletons {
|
||||
@Inject MessagingManager messagingManager;
|
||||
@Inject PrivateMessageValidator privateMessageValidator;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
@Provides
|
||||
PrivateMessageFactory providePrivateMessageFactory(
|
||||
ClientHelper clientHelper) {
|
||||
return new PrivateMessageFactoryImpl(clientHelper);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
PrivateMessageValidator getValidator(ValidationManager validationManager,
|
||||
ClientHelper clientHelper, MetadataEncoder metadataEncoder,
|
||||
Clock clock) {
|
||||
@@ -32,7 +41,8 @@ public class MessagingModule extends AbstractModule {
|
||||
return validator;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
@Provides
|
||||
@Singleton
|
||||
MessagingManager getMessagingManager(ContactManager contactManager,
|
||||
MessagingManagerImpl messagingManager) {
|
||||
contactManager.registerAddContactHook(messagingManager);
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.plugins;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.contact.ContactId;
|
||||
import org.briarproject.api.event.ContactConnectedEvent;
|
||||
@@ -19,6 +17,8 @@ import java.util.concurrent.locks.Lock;
|
||||
import java.util.concurrent.locks.ReentrantLock;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
class ConnectionRegistryImpl implements ConnectionRegistry {
|
||||
|
||||
@@ -1,31 +1,73 @@
|
||||
package org.briarproject.plugins;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import org.briarproject.api.event.EventBus;
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.lifecycle.LifecycleManager;
|
||||
import org.briarproject.api.plugins.BackoffFactory;
|
||||
import org.briarproject.api.plugins.ConnectionManager;
|
||||
import org.briarproject.api.plugins.ConnectionRegistry;
|
||||
import org.briarproject.api.plugins.PluginManager;
|
||||
import org.briarproject.api.sync.SyncSessionFactory;
|
||||
import org.briarproject.api.system.Timer;
|
||||
import org.briarproject.api.transport.KeyManager;
|
||||
import org.briarproject.api.transport.StreamReaderFactory;
|
||||
import org.briarproject.api.transport.StreamWriterFactory;
|
||||
|
||||
import javax.inject.Singleton;
|
||||
import java.security.SecureRandom;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class PluginsModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(BackoffFactory.class).to(BackoffFactoryImpl.class);
|
||||
bind(Poller.class).to(PollerImpl.class);
|
||||
bind(ConnectionManager.class).to(ConnectionManagerImpl.class);
|
||||
bind(ConnectionRegistry.class).to(
|
||||
ConnectionRegistryImpl.class).in(Singleton.class);
|
||||
|
||||
@Module
|
||||
public class PluginsModule {
|
||||
|
||||
public static class EagerSingletons {
|
||||
@Inject
|
||||
PluginManager pluginManager;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
@Provides
|
||||
BackoffFactory provideBackoffFactory() {
|
||||
return new BackoffFactoryImpl();
|
||||
}
|
||||
|
||||
@Provides
|
||||
Poller providePoller(@IoExecutor Executor ioExecutor,
|
||||
ConnectionRegistry connectionRegistry, SecureRandom random,
|
||||
Timer timer) {
|
||||
return new PollerImpl(ioExecutor, connectionRegistry, random, timer);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ConnectionManager provideConnectionManager(
|
||||
@IoExecutor Executor ioExecutor,
|
||||
KeyManager keyManager, StreamReaderFactory streamReaderFactory,
|
||||
StreamWriterFactory streamWriterFactory,
|
||||
SyncSessionFactory syncSessionFactory,
|
||||
ConnectionRegistry connectionRegistry) {
|
||||
return new ConnectionManagerImpl(ioExecutor, keyManager,
|
||||
streamReaderFactory, streamWriterFactory, syncSessionFactory,
|
||||
connectionRegistry);
|
||||
}
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
ConnectionRegistry provideConnectionRegistry(EventBus eventBus) {
|
||||
return new ConnectionRegistryImpl(eventBus);
|
||||
}
|
||||
|
||||
|
||||
@Provides
|
||||
@Singleton
|
||||
PluginManager getPluginManager(LifecycleManager lifecycleManager,
|
||||
PluginManagerImpl pluginManager) {
|
||||
lifecycleManager.register(pluginManager);
|
||||
return pluginManager;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,8 +1,5 @@
|
||||
package org.briarproject.properties;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import com.google.inject.Provides;
|
||||
|
||||
import org.briarproject.api.clients.ClientHelper;
|
||||
import org.briarproject.api.contact.ContactManager;
|
||||
import org.briarproject.api.data.MetadataEncoder;
|
||||
@@ -10,16 +7,24 @@ import org.briarproject.api.properties.TransportPropertyManager;
|
||||
import org.briarproject.api.sync.ValidationManager;
|
||||
import org.briarproject.api.system.Clock;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
import static org.briarproject.properties.TransportPropertyManagerImpl.CLIENT_ID;
|
||||
|
||||
public class PropertiesModule extends AbstractModule {
|
||||
@Module
|
||||
public class PropertiesModule {
|
||||
|
||||
@Override
|
||||
protected void configure() {}
|
||||
public static class EagerSingletons {
|
||||
@Inject TransportPropertyValidator transportPropertyValidator;
|
||||
@Inject TransportPropertyManager transportPropertyManager;
|
||||
}
|
||||
|
||||
@Provides @Singleton
|
||||
@Provides
|
||||
@Singleton
|
||||
TransportPropertyValidator getValidator(ValidationManager validationManager,
|
||||
ClientHelper clientHelper, MetadataEncoder metadataEncoder,
|
||||
Clock clock) {
|
||||
|
||||
@@ -1,7 +1,5 @@
|
||||
package org.briarproject.properties;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.DeviceId;
|
||||
import org.briarproject.api.FormatException;
|
||||
import org.briarproject.api.TransportId;
|
||||
@@ -33,6 +31,8 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
class TransportPropertyManagerImpl implements TransportPropertyManager,
|
||||
AddContactHook, RemoveContactHook {
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ import static org.briarproject.api.TransportId.MAX_TRANSPORT_ID_LENGTH;
|
||||
import static org.briarproject.api.properties.TransportPropertyConstants.MAX_PROPERTIES_PER_TRANSPORT;
|
||||
import static org.briarproject.api.properties.TransportPropertyConstants.MAX_PROPERTY_LENGTH;
|
||||
|
||||
class TransportPropertyValidator extends BdfMessageValidator {
|
||||
public class TransportPropertyValidator extends BdfMessageValidator {
|
||||
|
||||
TransportPropertyValidator(ClientHelper clientHelper,
|
||||
MetadataEncoder metadataEncoder, Clock clock) {
|
||||
|
||||
@@ -1,14 +1,28 @@
|
||||
package org.briarproject.reliability;
|
||||
|
||||
import org.briarproject.api.lifecycle.IoExecutor;
|
||||
import org.briarproject.api.reliability.ReliabilityLayerFactory;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
import java.util.concurrent.Executor;
|
||||
|
||||
public class ReliabilityModule extends AbstractModule {
|
||||
import javax.inject.Named;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(ReliabilityLayerFactory.class).to(
|
||||
ReliabilityLayerFactoryImpl.class);
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Module
|
||||
public class ReliabilityModule {
|
||||
|
||||
@Provides
|
||||
ReliabilityLayerFactory provideReliabilityFactoryByExector(@IoExecutor
|
||||
Executor ioExecutor) {
|
||||
return new ReliabilityLayerFactoryImpl(ioExecutor);
|
||||
}
|
||||
|
||||
@Provides
|
||||
ReliabilityLayerFactory provideReliabilityFactory(
|
||||
ReliabilityLayerFactoryImpl reliabilityLayerFactory) {
|
||||
return reliabilityLayerFactory;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.settings;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.db.DbException;
|
||||
@@ -8,6 +7,8 @@ import org.briarproject.api.db.Transaction;
|
||||
import org.briarproject.api.settings.Settings;
|
||||
import org.briarproject.api.settings.SettingsManager;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
class SettingsManagerImpl implements SettingsManager {
|
||||
|
||||
private final DatabaseComponent db;
|
||||
|
||||
@@ -1,13 +1,18 @@
|
||||
package org.briarproject.settings;
|
||||
|
||||
import com.google.inject.AbstractModule;
|
||||
|
||||
import org.briarproject.api.db.DatabaseComponent;
|
||||
import org.briarproject.api.settings.SettingsManager;
|
||||
import org.briarproject.db.DatabaseModule;
|
||||
|
||||
public class SettingsModule extends AbstractModule {
|
||||
import dagger.Module;
|
||||
import dagger.Provides;
|
||||
|
||||
@Override
|
||||
protected void configure() {
|
||||
bind(SettingsManager.class).to(SettingsManagerImpl.class);
|
||||
@Module
|
||||
public class SettingsModule {
|
||||
|
||||
@Provides
|
||||
SettingsManager provideSettingsManager(DatabaseComponent db) {
|
||||
return new SettingsManagerImpl(db);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.briarproject.sync;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
|
||||
import org.briarproject.api.UniqueId;
|
||||
import org.briarproject.api.crypto.CryptoComponent;
|
||||
@@ -10,6 +9,8 @@ import org.briarproject.api.sync.MessageFactory;
|
||||
import org.briarproject.api.sync.MessageId;
|
||||
import org.briarproject.util.ByteUtils;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
import static org.briarproject.api.sync.SyncConstants.MAX_MESSAGE_BODY_LENGTH;
|
||||
import static org.briarproject.api.sync.SyncConstants.MESSAGE_HEADER_LENGTH;
|
||||
|
||||
|
||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user