mirror of
https://github.com/oxen-io/session-android.git
synced 2024-11-23 18:15:22 +00:00
Use larger version of ic_contact_picture in calls
Closes #4971 Fixes #4245 // FREEBIE
This commit is contained in:
parent
1e2a45d440
commit
1abf39685a
BIN
res/drawable-hdpi/ic_contact_picture_large.png
Normal file
BIN
res/drawable-hdpi/ic_contact_picture_large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 4.7 KiB |
BIN
res/drawable-mdpi/ic_contact_picture_large.png
Normal file
BIN
res/drawable-mdpi/ic_contact_picture_large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.1 KiB |
BIN
res/drawable-xhdpi/ic_contact_picture_large.png
Normal file
BIN
res/drawable-xhdpi/ic_contact_picture_large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 6.3 KiB |
BIN
res/drawable-xxhdpi/ic_contact_picture_large.png
Normal file
BIN
res/drawable-xxhdpi/ic_contact_picture_large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 10 KiB |
BIN
res/drawable-xxxhdpi/ic_contact_picture_large.png
Normal file
BIN
res/drawable-xxxhdpi/ic_contact_picture_large.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 14 KiB |
@ -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. -->
|
||||
|
@ -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());
|
||||
}
|
||||
|
@ -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();
|
||||
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user