Fix contact picture
This commit is contained in:
parent
4f58d19fa3
commit
14c8510398
11 changed files with 81 additions and 35 deletions
|
@ -34,6 +34,7 @@ public class ChatActivity extends FragmentActivity {
|
||||||
extras.putString("SipUri", getIntent().getExtras().getString("SipUri"));
|
extras.putString("SipUri", getIntent().getExtras().getString("SipUri"));
|
||||||
extras.putString("DisplayName", getIntent().getExtras().getString("DisplayName"));
|
extras.putString("DisplayName", getIntent().getExtras().getString("DisplayName"));
|
||||||
extras.putString("PictureUri", getIntent().getExtras().getString("PictureUri"));
|
extras.putString("PictureUri", getIntent().getExtras().getString("PictureUri"));
|
||||||
|
extras.putString("ThumbnailUri", getIntent().getExtras().getString("ThumbnailUri"));
|
||||||
|
|
||||||
ChatFragment fragment = new ChatFragment();
|
ChatFragment fragment = new ChatFragment();
|
||||||
fragment.setArguments(extras);
|
fragment.setArguments(extras);
|
||||||
|
|
|
@ -33,6 +33,7 @@ import org.linphone.core.LinphoneChatMessage.State;
|
||||||
import org.linphone.core.LinphoneChatRoom;
|
import org.linphone.core.LinphoneChatRoom;
|
||||||
import org.linphone.core.LinphoneContent;
|
import org.linphone.core.LinphoneContent;
|
||||||
import org.linphone.core.LinphoneCore;
|
import org.linphone.core.LinphoneCore;
|
||||||
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
import org.linphone.core.LinphoneCoreListenerBase;
|
import org.linphone.core.LinphoneCoreListenerBase;
|
||||||
import org.linphone.mediastream.Log;
|
import org.linphone.mediastream.Log;
|
||||||
|
@ -334,6 +335,20 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayChatHeader(String displayName, String pictureUri) {
|
private void displayChatHeader(String displayName, String pictureUri) {
|
||||||
|
LinphoneAddress lAddress;
|
||||||
|
try {
|
||||||
|
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
|
if (contact != null) {
|
||||||
|
LinphoneUtils.setImagePictureFromUri(getActivity(), contactPicture.getView(), contact.getPhotoUri(), contact.getThumbnailUri(), R.drawable.unknown_small);
|
||||||
|
|
||||||
|
} else {
|
||||||
|
contactPicture.setImageResource(R.drawable.unknown_small);
|
||||||
|
}
|
||||||
|
} catch (LinphoneCoreException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
if (displayName == null && getResources().getBoolean(R.bool.only_display_username_if_unknown) && LinphoneUtils.isSipAddress(sipUri)) {
|
||||||
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
contactName.setText(LinphoneUtils.getUsernameFromAddress(sipUri));
|
||||||
} else if (displayName == null) {
|
} else if (displayName == null) {
|
||||||
|
@ -342,11 +357,6 @@ public class ChatFragment extends Fragment implements OnClickListener, LinphoneC
|
||||||
contactName.setText(displayName);
|
contactName.setText(displayName);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (pictureUri != null) {
|
|
||||||
LinphoneUtils.setImagePictureFromUri(getActivity(), contactPicture.getView(), Uri.parse(pictureUri), R.drawable.unknown_small);
|
|
||||||
} else {
|
|
||||||
contactPicture.setImageResource(R.drawable.unknown_small);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri) {
|
public void changeDisplayedChat(String newSipUri, String displayName, String pictureUri) {
|
||||||
|
|
|
@ -365,7 +365,7 @@ public class ChatListFragment extends Fragment implements OnClickListener, OnIte
|
||||||
if (history != null && history.length > 0) {
|
if (history != null && history.length > 0) {
|
||||||
for (int i = history.length - 1; i >= 0; i--) {
|
for (int i = history.length - 1; i >= 0; i--) {
|
||||||
LinphoneChatMessage msg = history[i];
|
LinphoneChatMessage msg = history[i];
|
||||||
if (msg.getText() != null && msg.getText().length() > 0) {
|
if (msg.getText() != null && msg.getText().length() > 0 && msg.getFileTransferInformation() == null) {
|
||||||
message = msg.getText();
|
message = msg.getText();
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
|
@ -37,6 +37,7 @@ public class Contact implements Serializable {
|
||||||
private String id;
|
private String id;
|
||||||
private String name;
|
private String name;
|
||||||
private transient Uri photoUri;
|
private transient Uri photoUri;
|
||||||
|
private transient Uri thumbnailUri;
|
||||||
private transient Bitmap photo;
|
private transient Bitmap photo;
|
||||||
private List<String> numbersOrAddresses;
|
private List<String> numbersOrAddresses;
|
||||||
private boolean hasFriends;
|
private boolean hasFriends;
|
||||||
|
@ -46,23 +47,26 @@ public class Contact implements Serializable {
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.photoUri = null;
|
this.photoUri = null;
|
||||||
|
this.thumbnailUri = null;
|
||||||
this.hasFriends = false;
|
this.hasFriends = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contact(String id, String name, Uri photo) {
|
public Contact(String id, String name, Uri photo, Uri thumbnail) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.photoUri = photo;
|
this.photoUri = photo;
|
||||||
|
this.thumbnailUri = thumbnail;
|
||||||
this.photo = null;
|
this.photo = null;
|
||||||
this.hasFriends = false;
|
this.hasFriends = false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Contact(String id, String name, Uri photo, Bitmap picture) {
|
public Contact(String id, String name, Uri photo, Uri thumbnail, Bitmap picture) {
|
||||||
super();
|
super();
|
||||||
this.id = id;
|
this.id = id;
|
||||||
this.name = name;
|
this.name = name;
|
||||||
this.photoUri = photo;
|
this.photoUri = photo;
|
||||||
|
this.thumbnailUri = thumbnail;
|
||||||
this.photo = picture;
|
this.photo = picture;
|
||||||
this.hasFriends = false;
|
this.hasFriends = false;
|
||||||
}
|
}
|
||||||
|
@ -84,6 +88,10 @@ public class Contact implements Serializable {
|
||||||
return photoUri;
|
return photoUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public Uri getThumbnailUri() {
|
||||||
|
return thumbnailUri;
|
||||||
|
}
|
||||||
|
|
||||||
public Bitmap getPhoto() {
|
public Bitmap getPhoto() {
|
||||||
return photo;
|
return photo;
|
||||||
}
|
}
|
||||||
|
@ -96,7 +104,7 @@ public class Contact implements Serializable {
|
||||||
|
|
||||||
public void refresh(ContentResolver cr) {
|
public void refresh(ContentResolver cr) {
|
||||||
this.numbersOrAddresses = Compatibility.extractContactNumbersAndAddresses(id, cr);
|
this.numbersOrAddresses = Compatibility.extractContactNumbersAndAddresses(id, cr);
|
||||||
for(LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
for(LinphoneFriend friend : LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList()) {
|
||||||
if (friend.getRefKey().equals(id)) {
|
if (friend.getRefKey().equals(id)) {
|
||||||
hasFriends = true;
|
hasFriends = true;
|
||||||
this.numbersOrAddresses.add(friend.getAddress().asStringUriOnly());
|
this.numbersOrAddresses.add(friend.getAddress().asStringUriOnly());
|
||||||
|
|
|
@ -154,7 +154,7 @@ public class ContactsManager {
|
||||||
friend.setRefKey(contact.getID());
|
friend.setRefKey(contact.getID());
|
||||||
friend.done();
|
friend.done();
|
||||||
try {
|
try {
|
||||||
LinphoneManager.getLc().addFriend(friend);
|
LinphoneManager.getLcIfManagerNotDestroyedOrNull().addFriend(friend);
|
||||||
return true;
|
return true;
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
@ -174,7 +174,7 @@ public class ContactsManager {
|
||||||
oldSipUri = "sip:" + oldSipUri;
|
oldSipUri = "sip:" + oldSipUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneFriend friend = LinphoneManager.getLc().findFriendByAddress(oldSipUri);
|
LinphoneFriend friend = LinphoneManager.getLcIfManagerNotDestroyedOrNull().findFriendByAddress(oldSipUri);
|
||||||
if (friend != null) {
|
if (friend != null) {
|
||||||
friend.edit();
|
friend.edit();
|
||||||
try {
|
try {
|
||||||
|
@ -191,18 +191,18 @@ public class ContactsManager {
|
||||||
sipUri = "sip:" + sipUri;
|
sipUri = "sip:" + sipUri;
|
||||||
}
|
}
|
||||||
|
|
||||||
LinphoneFriend friend = LinphoneManager.getLc().findFriendByAddress(sipUri);
|
LinphoneFriend friend = LinphoneManager.getLcIfManagerNotDestroyedOrNull().findFriendByAddress(sipUri);
|
||||||
if (friend != null) {
|
if (friend != null) {
|
||||||
LinphoneManager.getLc().removeFriend(friend);
|
LinphoneManager.getLcIfManagerNotDestroyedOrNull().removeFriend(friend);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removeAllFriends(Contact contact) {
|
public void removeAllFriends(Contact contact) {
|
||||||
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
for (LinphoneFriend friend : LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList()) {
|
||||||
if (friend.getRefKey().equals(contact.getID())) {
|
if (friend.getRefKey().equals(contact.getID())) {
|
||||||
LinphoneManager.getLc().removeFriend(friend);
|
LinphoneManager.getLcIfManagerNotDestroyedOrNull().removeFriend(friend);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -256,8 +256,8 @@ public class ContactsManager {
|
||||||
|
|
||||||
public List<String> getContactsId(){
|
public List<String> getContactsId(){
|
||||||
List<String> ids = new ArrayList<String>();
|
List<String> ids = new ArrayList<String>();
|
||||||
if(LinphoneManager.getLc().getFriendList() == null) return null;
|
if(LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList() == null) return null;
|
||||||
for(LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
for(LinphoneFriend friend : LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList()) {
|
||||||
friend.edit();
|
friend.edit();
|
||||||
friend.enableSubscribes(false);
|
friend.enableSubscribes(false);
|
||||||
friend.done();
|
friend.done();
|
||||||
|
@ -342,8 +342,8 @@ public class ContactsManager {
|
||||||
if (sipUri.startsWith("sip:"))
|
if (sipUri.startsWith("sip:"))
|
||||||
sipUri = sipUri.substring(4);
|
sipUri = sipUri.substring(4);
|
||||||
|
|
||||||
if(LinphoneManager.getLc().getFriendList() != null && LinphoneManager.getLc().getFriendList().length > 0) {
|
if(LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList() != null && LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList().length > 0) {
|
||||||
for (LinphoneFriend friend : LinphoneManager.getLc().getFriendList()) {
|
for (LinphoneFriend friend : LinphoneManager.getLcIfManagerNotDestroyedOrNull().getFriendList()) {
|
||||||
if (friend.getAddress().equals(address)) {
|
if (friend.getAddress().equals(address)) {
|
||||||
return getContact(friend.getRefKey(), contentResolver);
|
return getContact(friend.getRefKey(), contentResolver);
|
||||||
}
|
}
|
||||||
|
@ -530,7 +530,7 @@ public class ContactsManager {
|
||||||
|
|
||||||
contact.refresh(contentResolver);
|
contact.refresh(contentResolver);
|
||||||
//Add tag to Linphone contact if it not existed
|
//Add tag to Linphone contact if it not existed
|
||||||
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (LinphoneActivity.isInstanciated() && LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
if (!isContactHasLinphoneTag(contact, contentResolver)) {
|
if (!isContactHasLinphoneTag(contact, contentResolver)) {
|
||||||
Compatibility.createLinphoneContactTag(context, contentResolver, contact,
|
Compatibility.createLinphoneContactTag(context, contentResolver, contact,
|
||||||
findRawContactID(contentResolver, String.valueOf(contact.getID())));
|
findRawContactID(contentResolver, String.valueOf(contact.getID())));
|
||||||
|
@ -547,7 +547,7 @@ public class ContactsManager {
|
||||||
continue;
|
continue;
|
||||||
|
|
||||||
//Remove linphone contact tag if the contact has no sip address
|
//Remove linphone contact tag if the contact has no sip address
|
||||||
if (LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
if (LinphoneActivity.isInstanciated() && LinphoneActivity.instance().getResources().getBoolean(R.bool.use_linphone_tag)) {
|
||||||
if (removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact, contentResolver)) {
|
if (removeContactTagIsNeeded(contact) && isContactHasLinphoneTag(contact, contentResolver)) {
|
||||||
removeLinphoneContactTag(contact);
|
removeLinphoneContactTag(contact);
|
||||||
}
|
}
|
||||||
|
|
|
@ -23,6 +23,7 @@ import java.util.Calendar;
|
||||||
import org.linphone.core.LinphoneAddress;
|
import org.linphone.core.LinphoneAddress;
|
||||||
import org.linphone.core.LinphoneCoreException;
|
import org.linphone.core.LinphoneCoreException;
|
||||||
import org.linphone.core.LinphoneCoreFactory;
|
import org.linphone.core.LinphoneCoreFactory;
|
||||||
|
import org.linphone.mediastream.Log;
|
||||||
import org.linphone.ui.AvatarWithShadow;
|
import org.linphone.ui.AvatarWithShadow;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
import android.annotation.SuppressLint;
|
||||||
|
@ -114,10 +115,10 @@ public class HistoryDetailFragment extends Fragment implements OnClickListener {
|
||||||
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
lAddress = LinphoneCoreFactory.instance().createLinphoneAddress(sipUri);
|
||||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(getActivity().getContentResolver(), lAddress);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(),contact.getPhotoUri(), R.drawable.unknown_small);
|
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(),contact.getPhotoUri(), contact.getThumbnailUri(), R.drawable.unknown_small);
|
||||||
view.findViewById(R.id.addContactRow).setVisibility(View.GONE);
|
view.findViewById(R.id.addContactRow).setVisibility(View.GONE);
|
||||||
} else {
|
} else {
|
||||||
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(),null ,R.drawable.unknown_small);
|
LinphoneUtils.setImagePictureFromUri(view.getContext(), contactPicture.getView(),null, null ,R.drawable.unknown_small);
|
||||||
}
|
}
|
||||||
} catch (LinphoneCoreException e) {
|
} catch (LinphoneCoreException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
|
|
|
@ -1301,9 +1301,9 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
|
LinearLayout imageView = (LinearLayout) inflater.inflate(R.layout.active_call_image_row, container, false);
|
||||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(imageView.getContext().getContentResolver(), lAddress);
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(imageView.getContext().getContentResolver(), lAddress);
|
||||||
if(contact != null) {
|
if(contact != null) {
|
||||||
displayOrHideContactPicture(imageView, contact.getPhotoUri(), false);
|
displayOrHideContactPicture(imageView, contact.getPhotoUri(), contact.getThumbnailUri(), false);
|
||||||
} else {
|
} else {
|
||||||
displayOrHideContactPicture(imageView, null, false);
|
displayOrHideContactPicture(imageView, null, null, false);
|
||||||
}
|
}
|
||||||
callsList.addView(imageView);
|
callsList.addView(imageView);
|
||||||
|
|
||||||
|
@ -1366,10 +1366,10 @@ public class InCallActivity extends FragmentActivity implements OnClickListener
|
||||||
return isCallPaused || isInConference;
|
return isCallPaused || isInConference;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, boolean hide) {
|
private void displayOrHideContactPicture(LinearLayout callView, Uri pictureUri, Uri thumbnailUri, boolean hide) {
|
||||||
AvatarWithShadow contactPicture = (AvatarWithShadow) callView.findViewById(R.id.contactPicture);
|
AvatarWithShadow contactPicture = (AvatarWithShadow) callView.findViewById(R.id.contactPicture);
|
||||||
if (pictureUri != null) {
|
if (pictureUri != null) {
|
||||||
LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(), Uri.parse(pictureUri.toString()), R.drawable.unknown_small);
|
LinphoneUtils.setImagePictureFromUri(callView.getContext(), contactPicture.getView(), Uri.parse(pictureUri.toString()), thumbnailUri, R.drawable.unknown_small);
|
||||||
}
|
}
|
||||||
callView.setVisibility(hide ? View.GONE : View.VISIBLE);
|
callView.setVisibility(hide ? View.GONE : View.VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
|
@ -125,7 +125,8 @@ public class IncomingCallActivity extends Activity implements LinphoneSliderTrig
|
||||||
LinphoneAddress address = mCall.getRemoteAddress();
|
LinphoneAddress address = mCall.getRemoteAddress();
|
||||||
// May be greatly sped up using a drawable cache
|
// May be greatly sped up using a drawable cache
|
||||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), address);
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), address);
|
||||||
LinphoneUtils.setImagePictureFromUri(this, mPictureView.getView(), contact != null ? contact.getPhotoUri() : null, R.drawable.unknown_small);
|
LinphoneUtils.setImagePictureFromUri(this, mPictureView.getView(), contact != null ? contact.getPhotoUri() : null,
|
||||||
|
contact != null ? contact.getThumbnailUri() : null, R.drawable.unknown_small);
|
||||||
|
|
||||||
// To be done after findUriPictureOfContactAndSetDisplayName called
|
// To be done after findUriPictureOfContactAndSetDisplayName called
|
||||||
mNameView.setText(contact != null ? contact.getName() : "");
|
mNameView.setText(contact != null ? contact.getName() : "");
|
||||||
|
|
|
@ -613,7 +613,13 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
}
|
}
|
||||||
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
|
Contact contact = ContactsManager.getInstance().findContactWithAddress(getContentResolver(), lAddress);
|
||||||
String displayName = contact != null ? contact.getName() : null;
|
String displayName = contact != null ? contact.getName() : null;
|
||||||
String pictureUri = contact != null && contact.getPhotoUri() != null ? contact.getPhotoUri().toString() : null;
|
|
||||||
|
String pictureUri = null;
|
||||||
|
String thumbnailUri = null;
|
||||||
|
if(contact != null && contact.getPhotoUri() != null){
|
||||||
|
pictureUri = contact.getPhotoUri().toString();
|
||||||
|
thumbnailUri = contact.getThumbnailUri().toString();
|
||||||
|
}
|
||||||
|
|
||||||
if (isTablet()){
|
if (isTablet()){
|
||||||
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT){
|
if (currentFragment == FragmentsAvailable.CHATLIST || currentFragment == FragmentsAvailable.CHAT){
|
||||||
|
@ -624,9 +630,10 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
} else {
|
} else {
|
||||||
Bundle extras = new Bundle();
|
Bundle extras = new Bundle();
|
||||||
extras.putString("SipUri", sipUri);
|
extras.putString("SipUri", sipUri);
|
||||||
if (lAddress.getDisplayName() != null) {
|
if (contact != null) {
|
||||||
extras.putString("DisplayName", displayName);
|
extras.putString("DisplayName", displayName);
|
||||||
extras.putString("PictureUri", pictureUri);
|
extras.putString("PictureUri", pictureUri);
|
||||||
|
extras.putString("ThumbnailUri", thumbnailUri);
|
||||||
}
|
}
|
||||||
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
changeCurrentFragment(FragmentsAvailable.CHAT, extras);
|
||||||
}
|
}
|
||||||
|
@ -639,7 +646,8 @@ public class LinphoneActivity extends FragmentActivity implements OnClickListene
|
||||||
intent.putExtra("SipUri", sipUri);
|
intent.putExtra("SipUri", sipUri);
|
||||||
if (contact != null) {
|
if (contact != null) {
|
||||||
intent.putExtra("DisplayName", contact.getName());
|
intent.putExtra("DisplayName", contact.getName());
|
||||||
intent.putExtra("PictureUri", contact.getPhotoUri());
|
intent.putExtra("PictureUri", pictureUri);
|
||||||
|
intent.putExtra("ThumbnailUri", thumbnailUri);
|
||||||
}
|
}
|
||||||
startOrientationSensor();
|
startOrientationSensor();
|
||||||
startActivityForResult(intent, CHAT_ACTIVITY);
|
startActivityForResult(intent, CHAT_ACTIVITY);
|
||||||
|
|
|
@ -58,6 +58,7 @@ import android.net.ConnectivityManager;
|
||||||
import android.net.NetworkInfo;
|
import android.net.NetworkInfo;
|
||||||
import android.net.Uri;
|
import android.net.Uri;
|
||||||
import android.os.Build;
|
import android.os.Build;
|
||||||
|
import android.provider.MediaStore;
|
||||||
import android.telephony.TelephonyManager;
|
import android.telephony.TelephonyManager;
|
||||||
import android.util.TypedValue;
|
import android.util.TypedValue;
|
||||||
import android.view.KeyEvent;
|
import android.view.KeyEvent;
|
||||||
|
@ -158,7 +159,7 @@ public final class LinphoneUtils {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
public static void setImagePictureFromUri(Context c, ImageView view, Uri uri, int notFoundResource) {
|
public static void setImagePictureFromUri(Context c, ImageView view, Uri uri, Uri tUri, int notFoundResource) {
|
||||||
if (uri == null) {
|
if (uri == null) {
|
||||||
view.setImageResource(notFoundResource);
|
view.setImageResource(notFoundResource);
|
||||||
return;
|
return;
|
||||||
|
@ -169,7 +170,17 @@ public final class LinphoneUtils {
|
||||||
view.setImageBitmap(bm);
|
view.setImageBitmap(bm);
|
||||||
} else {
|
} else {
|
||||||
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
|
if (Version.sdkAboveOrEqual(Version.API06_ECLAIR_201)) {
|
||||||
view.setImageURI(uri);
|
Bitmap bm = null;
|
||||||
|
try {
|
||||||
|
bm = MediaStore.Images.Media.getBitmap(c.getContentResolver(),uri);
|
||||||
|
} catch (IOException e) {
|
||||||
|
if(tUri != null){
|
||||||
|
view.setImageURI(tUri);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if(bm != null) {
|
||||||
|
view.setImageBitmap(bm);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
@SuppressWarnings("deprecation")
|
@SuppressWarnings("deprecation")
|
||||||
Bitmap bitmap = android.provider.Contacts.People.loadContactPhoto(c, uri, notFoundResource, null);
|
Bitmap bitmap = android.provider.Contacts.People.loadContactPhoto(c, uri, notFoundResource, null);
|
||||||
|
|
|
@ -216,7 +216,8 @@ public class ApiFivePlus {
|
||||||
|
|
||||||
String id = cursor.getString(cursor.getColumnIndex(Data.CONTACT_ID));
|
String id = cursor.getString(cursor.getColumnIndex(Data.CONTACT_ID));
|
||||||
String name = getContactDisplayName(cursor);
|
String name = getContactDisplayName(cursor);
|
||||||
Uri photo = getContactPictureUri(id);
|
Uri thumbnail = getContactPictureUri(id);
|
||||||
|
Uri photo = getContactPhotoUri(id);
|
||||||
InputStream input = getContactPictureInputStream(cr, id);
|
InputStream input = getContactPictureInputStream(cr, id);
|
||||||
|
|
||||||
Contact contact;
|
Contact contact;
|
||||||
|
@ -228,7 +229,7 @@ public class ApiFivePlus {
|
||||||
try {
|
try {
|
||||||
bm = BitmapFactory.decodeStream(input);
|
bm = BitmapFactory.decodeStream(input);
|
||||||
} catch (OutOfMemoryError oome) {}
|
} catch (OutOfMemoryError oome) {}
|
||||||
contact = new Contact(id, name, photo, bm);
|
contact = new Contact(id, name, photo, thumbnail, bm);
|
||||||
}
|
}
|
||||||
|
|
||||||
return contact;
|
return contact;
|
||||||
|
@ -248,6 +249,11 @@ public class ApiFivePlus {
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Uri getContactPictureUri(String id) {
|
private static Uri getContactPictureUri(String id) {
|
||||||
|
Uri person = ContentUris.withAppendedId(Contacts.CONTENT_URI, Long.parseLong(id));
|
||||||
|
return Uri.withAppendedPath(person, Contacts.Photo.CONTENT_DIRECTORY);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static Uri getContactPhotoUri(String id) {
|
||||||
Uri person = ContentUris.withAppendedId(Contacts.CONTENT_URI, Long.parseLong(id));
|
Uri person = ContentUris.withAppendedId(Contacts.CONTENT_URI, Long.parseLong(id));
|
||||||
return Uri.withAppendedPath(person, Contacts.Photo.DISPLAY_PHOTO);
|
return Uri.withAppendedPath(person, Contacts.Photo.DISPLAY_PHOTO);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue