modifications based on Akwizgran's comments

This commit is contained in:
Ernir Erlingsson
2016-05-11 11:40:49 +02:00
parent d4232b6a01
commit c93e78f178
19 changed files with 57 additions and 87 deletions

View File

@@ -8,7 +8,7 @@ public interface BriarController extends ActivityLifecycleController {
void startAndBindService();
boolean encryptionKey();
boolean hasEncryptionKey();
void signOut(ResultHandler<Void> eventHandler);
}

View File

@@ -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;
}

View File

@@ -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() {
}

View File

@@ -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);
}

View File

@@ -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);
}
}
});

View File

@@ -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);
}
}

View File

@@ -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);