mirror of
https://code.briarproject.org/briar/briar.git
synced 2026-02-13 11:19:04 +01:00
Fixes after comments, also removed the CryptoComoponent from the IdentIcons
This commit is contained in:
@@ -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() {
|
||||
|
||||
@@ -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();
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -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() {
|
||||
|
||||
@@ -87,11 +87,9 @@ public class ContactListAdapter
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private CryptoComponent crypto;
|
||||
|
||||
public ContactListAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||
public ContactListAdapter(Context context) {
|
||||
ctx = context;
|
||||
crypto = cryptoComponent;
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -121,7 +119,7 @@ public class ContactListAdapter
|
||||
|
||||
Author author = item.getContact().getAuthor();
|
||||
ui.avatar.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, author.getId().getBytes()));
|
||||
new IdenticonDrawable(author.getId().getBytes()));
|
||||
String contactName = author.getName();
|
||||
if (unread > 0) {
|
||||
ui.name.setText(contactName + " (" + unread + ")");
|
||||
|
||||
@@ -65,8 +65,6 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
return TAG;
|
||||
}
|
||||
|
||||
@Inject
|
||||
protected CryptoComponent crypto;
|
||||
@Inject
|
||||
protected ConnectionRegistry connectionRegistry;
|
||||
private ContactListAdapter adapter = null;
|
||||
@@ -80,11 +78,6 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
@Inject
|
||||
protected volatile EventBus eventBus;
|
||||
|
||||
@Override
|
||||
public void onCreate(@Nullable Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void injectActivity(AndroidComponent component) {
|
||||
component.inject(this);
|
||||
@@ -98,7 +91,7 @@ public class ContactListFragment extends BaseEventFragment {
|
||||
inflater.inflate(R.layout.activity_contact_list, container,
|
||||
false);
|
||||
|
||||
adapter = new ContactListAdapter(getContext(), crypto);
|
||||
adapter = new ContactListAdapter(getContext());
|
||||
list = (BriarRecyclerView) contentView.findViewById(R.id.contactList);
|
||||
list.setLayoutManager(new LinearLayoutManager(getContext()));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
@@ -72,7 +72,6 @@ public class ConversationActivity extends BriarActivity
|
||||
private static final Logger LOG =
|
||||
Logger.getLogger(ConversationActivity.class.getName());
|
||||
|
||||
@Inject protected CryptoComponent crypto;
|
||||
@Inject protected AndroidNotificationManager notificationManager;
|
||||
@Inject protected ConnectionRegistry connectionRegistry;
|
||||
@Inject @CryptoExecutor protected Executor cryptoExecutor;
|
||||
@@ -104,7 +103,7 @@ public class ConversationActivity extends BriarActivity
|
||||
|
||||
setContentView(R.layout.activity_conversation);
|
||||
|
||||
adapter = new ConversationAdapter(this, crypto);
|
||||
adapter = new ConversationAdapter(this);
|
||||
list = (BriarRecyclerView) findViewById(R.id.conversationView);
|
||||
list.setLayoutManager(new LinearLayoutManager(this));
|
||||
list.setAdapter(adapter);
|
||||
|
||||
@@ -73,12 +73,10 @@ class ConversationAdapter extends
|
||||
}
|
||||
});
|
||||
private Context ctx;
|
||||
private CryptoComponent crypto;
|
||||
private byte[] identiconKey;
|
||||
|
||||
public ConversationAdapter(Context context, CryptoComponent cryptoComponent) {
|
||||
public ConversationAdapter(Context context) {
|
||||
ctx = context;
|
||||
crypto = cryptoComponent;
|
||||
}
|
||||
|
||||
public void setIdenticonKey(byte[] key) {
|
||||
@@ -133,7 +131,7 @@ class ConversationAdapter extends
|
||||
} else {
|
||||
if (identiconKey != null)
|
||||
ui.avatar.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, identiconKey));
|
||||
new IdenticonDrawable(identiconKey));
|
||||
if (!header.isRead()) {
|
||||
int left = ui.layout.getPaddingLeft();
|
||||
int top = ui.layout.getPaddingTop();
|
||||
|
||||
@@ -124,7 +124,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
left.addRule(CENTER_VERTICAL);
|
||||
header.addView(from, left);
|
||||
|
||||
adapter = new LocalAuthorSpinnerAdapter(this, crypto, true);
|
||||
adapter = new LocalAuthorSpinnerAdapter(this, true);
|
||||
spinner = new Spinner(this);
|
||||
spinner.setId(2);
|
||||
spinner.setAdapter(adapter);
|
||||
|
||||
@@ -23,17 +23,14 @@ import static org.briarproject.android.identity.LocalAuthorItem.ANONYMOUS;
|
||||
import static org.briarproject.android.identity.LocalAuthorItem.NEW;
|
||||
|
||||
public class LocalAuthorSpinnerAdapter extends BaseAdapter
|
||||
implements SpinnerAdapter {
|
||||
implements SpinnerAdapter {
|
||||
|
||||
private final Context ctx;
|
||||
private final CryptoComponent crypto;
|
||||
private final boolean includeAnonymous;
|
||||
private final List<LocalAuthorItem> list = new ArrayList<LocalAuthorItem>();
|
||||
|
||||
public LocalAuthorSpinnerAdapter(Context ctx,
|
||||
CryptoComponent crypto, boolean includeAnonymous) {
|
||||
public LocalAuthorSpinnerAdapter(Context ctx, boolean includeAnonymous) {
|
||||
this.ctx = ctx;
|
||||
this.crypto = crypto;
|
||||
this.includeAnonymous = includeAnonymous;
|
||||
}
|
||||
|
||||
@@ -78,7 +75,7 @@ implements SpinnerAdapter {
|
||||
} else {
|
||||
name.setText(item.getLocalAuthor().getName());
|
||||
avatar.setVisibility(View.VISIBLE);
|
||||
avatar.setImageDrawable(new IdenticonDrawable(crypto,
|
||||
avatar.setImageDrawable(new IdenticonDrawable(
|
||||
item.getLocalAuthor().getId().getBytes()));
|
||||
}
|
||||
return view;
|
||||
|
||||
@@ -56,7 +56,7 @@ implements OnItemSelectedListener, OnClickListener {
|
||||
TextView step = (TextView) view.findViewById(R.id.stepView);
|
||||
step.setText(String.format(ctx.getString(R.string.step), 1, 3));
|
||||
|
||||
adapter = new LocalAuthorSpinnerAdapter(ctx, crypto, false);
|
||||
adapter = new LocalAuthorSpinnerAdapter(ctx, false);
|
||||
spinner = (Spinner) view.findViewById(R.id.spinner);
|
||||
spinner.setAdapter(adapter);
|
||||
spinner.setOnItemSelectedListener(this);
|
||||
|
||||
@@ -19,7 +19,6 @@ import im.delight.android.identicons.IdenticonDrawable;
|
||||
|
||||
public class AuthorView extends FrameLayout {
|
||||
|
||||
@Inject protected CryptoComponent crypto;
|
||||
private ImageView avatarView;
|
||||
private TextView nameView;
|
||||
private ImageView statusView;
|
||||
@@ -61,7 +60,7 @@ public class AuthorView extends FrameLayout {
|
||||
} else {
|
||||
nameView.setText(name);
|
||||
avatarView.setImageDrawable(
|
||||
new IdenticonDrawable(crypto, id.getBytes()));
|
||||
new IdenticonDrawable(id.getBytes()));
|
||||
}
|
||||
|
||||
switch(status) {
|
||||
|
||||
Reference in New Issue
Block a user