mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-14 11:49:04 +01:00
Giant whitespace-only indentation patch.
This commit is contained in:
@@ -7,7 +7,7 @@ package im.delight.android.identicons;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -28,57 +28,57 @@ import roboguice.RoboGuice;
|
||||
|
||||
public class AsymmetricIdenticon extends IdenticonView {
|
||||
|
||||
@Inject private CryptoComponent mCrypto;
|
||||
private IdenticonBase mDelegate;
|
||||
@Inject private CryptoComponent mCrypto;
|
||||
private IdenticonBase mDelegate;
|
||||
|
||||
public AsymmetricIdenticon(Context context) {
|
||||
super(context);
|
||||
initDelegate();
|
||||
}
|
||||
public AsymmetricIdenticon(Context context) {
|
||||
super(context);
|
||||
initDelegate();
|
||||
}
|
||||
|
||||
public AsymmetricIdenticon(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initDelegate();
|
||||
}
|
||||
public AsymmetricIdenticon(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initDelegate();
|
||||
}
|
||||
|
||||
public AsymmetricIdenticon(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initDelegate();
|
||||
}
|
||||
public AsymmetricIdenticon(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initDelegate();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IdenticonBase getDelegate() {
|
||||
return mDelegate;
|
||||
}
|
||||
@Override
|
||||
protected IdenticonBase getDelegate() {
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
private void initDelegate() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return mCrypto;
|
||||
}
|
||||
private void initDelegate() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return mCrypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
return 4;
|
||||
}
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColumnCount() {
|
||||
return 4;
|
||||
}
|
||||
@Override
|
||||
protected int getColumnCount() {
|
||||
return 4;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCellVisible(int row, int column) {
|
||||
return getByte(3 + row * getColumnCount() + column) >= 0;
|
||||
}
|
||||
@Override
|
||||
protected boolean isCellVisible(int row, int column) {
|
||||
return getByte(3 + row * getColumnCount() + column) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconColor() {
|
||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected int getIconColor() {
|
||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -10,118 +10,118 @@ 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;
|
||||
private volatile int mCellWidth;
|
||||
private volatile int mCellHeight;
|
||||
private volatile byte[] mHash;
|
||||
private volatile int[][] mColors;
|
||||
private volatile boolean mReady;
|
||||
private final CryptoComponent mCrypto;
|
||||
private final int mRowCount;
|
||||
private final int mColumnCount;
|
||||
private final Paint mPaint;
|
||||
private volatile int mCellWidth;
|
||||
private volatile int mCellHeight;
|
||||
private volatile byte[] mHash;
|
||||
private volatile int[][] mColors;
|
||||
private volatile boolean mReady;
|
||||
|
||||
public IdenticonBase() {
|
||||
mCrypto = getCrypto();
|
||||
mRowCount = getRowCount();
|
||||
mColumnCount = getColumnCount();
|
||||
mPaint = new Paint();
|
||||
public IdenticonBase() {
|
||||
mCrypto = getCrypto();
|
||||
mRowCount = getRowCount();
|
||||
mColumnCount = getColumnCount();
|
||||
mPaint = new Paint();
|
||||
|
||||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setDither(true);
|
||||
}
|
||||
mPaint.setStyle(Paint.Style.FILL);
|
||||
mPaint.setAntiAlias(true);
|
||||
mPaint.setDither(true);
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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;
|
||||
}
|
||||
|
||||
protected void setupColors() {
|
||||
mColors = new int[mRowCount][mColumnCount];
|
||||
int colorVisible = getIconColor();
|
||||
int colorInvisible = getBackgroundColor();
|
||||
protected void setupColors() {
|
||||
mColors = new int[mRowCount][mColumnCount];
|
||||
int colorVisible = getIconColor();
|
||||
int colorInvisible = getBackgroundColor();
|
||||
|
||||
for (int r = 0; r < mRowCount; r++) {
|
||||
for (int c = 0; c < mColumnCount; c++) {
|
||||
if (isCellVisible(r, c)) {
|
||||
mColors[r][c] = colorVisible;
|
||||
} else {
|
||||
mColors[r][c] = colorInvisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (int r = 0; r < mRowCount; r++) {
|
||||
for (int c = 0; c < mColumnCount; c++) {
|
||||
if (isCellVisible(r, c)) {
|
||||
mColors[r][c] = colorVisible;
|
||||
} else {
|
||||
mColors[r][c] = colorInvisible;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void show(byte[] input) {
|
||||
if(input != null) {
|
||||
mHash = getHash(input);
|
||||
} else {
|
||||
mHash = null;
|
||||
}
|
||||
// set up the cell colors according to the input that was provided via show(...)
|
||||
setupColors();
|
||||
public void show(byte[] input) {
|
||||
if(input != null) {
|
||||
mHash = getHash(input);
|
||||
} else {
|
||||
mHash = null;
|
||||
}
|
||||
// set up the cell colors according to the input that was provided via show(...)
|
||||
setupColors();
|
||||
|
||||
// this view may now be drawn (and thus must be re-drawn)
|
||||
mReady = true;
|
||||
}
|
||||
// this view may now be drawn (and thus must be re-drawn)
|
||||
mReady = true;
|
||||
}
|
||||
|
||||
public byte getByte(int index) {
|
||||
if (mHash == null) {
|
||||
return -128;
|
||||
} else {
|
||||
return mHash[index % mHash.length];
|
||||
}
|
||||
}
|
||||
public byte getByte(int index) {
|
||||
if (mHash == null) {
|
||||
return -128;
|
||||
} else {
|
||||
return mHash[index % mHash.length];
|
||||
}
|
||||
}
|
||||
|
||||
abstract protected CryptoComponent getCrypto();
|
||||
abstract protected CryptoComponent getCrypto();
|
||||
|
||||
abstract protected int getRowCount();
|
||||
abstract protected int getRowCount();
|
||||
|
||||
abstract protected int getColumnCount();
|
||||
abstract protected int getColumnCount();
|
||||
|
||||
abstract protected boolean isCellVisible(int row, int column);
|
||||
abstract protected boolean isCellVisible(int row, int column);
|
||||
|
||||
abstract protected int getIconColor();
|
||||
abstract protected int getIconColor();
|
||||
|
||||
protected int getBackgroundColor() {
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(getIconColor(), hsv);
|
||||
if (hsv[2] < 0.5)
|
||||
return Color.parseColor("#ffeeeeee"); // @color/background_material_light
|
||||
else
|
||||
return Color.parseColor("#ff303030"); // @color/background_material_dark
|
||||
}
|
||||
protected int getBackgroundColor() {
|
||||
float[] hsv = new float[3];
|
||||
Color.colorToHSV(getIconColor(), hsv);
|
||||
if (hsv[2] < 0.5)
|
||||
return Color.parseColor("#ffeeeeee"); // @color/background_material_light
|
||||
else
|
||||
return Color.parseColor("#ff303030"); // @color/background_material_dark
|
||||
}
|
||||
|
||||
public void updateSize(int w, int h) {
|
||||
mCellWidth = w / mColumnCount;
|
||||
mCellHeight = h / mRowCount;
|
||||
}
|
||||
public void updateSize(int w, int h) {
|
||||
mCellWidth = w / mColumnCount;
|
||||
mCellHeight = h / mRowCount;
|
||||
}
|
||||
|
||||
protected void draw(Canvas canvas) {
|
||||
if (mReady) {
|
||||
int x, y;
|
||||
for (int r = 0; r < mRowCount; r++) {
|
||||
for (int c = 0; c < mColumnCount; c++) {
|
||||
x = mCellWidth * c;
|
||||
y = mCellHeight * r;
|
||||
protected void draw(Canvas canvas) {
|
||||
if (mReady) {
|
||||
int x, y;
|
||||
for (int r = 0; r < mRowCount; r++) {
|
||||
for (int c = 0; c < mColumnCount; c++) {
|
||||
x = mCellWidth * c;
|
||||
y = mCellHeight * r;
|
||||
|
||||
mPaint.setColor(mColors[r][c]);
|
||||
mPaint.setColor(mColors[r][c]);
|
||||
|
||||
canvas.drawRect(x, y + mCellHeight, x + mCellWidth, y, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
canvas.drawRect(x, y + mCellHeight, x + mCellWidth, y, mPaint);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,90 +13,90 @@ import org.briarproject.api.crypto.CryptoComponent;
|
||||
* Created by saiimons on 05/10/14.
|
||||
*/
|
||||
public class IdenticonDrawable extends Drawable {
|
||||
private IdenticonBase mDelegate;
|
||||
private IdenticonBase mDelegate;
|
||||
|
||||
private static final int CENTER_COLUMN_INDEX = 5;
|
||||
private static final int CENTER_COLUMN_INDEX = 5;
|
||||
|
||||
public IdenticonDrawable(final CryptoComponent crypto, byte[] toShow) {
|
||||
super();
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return crypto;
|
||||
}
|
||||
public IdenticonDrawable(final CryptoComponent crypto, byte[] toShow) {
|
||||
super();
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return crypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
return 9;
|
||||
}
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColumnCount() {
|
||||
return 9;
|
||||
}
|
||||
@Override
|
||||
protected int getColumnCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCellVisible(int row, int column) {
|
||||
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
||||
}
|
||||
@Override
|
||||
protected boolean isCellVisible(int row, int column) {
|
||||
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconColor() {
|
||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
||||
}
|
||||
};
|
||||
mDelegate.show(toShow);
|
||||
}
|
||||
@Override
|
||||
protected int getIconColor() {
|
||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
||||
}
|
||||
};
|
||||
mDelegate.show(toShow);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return 200;
|
||||
}
|
||||
@Override
|
||||
public int getIntrinsicHeight() {
|
||||
return 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return 200;
|
||||
}
|
||||
@Override
|
||||
public int getIntrinsicWidth() {
|
||||
return 200;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(Rect bounds) {
|
||||
super.setBounds(bounds);
|
||||
Log.d("IDENTICON", "SIZE : " + (bounds.right - bounds.left) + " " + (bounds.bottom - bounds.top));
|
||||
mDelegate.updateSize(bounds.right - bounds.left, bounds.bottom - bounds.top);
|
||||
}
|
||||
@Override
|
||||
public void setBounds(Rect bounds) {
|
||||
super.setBounds(bounds);
|
||||
Log.d("IDENTICON", "SIZE : " + (bounds.right - bounds.left) + " " + (bounds.bottom - bounds.top));
|
||||
mDelegate.updateSize(bounds.right - bounds.left, bounds.bottom - bounds.top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setBounds(int left, int top, int right, int bottom) {
|
||||
super.setBounds(left, top, right, bottom);
|
||||
mDelegate.updateSize(right - left, bottom - top);
|
||||
}
|
||||
@Override
|
||||
public void setBounds(int left, int top, int right, int bottom) {
|
||||
super.setBounds(left, top, right, bottom);
|
||||
mDelegate.updateSize(right - left, bottom - top);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
Log.d("IDENTICON", "DRAW IN PROGRESS");
|
||||
mDelegate.draw(canvas);
|
||||
}
|
||||
@Override
|
||||
public void draw(Canvas canvas) {
|
||||
Log.d("IDENTICON", "DRAW IN PROGRESS");
|
||||
mDelegate.draw(canvas);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
@Override
|
||||
public void setAlpha(int alpha) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
@Override
|
||||
public void setColorFilter(ColorFilter cf) {
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
@Override
|
||||
public int getOpacity() {
|
||||
return 0;
|
||||
}
|
||||
|
||||
protected int getSymmetricColumnIndex(int row) {
|
||||
if (row < CENTER_COLUMN_INDEX) {
|
||||
return row;
|
||||
} else {
|
||||
return mDelegate.getColumnCount() - row - 1;
|
||||
}
|
||||
}
|
||||
protected int getSymmetricColumnIndex(int row) {
|
||||
if (row < CENTER_COLUMN_INDEX) {
|
||||
return row;
|
||||
} else {
|
||||
return mDelegate.getColumnCount() - row - 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package im.delight.android.identicons;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -26,97 +26,97 @@ import android.view.View;
|
||||
abstract public class IdenticonView extends View {
|
||||
|
||||
|
||||
public IdenticonView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
public IdenticonView(Context context) {
|
||||
super(context);
|
||||
init();
|
||||
}
|
||||
|
||||
public IdenticonView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
public IdenticonView(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
init();
|
||||
}
|
||||
|
||||
public IdenticonView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
public IdenticonView(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
init();
|
||||
}
|
||||
|
||||
@SuppressLint("NewApi")
|
||||
protected void init() {
|
||||
setWillNotDraw(false);
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
}
|
||||
@SuppressLint("NewApi")
|
||||
protected void init() {
|
||||
setWillNotDraw(false);
|
||||
if (Build.VERSION.SDK_INT >= 11) {
|
||||
setLayerType(View.LAYER_TYPE_SOFTWARE, null);
|
||||
}
|
||||
}
|
||||
|
||||
public void show(byte[] input) {
|
||||
getDelegate().show(input);
|
||||
invalidate();
|
||||
}
|
||||
public void show(byte[] input) {
|
||||
getDelegate().show(input);
|
||||
invalidate();
|
||||
}
|
||||
|
||||
public void show(String input) {
|
||||
show(input.getBytes());
|
||||
}
|
||||
public void show(String input) {
|
||||
show(input.getBytes());
|
||||
}
|
||||
|
||||
public void show(int input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
public void show(int input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
|
||||
public void show(long input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
public void show(long input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
|
||||
public void show(float input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
public void show(float input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
|
||||
public void show(double input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
public void show(double input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
|
||||
public void show(byte input) {
|
||||
show(new byte[] { input });
|
||||
}
|
||||
public void show(byte input) {
|
||||
show(new byte[] { input });
|
||||
}
|
||||
|
||||
public void show(char input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
public void show(char input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
|
||||
public void show(boolean input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
public void show(boolean input) {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
|
||||
public void show(Object input) {
|
||||
if (input == null) {
|
||||
getDelegate().show(null);
|
||||
} else {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
}
|
||||
public void show(Object input) {
|
||||
if (input == null) {
|
||||
getDelegate().show(null);
|
||||
} else {
|
||||
show(String.valueOf(input));
|
||||
}
|
||||
}
|
||||
|
||||
protected byte getByte(int index) {
|
||||
return getDelegate().getByte(index);
|
||||
}
|
||||
protected byte getByte(int index) {
|
||||
return getDelegate().getByte(index);
|
||||
}
|
||||
|
||||
abstract protected IdenticonBase getDelegate();
|
||||
abstract protected IdenticonBase getDelegate();
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
getDelegate().updateSize(w, h);
|
||||
}
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
super.onSizeChanged(w, h, oldw, oldh);
|
||||
getDelegate().updateSize(w, h);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
|
||||
setMeasuredDimension(size, size);
|
||||
}
|
||||
@Override
|
||||
protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
|
||||
super.onMeasure(widthMeasureSpec, heightMeasureSpec);
|
||||
int size = Math.min(getMeasuredWidth(), getMeasuredHeight());
|
||||
setMeasuredDimension(size, size);
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
getDelegate().draw(canvas);
|
||||
}
|
||||
@Override
|
||||
protected void onDraw(Canvas canvas) {
|
||||
super.onDraw(canvas);
|
||||
getDelegate().draw(canvas);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -7,7 +7,7 @@ package im.delight.android.identicons;
|
||||
* you may not use this file except in compliance with the License.
|
||||
* You may obtain a copy of the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||
@@ -28,67 +28,67 @@ import roboguice.RoboGuice;
|
||||
|
||||
public class SymmetricIdenticon extends IdenticonView {
|
||||
|
||||
private static final int CENTER_COLUMN_INDEX = 5;
|
||||
private static final int CENTER_COLUMN_INDEX = 5;
|
||||
|
||||
@Inject private CryptoComponent mCrypto;
|
||||
private IdenticonBase mDelegate;
|
||||
@Inject private CryptoComponent mCrypto;
|
||||
private IdenticonBase mDelegate;
|
||||
|
||||
public SymmetricIdenticon(Context context) {
|
||||
super(context);
|
||||
initDelegate();
|
||||
}
|
||||
public SymmetricIdenticon(Context context) {
|
||||
super(context);
|
||||
initDelegate();
|
||||
}
|
||||
|
||||
public SymmetricIdenticon(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initDelegate();
|
||||
}
|
||||
public SymmetricIdenticon(Context context, AttributeSet attrs) {
|
||||
super(context, attrs);
|
||||
initDelegate();
|
||||
}
|
||||
|
||||
public SymmetricIdenticon(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initDelegate();
|
||||
}
|
||||
public SymmetricIdenticon(Context context, AttributeSet attrs, int defStyleAttr) {
|
||||
super(context, attrs, defStyleAttr);
|
||||
initDelegate();
|
||||
}
|
||||
|
||||
private void initDelegate() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return mCrypto;
|
||||
}
|
||||
private void initDelegate() {
|
||||
RoboGuice.injectMembers(getContext(), this);
|
||||
mDelegate = new IdenticonBase() {
|
||||
@Override
|
||||
protected CryptoComponent getCrypto() {
|
||||
return mCrypto;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
return 9;
|
||||
}
|
||||
@Override
|
||||
protected int getRowCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getColumnCount() {
|
||||
return 9;
|
||||
}
|
||||
@Override
|
||||
protected int getColumnCount() {
|
||||
return 9;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected boolean isCellVisible(int row, int column) {
|
||||
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
||||
}
|
||||
@Override
|
||||
protected boolean isCellVisible(int row, int column) {
|
||||
return getByte(3 + row * CENTER_COLUMN_INDEX + getSymmetricColumnIndex(column)) >= 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
protected int getIconColor() {
|
||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
||||
}
|
||||
};
|
||||
}
|
||||
@Override
|
||||
protected int getIconColor() {
|
||||
return Color.rgb(getByte(0) + 128, getByte(1) + 128, getByte(2) + 128);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@Override
|
||||
protected IdenticonBase getDelegate() {
|
||||
return mDelegate;
|
||||
}
|
||||
@Override
|
||||
protected IdenticonBase getDelegate() {
|
||||
return mDelegate;
|
||||
}
|
||||
|
||||
protected int getSymmetricColumnIndex(int row) {
|
||||
if (row < CENTER_COLUMN_INDEX) {
|
||||
return row;
|
||||
} else {
|
||||
return getDelegate().getColumnCount() - row - 1;
|
||||
}
|
||||
}
|
||||
protected int getSymmetricColumnIndex(int row) {
|
||||
if (row < CENTER_COLUMN_INDEX) {
|
||||
return row;
|
||||
} else {
|
||||
return getDelegate().getColumnCount() - row - 1;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user