mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-11 18:29:05 +01:00
modifications based on Akwizgran's comments
This commit is contained in:
@@ -29,7 +29,7 @@
|
||||
<uses-permission android:name="android.permission.ACCESS_COARSE_LOCATION" />
|
||||
|
||||
<application
|
||||
android:name=".android.BriarApplicationImp"
|
||||
android:name=".android.BriarApplicationImpl"
|
||||
android:allowBackup="false"
|
||||
android:icon="@drawable/ic_launcher"
|
||||
android:label="@string/app_name"
|
||||
|
||||
@@ -93,10 +93,6 @@ android {
|
||||
assets.srcDirs = ['assets']
|
||||
}
|
||||
|
||||
// Move the tests to tests/java, tests/res, etc...
|
||||
//instrumentTest.setRoot('tests')
|
||||
// unitTest.setRoot('tests')
|
||||
|
||||
androidTest.setRoot('androidTest')
|
||||
androidTest {
|
||||
java.srcDirs = ['androidTest/java']
|
||||
|
||||
@@ -50,20 +50,6 @@
|
||||
-keep class dagger.** { *; }
|
||||
-keep class com.google.** { *; }
|
||||
|
||||
-dontwarn org.hamcrest.**
|
||||
-dontwarn com.squareup.**
|
||||
-dontwarn com.google.android.**
|
||||
|
||||
-keep class com.google.android.** {
|
||||
*;
|
||||
}
|
||||
-keep class com.google.common.** {
|
||||
*;
|
||||
}
|
||||
-keep class org.hamcrest.** {
|
||||
*;
|
||||
}
|
||||
|
||||
-dontwarn org.h2.**
|
||||
-dontnote org.h2.**
|
||||
-dontwarn net.sf.cglib.**
|
||||
|
||||
@@ -7,18 +7,18 @@ import android.os.Bundle;
|
||||
|
||||
import org.briarproject.android.contact.ContactListFragment;
|
||||
import org.briarproject.android.controller.BriarController;
|
||||
import org.briarproject.android.controller.BriarControllerImp;
|
||||
import org.briarproject.android.controller.BriarControllerImpl;
|
||||
import org.briarproject.android.controller.NavDrawerController;
|
||||
import org.briarproject.android.controller.NavDrawerControllerImp;
|
||||
import org.briarproject.android.controller.NavDrawerControllerImpl;
|
||||
import org.briarproject.android.controller.PasswordControllerImpl;
|
||||
import org.briarproject.android.controller.SetupControllerImpl;
|
||||
import org.briarproject.android.controller.TransportStateListener;
|
||||
import org.briarproject.android.forum.ForumListFragment;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.android.controller.PasswordController;
|
||||
import org.briarproject.android.controller.PasswordControllerImp;
|
||||
import org.briarproject.android.controller.SetupController;
|
||||
import org.briarproject.android.controller.SetupControllerImp;
|
||||
import org.briarproject.android.controller.ConfigController;
|
||||
import org.briarproject.android.controller.ConfigControllerImp;
|
||||
import org.briarproject.android.controller.ConfigControllerImpl;
|
||||
import org.briarproject.android.introduction.ContactChooserFragment;
|
||||
import org.briarproject.android.introduction.IntroductionMessageFragment;
|
||||
import org.briarproject.android.keyagreement.ChooseIdentityFragment;
|
||||
@@ -55,15 +55,15 @@ public class ActivityModule {
|
||||
@ActivityScope
|
||||
@Provides
|
||||
protected SetupController provideSetupController(
|
||||
SetupControllerImp setupControllerImp) {
|
||||
return setupControllerImp;
|
||||
SetupControllerImpl setupControllerImpl) {
|
||||
return setupControllerImpl;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
protected ConfigController provideConfigController(
|
||||
ConfigControllerImp configControllerImp) {
|
||||
return configControllerImp;
|
||||
ConfigControllerImpl configControllerImpl) {
|
||||
return configControllerImpl;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@@ -75,22 +75,22 @@ public class ActivityModule {
|
||||
@ActivityScope
|
||||
@Provides
|
||||
protected PasswordController providePasswordController(
|
||||
PasswordControllerImp passwordControllerImp) {
|
||||
PasswordControllerImpl passwordControllerImp) {
|
||||
return passwordControllerImp;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
protected BriarController provideBriarController(
|
||||
BriarControllerImp briarControllerImp) {
|
||||
activity.addLifecycleController(briarControllerImp);
|
||||
return briarControllerImp;
|
||||
BriarControllerImpl briarControllerImpl) {
|
||||
activity.addLifecycleController(briarControllerImpl);
|
||||
return briarControllerImpl;
|
||||
}
|
||||
|
||||
@ActivityScope
|
||||
@Provides
|
||||
protected NavDrawerController provideNavDrawerController(
|
||||
NavDrawerControllerImp navDrawerControllerImp) {
|
||||
NavDrawerControllerImpl navDrawerControllerImp) {
|
||||
activity.addLifecycleController(navDrawerControllerImp);
|
||||
if (activity instanceof TransportStateListener) {
|
||||
navDrawerControllerImp
|
||||
|
||||
@@ -3,7 +3,6 @@ package org.briarproject.android;
|
||||
import android.annotation.SuppressLint;
|
||||
import android.content.Intent;
|
||||
import android.os.Build;
|
||||
import android.os.Bundle;
|
||||
|
||||
import org.briarproject.android.controller.BriarController;
|
||||
import org.briarproject.android.controller.handler.UiResultHandler;
|
||||
@@ -35,11 +34,6 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
@Inject
|
||||
protected BriarController briarController;
|
||||
|
||||
@Override
|
||||
public void onCreate(Bundle state) {
|
||||
super.onCreate(state);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onActivityResult(int request, int result, Intent data) {
|
||||
super.onActivityResult(request, result, data);
|
||||
@@ -52,7 +46,7 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
@Override
|
||||
public void onResume() {
|
||||
super.onResume();
|
||||
if (!briarController.encryptionKey() && !isFinishing()) {
|
||||
if (!briarController.hasEncryptionKey() && !isFinishing()) {
|
||||
Intent i = new Intent(this, PasswordActivity.class);
|
||||
i.setFlags(FLAG_ACTIVITY_NO_ANIMATION | FLAG_ACTIVITY_SINGLE_TOP);
|
||||
startActivityForResult(i, REQUEST_PASSWORD);
|
||||
@@ -93,7 +87,7 @@ public abstract class BriarActivity extends BaseActivity {
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void runOnDbThread(final Runnable task) {
|
||||
public void runOnDbThread(Runnable task) {
|
||||
briarController.runOnDbThread(task);
|
||||
}
|
||||
|
||||
|
||||
@@ -22,10 +22,10 @@ import java.util.logging.Logger;
|
||||
resDialogOkToast = R.string.dev_report_saved,
|
||||
deleteOldUnsentReportsOnApplicationStart = false
|
||||
)
|
||||
public class BriarApplicationImp extends Application implements BriarApplication {
|
||||
public class BriarApplicationImpl extends Application implements BriarApplication {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BriarApplicationImp.class.getName());
|
||||
Logger.getLogger(BriarApplicationImpl.class.getName());
|
||||
|
||||
private AndroidComponent applicationComponent;
|
||||
|
||||
@@ -21,11 +21,10 @@ import android.widget.TextView;
|
||||
import org.briarproject.R;
|
||||
import org.briarproject.android.controller.NavDrawerController;
|
||||
import org.briarproject.android.controller.TransportStateListener;
|
||||
import org.briarproject.android.controller.handler.UiResultExceptionHandler;
|
||||
import org.briarproject.android.controller.handler.UiResultHandler;
|
||||
import org.briarproject.android.fragment.BaseFragment;
|
||||
import org.briarproject.android.util.CustomAnimations;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
|
||||
import java.util.ArrayList;
|
||||
@@ -48,7 +47,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
private ActionBarDrawerToggle drawerToggle;
|
||||
|
||||
@Inject
|
||||
NavDrawerController controller;
|
||||
protected NavDrawerController controller;
|
||||
|
||||
private Toolbar toolbar;
|
||||
private DrawerLayout drawerLayout;
|
||||
@@ -159,16 +158,11 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
|
||||
private void storeLocalAuthor(final LocalAuthor a) {
|
||||
controller.storeLocalAuthor(a,
|
||||
new UiResultExceptionHandler<Void, DbException>(this) {
|
||||
new UiResultHandler<Void>(this) {
|
||||
@Override
|
||||
public void onResultUi(Void result) {
|
||||
hideLoadingScreen();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onExceptionUi(DbException exception) {
|
||||
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -245,21 +239,21 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
|
||||
Transport tor = new Transport();
|
||||
tor.id = new TransportId("tor");
|
||||
tor.enabled = controller.transportRunning(tor.id);
|
||||
tor.enabled = controller.isTransportRunning(tor.id);
|
||||
tor.iconId = R.drawable.transport_tor;
|
||||
tor.textId = R.string.transport_tor;
|
||||
transports.add(tor);
|
||||
|
||||
Transport bt = new Transport();
|
||||
bt.id = new TransportId("bt");
|
||||
bt.enabled = controller.transportRunning(bt.id);
|
||||
bt.enabled = controller.isTransportRunning(bt.id);
|
||||
bt.iconId = R.drawable.transport_bt;
|
||||
bt.textId = R.string.transport_bt;
|
||||
transports.add(bt);
|
||||
|
||||
Transport lan = new Transport();
|
||||
lan.id = new TransportId("lan");
|
||||
lan.enabled = controller.transportRunning(lan.id);
|
||||
lan.enabled = controller.isTransportRunning(lan.id);
|
||||
lan.iconId = R.drawable.transport_lan;
|
||||
lan.textId = R.string.transport_lan;
|
||||
transports.add(lan);
|
||||
@@ -326,7 +320,7 @@ public class NavDrawerActivity extends BriarFragmentActivity implements
|
||||
private void updateTransports() {
|
||||
if (transports == null || transportsAdapter == null) return;
|
||||
for (Transport t : transports) {
|
||||
t.enabled = controller.transportRunning(t.id);
|
||||
t.enabled = controller.isTransportRunning(t.id);
|
||||
}
|
||||
transportsAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@@ -69,6 +69,7 @@ public class SplashScreenActivity extends BaseActivity {
|
||||
startActivity(new Intent(this, NavDrawerActivity.class));
|
||||
} else {
|
||||
configController.clearPrefs();
|
||||
// TODO replace this static call with a controller method
|
||||
AndroidUtils.deleteAppData(this);
|
||||
startActivity(new Intent(this, SetupActivity.class));
|
||||
}
|
||||
|
||||
@@ -8,7 +8,7 @@ public interface BriarController extends ActivityLifecycleController {
|
||||
|
||||
void startAndBindService();
|
||||
|
||||
boolean encryptionKey();
|
||||
boolean hasEncryptionKey();
|
||||
|
||||
void signOut(ResultHandler<Void> eventHandler);
|
||||
}
|
||||
|
||||
@@ -17,10 +17,10 @@ import java.util.logging.Logger;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class BriarControllerImp implements BriarController {
|
||||
public class BriarControllerImpl implements BriarController {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(BriarControllerImp.class.getName());
|
||||
Logger.getLogger(BriarControllerImpl.class.getName());
|
||||
|
||||
@Inject
|
||||
protected BriarServiceConnection serviceConnection;
|
||||
@@ -38,7 +38,7 @@ public class BriarControllerImp implements BriarController {
|
||||
private boolean bound = false;
|
||||
|
||||
@Inject
|
||||
public BriarControllerImp() {
|
||||
public BriarControllerImpl() {
|
||||
|
||||
}
|
||||
|
||||
@@ -71,7 +71,7 @@ public class BriarControllerImp implements BriarController {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean encryptionKey() {
|
||||
public boolean hasEncryptionKey() {
|
||||
return databaseConfig.getEncryptionKey() != null;
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import org.briarproject.api.db.DatabaseConfig;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class ConfigControllerImp implements ConfigController {
|
||||
public class ConfigControllerImpl implements ConfigController {
|
||||
|
||||
private final static String PREF_DB_KEY = "key";
|
||||
|
||||
@@ -16,7 +16,7 @@ public class ConfigControllerImp implements ConfigController {
|
||||
protected volatile DatabaseConfig databaseConfig;
|
||||
|
||||
@Inject
|
||||
public ConfigControllerImp() {
|
||||
public ConfigControllerImpl() {
|
||||
|
||||
}
|
||||
|
||||
@@ -1,17 +1,16 @@
|
||||
package org.briarproject.android.controller;
|
||||
|
||||
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
||||
import org.briarproject.android.controller.handler.UiResultHandler;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.identity.LocalAuthor;
|
||||
|
||||
public interface NavDrawerController extends BriarController {
|
||||
void setTransportListener(TransportStateListener transportListener);
|
||||
|
||||
boolean transportRunning(TransportId transportId);
|
||||
boolean isTransportRunning(TransportId transportId);
|
||||
|
||||
void storeLocalAuthor(LocalAuthor author,
|
||||
ResultExceptionHandler<Void, DbException> resultHandler);
|
||||
UiResultHandler<Void> resultHandler);
|
||||
|
||||
LocalAuthor removeAuthorHandle(long handle);
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package org.briarproject.android.controller;
|
||||
import android.app.Activity;
|
||||
|
||||
import org.briarproject.android.api.ReferenceManager;
|
||||
import org.briarproject.android.controller.handler.ResultExceptionHandler;
|
||||
import org.briarproject.android.controller.handler.UiResultHandler;
|
||||
import org.briarproject.api.TransportId;
|
||||
import org.briarproject.api.db.DbException;
|
||||
import org.briarproject.api.event.Event;
|
||||
@@ -25,11 +25,11 @@ import javax.inject.Inject;
|
||||
import static java.util.logging.Level.INFO;
|
||||
import static java.util.logging.Level.WARNING;
|
||||
|
||||
public class NavDrawerControllerImp extends BriarControllerImp
|
||||
public class NavDrawerControllerImpl extends BriarControllerImpl
|
||||
implements NavDrawerController, EventListener {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(NavDrawerControllerImp.class.getName());
|
||||
Logger.getLogger(NavDrawerControllerImpl.class.getName());
|
||||
|
||||
@Inject
|
||||
protected ReferenceManager referenceManager;
|
||||
@@ -38,7 +38,7 @@ public class NavDrawerControllerImp extends BriarControllerImp
|
||||
@Inject
|
||||
protected PluginManager pluginManager;
|
||||
@Inject
|
||||
protected volatile EventBus eventBus;
|
||||
protected EventBus eventBus;
|
||||
@Inject
|
||||
protected Activity activity;
|
||||
|
||||
@@ -47,7 +47,7 @@ public class NavDrawerControllerImp extends BriarControllerImp
|
||||
private TransportStateListener transportStateListener;
|
||||
|
||||
@Inject
|
||||
public NavDrawerControllerImp() {
|
||||
public NavDrawerControllerImpl() {
|
||||
|
||||
}
|
||||
|
||||
@@ -103,15 +103,14 @@ public class NavDrawerControllerImp extends BriarControllerImp
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean transportRunning(TransportId transportId) {
|
||||
public boolean isTransportRunning(TransportId transportId) {
|
||||
Plugin plugin = pluginManager.getPlugin(transportId);
|
||||
return plugin != null && plugin.isRunning();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void storeLocalAuthor(final LocalAuthor author,
|
||||
final ResultExceptionHandler<Void, DbException> resultHandler) {
|
||||
|
||||
final UiResultHandler<Void> resultHandler) {
|
||||
runOnDbThread(new Runnable() {
|
||||
public void run() {
|
||||
try {
|
||||
@@ -124,7 +123,6 @@ public class NavDrawerControllerImp extends BriarControllerImp
|
||||
} catch (final DbException e) {
|
||||
if (LOG.isLoggable(WARNING))
|
||||
LOG.log(WARNING, e.toString(), e);
|
||||
resultHandler.onException(e);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -12,7 +12,7 @@ import java.util.concurrent.Executor;
|
||||
|
||||
import javax.inject.Inject;
|
||||
|
||||
public class PasswordControllerImp extends ConfigControllerImp
|
||||
public class PasswordControllerImpl extends ConfigControllerImpl
|
||||
implements PasswordController {
|
||||
|
||||
@Inject
|
||||
@@ -24,7 +24,7 @@ public class PasswordControllerImp extends ConfigControllerImp
|
||||
protected Activity activity;
|
||||
|
||||
@Inject
|
||||
public PasswordControllerImp() {
|
||||
public PasswordControllerImpl() {
|
||||
|
||||
}
|
||||
|
||||
@@ -47,6 +47,8 @@ public class PasswordControllerImp extends ConfigControllerImp
|
||||
|
||||
private byte[] getEncryptedKey() {
|
||||
String hex = getEncryptedDatabaseKey();
|
||||
return hex == null ? null : StringUtils.fromHexString(hex);
|
||||
if (hex == null)
|
||||
throw new IllegalStateException("Encrypted database key is null.");
|
||||
return StringUtils.fromHexString(hex);
|
||||
}
|
||||
}
|
||||
@@ -22,10 +22,10 @@ import javax.inject.Inject;
|
||||
|
||||
import static java.util.logging.Level.INFO;
|
||||
|
||||
public class SetupControllerImp implements SetupController {
|
||||
public class SetupControllerImpl implements SetupController {
|
||||
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(SetupControllerImp.class.getName());
|
||||
Logger.getLogger(SetupControllerImpl.class.getName());
|
||||
|
||||
private final static String PREF_DB_KEY = "key";
|
||||
|
||||
@@ -50,7 +50,7 @@ public class SetupControllerImp implements SetupController {
|
||||
protected SharedPreferences briarPrefs;
|
||||
|
||||
@Inject
|
||||
public SetupControllerImp() {
|
||||
public SetupControllerImpl() {
|
||||
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ public class SetupControllerImp implements SetupController {
|
||||
databaseConfig.setEncryptionKey(key);
|
||||
String hex = encryptDatabaseKey(key, password);
|
||||
storeEncryptedDatabaseKey(hex);
|
||||
final LocalAuthor localAuthor = createLocalAuthor(nickname);
|
||||
LocalAuthor localAuthor = createLocalAuthor(nickname);
|
||||
long handle = referenceManager.putReference(localAuthor,
|
||||
LocalAuthor.class);
|
||||
resultHandler.onResult(handle);
|
||||
@@ -112,6 +112,7 @@ public class PanicResponderActivity extends BriarActivity {
|
||||
public void run() {
|
||||
configController.clearPrefs();
|
||||
// TODO somehow delete/shred the database more thoroughly
|
||||
// TODO replace this static call with a controller method
|
||||
AndroidUtils.deleteAppData(PanicResponderActivity.this);
|
||||
PanicResponder.deleteAllAppData(PanicResponderActivity.this);
|
||||
|
||||
|
||||
@@ -7,7 +7,6 @@ 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
|
||||
|
||||
@@ -37,7 +37,7 @@ class AndroidSeedProvider extends LinuxSeedProvider {
|
||||
String str = Settings.Secure.getString(contentResolver, ANDROID_ID);
|
||||
if (str != null) {
|
||||
out.writeUTF(str);
|
||||
super.writeToEntropyPool(out);
|
||||
}
|
||||
super.writeToEntropyPool(out);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -144,13 +144,13 @@ public class SetupActivityTest {
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testNickUI() {
|
||||
public void testNicknameUI() {
|
||||
Assert.assertNotNull(setupActivity);
|
||||
String longNick =
|
||||
Strings.padEnd("*", AuthorConstants.MAX_AUTHOR_NAME_LENGTH + 1,
|
||||
'*');
|
||||
nicknameEntry.setText(longNick);
|
||||
// Password should be too long
|
||||
// Nickname should be too long
|
||||
assertEquals(nicknameEntryWrapper.getError(),
|
||||
setupActivity.getString(R.string.name_too_long));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user