This commit is contained in:
Ernir Erlingsson
2016-05-06 11:01:59 +02:00
parent f855c9ea28
commit 64d1e25ad7
25 changed files with 132 additions and 1615 deletions

View File

@@ -53,8 +53,6 @@ public interface ActivityComponent {
void inject(CreateIdentityActivity activity);
void inject(TestingActivity activity);
void inject(AvailableForumsActivity activity);
void inject(WriteForumPostActivity activity);

View File

@@ -2,8 +2,10 @@ package org.briarproject.android;
import org.briarproject.CoreEagerSingletons;
import org.briarproject.CoreModule;
import org.briarproject.android.api.AndroidExecutor;
import org.briarproject.android.api.AndroidNotificationManager;
import org.briarproject.android.api.ReferenceManager;
import org.briarproject.android.util.BriarReportSender;
import org.briarproject.api.contact.ContactExchangeTask;
import org.briarproject.api.contact.ContactManager;
import org.briarproject.api.crypto.CryptoComponent;
@@ -22,6 +24,7 @@ import org.briarproject.api.invitation.InvitationTaskFactory;
import org.briarproject.api.keyagreement.KeyAgreementTaskFactory;
import org.briarproject.api.keyagreement.PayloadEncoder;
import org.briarproject.api.keyagreement.PayloadParser;
import org.briarproject.api.lifecycle.IoExecutor;
import org.briarproject.api.lifecycle.LifecycleManager;
import org.briarproject.api.messaging.MessagingManager;
import org.briarproject.api.messaging.PrivateMessageFactory;
@@ -103,12 +106,21 @@ public interface AndroidComponent extends CoreEagerSingletons {
IntroductionManager introductionManager();
AndroidExecutor androidExecutor();
void inject(BriarService activity);
@IoExecutor
Executor ioExecutor();
void inject(ContactChooserFragment fragment);
void inject(IntroductionMessageFragment fragment);
void inject(DevReportActivity devReportActivity);
void inject(BriarService activity);
// Eager singleton load
void inject(AppModule.EagerSingletons init);

View File

@@ -1,56 +1,10 @@
package org.briarproject.android;
import android.app.Application;
import android.content.Context;
/**
* This exists so that the Application object will not necessarily be cast
* directly to the Briar application object.
*/
public interface BriarApplication {
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import org.briarproject.CoreModule;
import org.briarproject.R;
import org.briarproject.android.util.BriarReportPrimer;
import org.briarproject.android.util.BriarReportSenderFactory;
import java.util.logging.Logger;
@ReportsCrashes(
reportPrimerClass = BriarReportPrimer.class,
logcatArguments = {"-d", "-v", "time", "*:I"},
reportSenderFactoryClasses = {BriarReportSenderFactory.class},
mode = ReportingInteractionMode.DIALOG,
reportDialogClass = DevReportActivity.class,
resDialogOkToast = R.string.dev_report_saved,
deleteOldUnsentReportsOnApplicationStart = false
)
public class BriarApplication extends Application {
private static final Logger LOG =
Logger.getLogger(BriarApplication.class.getName());
private AndroidComponent applicationComponent;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ACRA.init(this);
}
@Override
public void onCreate() {
super.onCreate();
LOG.info("Created");
applicationComponent = DaggerAndroidComponent.builder()
.appModule(new AppModule(this))
.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;
}
AndroidComponent getApplicationComponent();
}

View File

@@ -0,0 +1,56 @@
package org.briarproject.android;
import android.app.Application;
import android.content.Context;
import org.acra.ACRA;
import org.acra.ReportingInteractionMode;
import org.acra.annotation.ReportsCrashes;
import org.briarproject.CoreModule;
import org.briarproject.R;
import org.briarproject.android.util.BriarReportPrimer;
import org.briarproject.android.util.BriarReportSenderFactory;
import java.util.logging.Logger;
@ReportsCrashes(
reportPrimerClass = BriarReportPrimer.class,
logcatArguments = {"-d", "-v", "time", "*:I"},
reportSenderFactoryClasses = {BriarReportSenderFactory.class},
mode = ReportingInteractionMode.DIALOG,
reportDialogClass = DevReportActivity.class,
resDialogOkToast = R.string.dev_report_saved,
deleteOldUnsentReportsOnApplicationStart = false
)
public class BriarApplicationImp extends Application implements BriarApplication {
private static final Logger LOG =
Logger.getLogger(BriarApplicationImp.class.getName());
private AndroidComponent applicationComponent;
@Override
protected void attachBaseContext(Context base) {
super.attachBaseContext(base);
ACRA.init(this);
}
@Override
public void onCreate() {
super.onCreate();
LOG.info("Created");
applicationComponent = DaggerAndroidComponent.builder()
.appModule(new AppModule(this))
.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;
}
}

View File

@@ -89,6 +89,7 @@ public class DevReportActivity extends BaseCrashReportDialog
((BriarApplication) getApplication()).getApplicationComponent()
.inject(this);
sharedPreferencesFactory =
new SharedPreferencesFactory(getApplicationContext(),
getConfig());

View File

@@ -9,6 +9,7 @@ import android.os.StrictMode.VmPolicy;
import android.support.v7.preference.PreferenceManager;
import org.briarproject.R;
import org.briarproject.android.api.AndroidExecutor;
import org.briarproject.android.controller.ConfigController;
import org.briarproject.android.util.AndroidUtils;
@@ -29,6 +30,8 @@ public class SplashScreenActivity extends BaseActivity {
@Inject
ConfigController configController;
@Inject
protected AndroidExecutor androidExecutor;
public SplashScreenActivity() {
Logger.getLogger("").setLevel(DEFAULT_LOG_LEVEL);

View File

@@ -12,16 +12,12 @@ 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.fragment.BaseFragment;
import org.briarproject.android.keyagreement.KeyAgreementActivity;
import org.briarproject.android.util.BriarRecyclerView;
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.db.DbException;
import org.briarproject.api.db.NoSuchContactException;
import org.briarproject.api.event.ContactAddedEvent;

View File

@@ -84,23 +84,15 @@ public class SetupControllerImp implements SetupController {
@Override
public void createIdentity(final String nickname, final String password,
final ResultHandler<Long> resultHandler) {
LOG.info("createIdentity called");
cryptoExecutor.execute(new Runnable() {
public void run() {
LOG.info("createIdentity running");
SecretKey key = crypto.generateSecretKey();
LOG.info("createIdentity 1");
databaseConfig.setEncryptionKey(key);
LOG.info("createIdentity 2");
String hex = encryptDatabaseKey(key, password);
LOG.info("createIdentity 3");
storeEncryptedDatabaseKey(hex);
LOG.info("createIdentity 4");
final LocalAuthor localAuthor = createLocalAuthor(nickname);
LOG.info("createIdentity 5");
long handle = referenceManager.putReference(localAuthor,
LocalAuthor.class);
LOG.info("createIdentity 6");
resultHandler.onResult(handle);
}
});

View File

@@ -51,16 +51,6 @@ public class ForumListFragment extends BaseEventFragment implements
private static final Logger LOG =
Logger.getLogger(ForumListFragment.class.getName());
/*
public static ForumListFragment newInstance() {
Bundle args = new Bundle();
ForumListFragment fragment = new ForumListFragment();
fragment.setArguments(args);
return fragment;
}
*/
private BriarRecyclerView list;
private ForumListAdapter adapter;
@@ -107,11 +97,6 @@ public class ForumListFragment extends BaseEventFragment implements
return TAG;
}
// @Override
// public void injectActivity(ActivityComponent component) {
// component.inject(this);
// }
@Override
public void onResume() {
super.onResume();

View File

@@ -4,9 +4,6 @@ import android.content.Context;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import org.briarproject.android.AndroidComponent;
import org.briarproject.android.BriarApplication;
public abstract class BaseFragment extends Fragment {
public abstract String getUniqueTag();

View File

@@ -9,6 +9,7 @@ import android.support.v7.preference.PreferenceManager;
import org.briarproject.android.ActivityComponent;
import org.briarproject.android.BriarActivity;
import org.briarproject.android.api.AndroidExecutor;
import org.briarproject.android.controller.ConfigController;
import org.briarproject.android.util.AndroidUtils;
import org.iilab.IilabEngineeringRSA2048Pin;
@@ -22,6 +23,7 @@ import info.guardianproject.panic.Panic;
import info.guardianproject.panic.PanicResponder;
import info.guardianproject.trustedintents.TrustedIntents;
import static android.content.Intent.ACTION_DELETE;
import static org.briarproject.android.panic.PanicPreferencesFragment.KEY_LOCK;
import static org.briarproject.android.panic.PanicPreferencesFragment.KEY_PURGE;
import static org.briarproject.android.panic.PanicPreferencesFragment.KEY_UNINSTALL;
@@ -31,6 +33,8 @@ public class PanicResponderActivity extends BriarActivity {
private static final Logger LOG =
Logger.getLogger(PanicResponderActivity.class.getName());
@Inject protected ConfigController configController;
@Inject
protected AndroidExecutor androidExecutor;
@Override
public void onCreate(Bundle savedInstanceState) {

View File

@@ -7,6 +7,7 @@ import org.acra.config.ACRAConfiguration;
import org.acra.sender.ReportSender;
import org.acra.sender.ReportSenderFactory;
import org.briarproject.android.BriarApplication;
import org.briarproject.android.BriarApplicationImp;
public class BriarReportSenderFactory implements ReportSenderFactory {
@NonNull