Fixes after comments, also removed the CryptoComoponent from the IdentIcons

This commit is contained in:
Ernir Erlingsson
2016-03-03 23:00:57 +01:00
parent 95d89553d5
commit 5aba1d79f1
16 changed files with 21 additions and 209 deletions

View File

@@ -25,7 +25,6 @@ import javax.inject.Inject;
public class AsymmetricIdenticon extends IdenticonView {
@Inject protected CryptoComponent mCrypto;
private IdenticonBase mDelegate;
public AsymmetricIdenticon(Context context) {
@@ -50,10 +49,6 @@ public class AsymmetricIdenticon extends IdenticonView {
private void initDelegate() {
mDelegate = new IdenticonBase() {
@Override
protected CryptoComponent getCrypto() {
return mCrypto;
}
@Override
protected int getRowCount() {

View File

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

View File

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

View File

@@ -26,8 +26,7 @@ import javax.inject.Inject;
public class SymmetricIdenticon extends IdenticonView {
private static final int CENTER_COLUMN_INDEX = 5;
@Inject protected CryptoComponent mCrypto;
private IdenticonBase mDelegate;
public SymmetricIdenticon(Context context) {
@@ -47,10 +46,6 @@ public class SymmetricIdenticon extends IdenticonView {
private void initDelegate() {
mDelegate = new IdenticonBase() {
@Override
protected CryptoComponent getCrypto() {
return mCrypto;
}
@Override
protected int getRowCount() {