mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
implementing robolectric and mockito
This commit is contained in:
@@ -54,34 +54,33 @@ public class ActivityModule {
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
SetupController provideSetupController(
|
||||
SetupControllerImp setupControllerImp) {
|
||||
return setupControllerImp;
|
||||
protected SetupController provideSetupController() {
|
||||
return new SetupControllerImp();
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
ConfigController provideConfigController(
|
||||
protected ConfigController provideConfigController(
|
||||
ConfigControllerImp configControllerImp) {
|
||||
return configControllerImp;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
SharedPreferences provideSharedPreferences(Activity activity) {
|
||||
protected SharedPreferences provideSharedPreferences(Activity activity) {
|
||||
return activity.getSharedPreferences("db", Context.MODE_PRIVATE);
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
PasswordController providePasswordController(
|
||||
protected PasswordController providePasswordController(
|
||||
PasswordControllerImp passwordControllerImp) {
|
||||
return passwordControllerImp;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
BriarController provideBriarController(
|
||||
protected BriarController provideBriarController(
|
||||
BriarControllerImp briarControllerImp) {
|
||||
activity.addLifecycleController(briarControllerImp);
|
||||
return briarControllerImp;
|
||||
@@ -89,7 +88,7 @@ public class ActivityModule {
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
NavDrawerController provideNavDrawerController(
|
||||
protected NavDrawerController provideNavDrawerController(
|
||||
NavDrawerControllerImp navDrawerControllerImp) {
|
||||
activity.addLifecycleController(navDrawerControllerImp);
|
||||
if (activity instanceof TransportStateListener) {
|
||||
@@ -101,7 +100,7 @@ public class ActivityModule {
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
BriarServiceConnection provideBriarServiceConnection() {
|
||||
protected BriarServiceConnection provideBriarServiceConnection() {
|
||||
return new BriarServiceConnection();
|
||||
}
|
||||
|
||||
|
||||
@@ -38,7 +38,7 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
|
||||
activityComponent = DaggerActivityComponent.builder()
|
||||
.androidComponent(applicationComponent)
|
||||
.activityModule(new ActivityModule(this))
|
||||
.activityModule(getActivityModule())
|
||||
.build();
|
||||
|
||||
injectActivity(activityComponent);
|
||||
@@ -48,6 +48,11 @@ public abstract class BaseActivity extends AppCompatActivity {
|
||||
}
|
||||
}
|
||||
|
||||
// This exists to make test overrides easier
|
||||
protected ActivityModule getActivityModule() {
|
||||
return new ActivityModule(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onResume() {
|
||||
super.onResume();
|
||||
|
||||
@@ -27,8 +27,6 @@ import javax.inject.Inject;
|
||||
import static android.content.Intent.FLAG_ACTIVITY_NEW_TASK;
|
||||
import static android.view.View.INVISIBLE;
|
||||
import static android.view.View.VISIBLE;
|
||||
import static android.view.WindowManager.LayoutParams.FLAG_SECURE;
|
||||
import static org.briarproject.android.TestingConstants.PREVENT_SCREENSHOTS;
|
||||
import static org.briarproject.api.crypto.PasswordStrengthEstimator.WEAK;
|
||||
import static org.briarproject.api.identity.AuthorConstants.MAX_AUTHOR_NAME_LENGTH;
|
||||
|
||||
@@ -66,7 +64,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
createAccountButton = (Button) findViewById(R.id.create_account);
|
||||
progress = (ProgressBar) findViewById(R.id.progress_wheel);
|
||||
|
||||
if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
// if (PREVENT_SCREENSHOTS) getWindow().addFlags(FLAG_SECURE);
|
||||
|
||||
TextWatcher tw = new TextWatcher() {
|
||||
@Override
|
||||
@@ -125,6 +123,7 @@ public class SetupActivity extends BaseActivity implements OnClickListener,
|
||||
|
||||
public boolean onEditorAction(TextView v, int actionId, KeyEvent event) {
|
||||
hideSoftKeyboard(v);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
@@ -8,6 +8,7 @@ import android.provider.Settings;
|
||||
|
||||
import java.io.DataOutputStream;
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
@@ -15,6 +16,9 @@ import static android.provider.Settings.Secure.ANDROID_ID;
|
||||
|
||||
class AndroidSeedProvider extends LinuxSeedProvider {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(LinuxSeedProvider.class.getName());
|
||||
|
||||
private final Context appContext;
|
||||
|
||||
@Inject
|
||||
|
||||
Reference in New Issue
Block a user