Use larger version of ic_contact_picture in calls

Closes #4971
Fixes #4245
// FREEBIE
This commit is contained in:
haffenloher 2015-12-27 01:34:44 +01:00 committed by Moxie Marlinspike
parent 1e2a45d440
commit 1abf39685a
9 changed files with 35 additions and 22 deletions

Binary file not shown.

After

Width:  |  Height:  |  Size: 4.7 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 6.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 10 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 14 KiB

View File

@ -40,10 +40,12 @@
<!-- Contact photo for call_info_1 -->
<ImageView android:id="@+id/photo"
android:layout_alignParentTop="true"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/call_banner_1"
android:layout_marginBottom="@dimen/in_call_button_height"
android:gravity="top|center_horizontal"
android:background="@android:color/black"
android:scaleType="centerCrop"
/>
@ -140,23 +142,6 @@
</RelativeLayout> <!-- End of call_banner for call_info #1. -->
<!-- "Inset" photo used with "id/photo" above:
When the contact photo is a lo-res thumbnail, id/photo
contains a scaled-up but *blurred* version of the photo, and
*this* ImageView is overlaid on top as a smaller, unblurred
inset. (See InCallContactPhoto.java.)
The top of the inset is vertically aligned with the bottom
of the call banner. (Note that means that in states where the
"call state label" is visible, the label (see below) will overlap
the top of the inset photo.) -->
<ImageView android:id="@+id/insetPhoto"
android:layout_below="@id/call_banner_1"
android:layout_width="180dp"
android:layout_height="180dp"
android:scaleType="centerCrop"
android:layout_marginLeft="0dp"
/>
<!-- The "call state label": In some states, this shows a special
indication like "Dialing" or "Incoming call" or "Call ended".
It's unused for the normal case of an active ongoing call. -->

View File

@ -18,13 +18,20 @@
package org.thoughtcrime.redphone.ui;
import android.content.Context;
import android.net.Uri;
import android.os.AsyncTask;
import android.provider.ContactsContract;
import android.util.AttributeSet;
import android.util.DisplayMetrics;
import android.view.LayoutInflater;
import android.view.WindowManager;
import android.widget.ImageView;
import android.widget.LinearLayout;
import android.widget.TextView;
import org.thoughtcrime.securesms.R;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhoto;
import org.thoughtcrime.securesms.contacts.avatars.ContactPhotoFactory;
import org.thoughtcrime.securesms.recipients.Recipient;
/**
@ -62,8 +69,25 @@ public class CallCard extends LinearLayout {
this.elapsedTime.setText(time);
}
private void setPersonInfo(Recipient recipient) {
this.photo.setImageDrawable(recipient.getContactPhoto().asCallCard(getContext()));
private void setPersonInfo(final Recipient recipient) {
final Context context = getContext();
new AsyncTask<Void, Void, ContactPhoto>() {
@Override
protected ContactPhoto doInBackground(Void... params) {
DisplayMetrics metrics = new DisplayMetrics();
WindowManager windowManager = (WindowManager) context.getSystemService(Context.WINDOW_SERVICE);
Uri contentUri = ContactsContract.Contacts.lookupContact(context.getContentResolver(),
recipient.getContactUri());
windowManager.getDefaultDisplay().getMetrics(metrics);
return ContactPhotoFactory.getContactPhoto(context, contentUri, null, metrics.widthPixels);
}
@Override
protected void onPostExecute(final ContactPhoto contactPhoto) {
CallCard.this.photo.setImageDrawable(contactPhoto.asCallCard(context));
}
}.execute();
this.name.setText(recipient.getName());
this.phoneNumber.setText(recipient.getNumber());
}

View File

@ -37,8 +37,12 @@ public class ContactPhotoFactory {
}
public static ContactPhoto getContactPhoto(Context context, Uri uri, String name) {
int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
return getContactPhoto(context, uri, name, targetSize);
}
public static ContactPhoto getContactPhoto(Context context, Uri uri, String name, int targetSize) {
try {
int targetSize = context.getResources().getDimensionPixelSize(R.dimen.contact_photo_target_size);
Bitmap bitmap = Glide.with(context)
.load(new ContactPhotoUri(uri)).asBitmap()
.centerCrop().into(targetSize, targetSize).get();

View File

@ -48,6 +48,6 @@ public class GeneratedContactPhoto implements ContactPhoto {
@Override
public Drawable asCallCard(Context context) {
return ContextCompat.getDrawable(context, R.drawable.ic_contact_picture);
return ContextCompat.getDrawable(context, R.drawable.ic_contact_picture_large);
}
}