Clean up list of identity keys.

pull/1/head
Moxie Marlinspike 11 years ago
parent 5e2b31af60
commit 3743c57edd

@ -1,9 +1,26 @@
<?xml version="1.0" encoding="utf-8"?> <?xml version="1.0" encoding="utf-8"?>
<org.thoughtcrime.securesms.IdentityKeyView xmlns:android="http://schemas.android.com/apk/res/android" <org.thoughtcrime.securesms.IdentityKeyView xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="?android:attr/listPreferredItemHeight" android:layout_height="wrap_content"
android:orientation="horizontal" android:paddingRight="10dip">
android:padding="15dip">
<FrameLayout android:id="@+id/contact_photo_frame"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_centerVertical="true"
android:layout_alignParentLeft="true"
android:visibility="visible">
<QuickContactBadge android:id="@+id/contact_photo_badge"
style="?android:attr/quickContactBadgeStyleWindowLarge"
android:visibility="gone" />
<ImageView android:id="@+id/contact_photo_image"
android:layout_width="60dp"
android:layout_height="60dp"
android:cropToPadding="true"
android:scaleType="centerCrop"
android:visibility="gone" />
</FrameLayout>
<TextView android:id="@+id/identity_name" <TextView android:id="@+id/identity_name"
android:layout_width="wrap_content" android:layout_width="wrap_content"
@ -13,8 +30,22 @@
android:layout_marginTop="6dip" android:layout_marginTop="6dip"
android:layout_marginRight="5dip" android:layout_marginRight="5dip"
android:layout_marginLeft="5dip" android:layout_marginLeft="5dip"
android:layout_alignTop="@id/contact_photo_frame"
android:layout_toRightOf="@id/contact_photo_frame"
android:layout_alignWithParentIfMissing="true"
android:ellipsize="marquee" android:ellipsize="marquee"
android:layout_alignParentLeft="true" android:textColor="#000000"/>
android:layout_centerVertical="true" />
<TextView android:id="@+id/fingerprint"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:textAppearance="?android:attr/textAppearanceSmall"
android:singleLine="true"
android:layout_marginBottom="10dip"
android:layout_marginLeft="5dip"
android:layout_alignBottom="@id/contact_photo_frame"
android:layout_toRightOf="@id/contact_photo_frame"
android:layout_toLeftOf="@id/date"
android:ellipsize="end" />
</org.thoughtcrime.securesms.IdentityKeyView> </org.thoughtcrime.securesms.IdentityKeyView>

@ -3,9 +3,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" <LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent" android:layout_width="fill_parent"
android:layout_height="fill_parent" android:layout_height="fill_parent"
android:orientation="vertical" android:orientation="vertical">
android:paddingLeft="16dip"
android:paddingRight="16dip">
<ListView android:id="@android:id/list" <ListView android:id="@android:id/list"
android:layout_width="fill_parent" android:layout_width="fill_parent"

@ -17,9 +17,12 @@
package org.thoughtcrime.securesms; package org.thoughtcrime.securesms;
import android.content.Context; import android.content.Context;
import android.os.Build;
import android.os.Handler; import android.os.Handler;
import android.util.AttributeSet; import android.util.AttributeSet;
import android.view.LayoutInflater; import android.view.View;
import android.widget.ImageView;
import android.widget.QuickContactBadge;
import android.widget.RelativeLayout; import android.widget.RelativeLayout;
import android.widget.TextView; import android.widget.TextView;
@ -37,7 +40,10 @@ public class IdentityKeyView extends RelativeLayout
implements Recipient.RecipientModifiedListener implements Recipient.RecipientModifiedListener
{ {
private TextView identityName; private TextView identityName;
private TextView fingerprint;
private QuickContactBadge contactBadge;
private ImageView contactImage;
private Recipients recipients; private Recipients recipients;
private IdentityKey identityKey; private IdentityKey identityKey;
@ -46,17 +52,28 @@ public class IdentityKeyView extends RelativeLayout
public IdentityKeyView(Context context) { public IdentityKeyView(Context context) {
super(context); super(context);
LayoutInflater li = (LayoutInflater)context.getSystemService(Context.LAYOUT_INFLATER_SERVICE);
li.inflate(R.layout.identity_key_view, this, true);
initializeResources();
} }
public IdentityKeyView(Context context, AttributeSet attributeSet) { public IdentityKeyView(Context context, AttributeSet attributeSet) {
super(context, attributeSet); super(context, attributeSet);
} }
@Override
public void onFinishInflate() {
this.identityName = (TextView)findViewById(R.id.identity_name);
this.fingerprint = (TextView)findViewById(R.id.fingerprint);
this.contactBadge = (QuickContactBadge)findViewById(R.id.contact_photo_badge);
this.contactImage = (ImageView)findViewById(R.id.contact_photo_image);
if (isBadgeEnabled()) {
this.contactBadge.setVisibility(View.VISIBLE);
this.contactImage.setVisibility(View.GONE);
} else {
this.contactBadge.setVisibility(View.GONE);
this.contactImage.setVisibility(View.VISIBLE);
}
}
public void set(IdentityDatabase.Identity identity) { public void set(IdentityDatabase.Identity identity) {
this.recipients = identity.getRecipients(); this.recipients = identity.getRecipients();
this.identityKey = identity.getIdentityKey(); this.identityKey = identity.getIdentityKey();
@ -64,14 +81,19 @@ public class IdentityKeyView extends RelativeLayout
this.recipients.addListener(this); this.recipients.addListener(this);
identityName.setText(recipients.toShortString()); identityName.setText(recipients.toShortString());
fingerprint.setText(identity.getIdentityKey().getFingerprint());
contactBadge.setImageBitmap(recipients.getPrimaryRecipient().getContactPhoto());
contactBadge.assignContactFromPhone(recipients.getPrimaryRecipient().getNumber(), true);
contactImage.setImageBitmap(recipients.getPrimaryRecipient().getContactPhoto());
} }
public IdentityKey getIdentityKey() { public IdentityKey getIdentityKey() {
return this.identityKey; return this.identityKey;
} }
private void initializeResources() { private boolean isBadgeEnabled() {
this.identityName = (TextView)findViewById(R.id.identity_name); return Build.VERSION.SDK_INT >= Build.VERSION_CODES.HONEYCOMB;
} }
@Override @Override

@ -66,10 +66,12 @@ public class ReviewIdentitiesFragment extends SherlockListFragment
private class IdentitiesListAdapter extends CursorAdapter { private class IdentitiesListAdapter extends CursorAdapter {
private final MasterSecret masterSecret; private final MasterSecret masterSecret;
private final LayoutInflater inflater;
public IdentitiesListAdapter(Context context, Cursor cursor, MasterSecret masterSecret) { public IdentitiesListAdapter(Context context, Cursor cursor, MasterSecret masterSecret) {
super(context, cursor); super(context, cursor);
this.masterSecret = masterSecret; this.masterSecret = masterSecret;
this.inflater = LayoutInflater.from(context);
} }
@Override @Override
@ -82,9 +84,7 @@ public class ReviewIdentitiesFragment extends SherlockListFragment
@Override @Override
public View newView(Context context, Cursor cursor, ViewGroup parent) { public View newView(Context context, Cursor cursor, ViewGroup parent) {
IdentityKeyView identityKeyView = new IdentityKeyView(context); return inflater.inflate(R.layout.identity_key_view, parent, false);
bindView(identityKeyView, context, cursor);
return identityKeyView;
} }
} }
} }
Loading…
Cancel
Save