use of android.widget.QuickContactBadge in project android_packages_apps_Dialer by LineageOS.
the class ContactEntryListAdapter method bindQuickContact.
// TODO: move sharable logic (bindXX() methods) to here with extra arguments
/**
* Loads the photo for the quick contact view and assigns the contact uri.
*
* @param photoIdColumn Index of the photo id column
* @param photoUriColumn Index of the photo uri column. Optional: Can be -1
* @param contactIdColumn Index of the contact id column
* @param lookUpKeyColumn Index of the lookup key column
* @param displayNameColumn Index of the display name column
*/
protected void bindQuickContact(final ContactListItemView view, int partitionIndex, Cursor cursor, int photoIdColumn, int photoUriColumn, int contactIdColumn, int lookUpKeyColumn, int displayNameColumn) {
long photoId = 0;
if (!cursor.isNull(photoIdColumn)) {
photoId = cursor.getLong(photoIdColumn);
}
QuickContactBadge quickContact = view.getQuickContact();
quickContact.assignContactUri(getContactUri(partitionIndex, cursor, contactIdColumn, lookUpKeyColumn));
if (CompatUtils.hasPrioritizedMimeType()) {
// The Contacts app never uses the QuickContactBadge. Therefore, it is safe to assume
// that only Dialer will use this QuickContact badge. This means prioritizing the phone
// mimetype here is reasonable.
quickContact.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
}
Logger.get(mContext).logQuickContactOnTouch(quickContact, InteractionEvent.Type.OPEN_QUICK_CONTACT_FROM_SEARCH, true);
if (photoId != 0 || photoUriColumn == -1) {
getPhotoLoader().loadThumbnail(quickContact, photoId, mDarkTheme, mCircularPhotos, null);
} else {
final String photoUriString = cursor.getString(photoUriColumn);
final Uri photoUri = photoUriString == null ? null : Uri.parse(photoUriString);
DefaultImageRequest request = null;
if (photoUri == null) {
request = getDefaultImageRequestFromCursor(cursor, displayNameColumn, lookUpKeyColumn);
}
getPhotoLoader().loadPhoto(quickContact, photoUri, -1, mDarkTheme, mCircularPhotos, request);
}
}
use of android.widget.QuickContactBadge in project android_packages_apps_Dialer by MoKee.
the class NumbersAdapter method updateView.
public void updateView(View view, String number, String countryIso) {
final TextView callerName = (TextView) view.findViewById(R.id.caller_name);
final TextView callerNumber = (TextView) view.findViewById(R.id.caller_number);
final QuickContactBadge quickContactBadge = (QuickContactBadge) view.findViewById(R.id.quick_contact_photo);
quickContactBadge.setOverlay(null);
if (CompatUtils.hasPrioritizedMimeType()) {
quickContactBadge.setPrioritizedMimeType(Phone.CONTENT_ITEM_TYPE);
}
ContactInfo info = mContactInfoHelper.lookupNumber(number, countryIso);
if (info == null) {
info = new ContactInfo();
info.number = number;
}
final CharSequence locationOrType = getNumberTypeOrLocation(info);
final String displayNumber = getDisplayNumber(info);
final String displayNumberStr = mBidiFormatter.unicodeWrap(displayNumber, TextDirectionHeuristics.LTR);
String nameForDefaultImage;
if (!TextUtils.isEmpty(info.name)) {
nameForDefaultImage = info.name;
callerName.setText(info.name);
callerNumber.setText(locationOrType + " " + displayNumberStr);
} else {
nameForDefaultImage = displayNumber;
callerName.setText(displayNumberStr);
if (!TextUtils.isEmpty(locationOrType)) {
callerNumber.setText(locationOrType);
callerNumber.setVisibility(View.VISIBLE);
} else {
callerNumber.setVisibility(View.GONE);
}
}
loadContactPhoto(info, nameForDefaultImage, quickContactBadge);
}
use of android.widget.QuickContactBadge in project android_packages_apps_Dialer by MoKee.
the class CallLogListItemViewHolder method createForTest.
@NeededForTesting
public static CallLogListItemViewHolder createForTest(Context context) {
Resources resources = context.getResources();
CallLogCache callLogCache = CallLogCache.getCallLogCache(context);
PhoneCallDetailsHelper phoneCallDetailsHelper = new PhoneCallDetailsHelper(context, resources, callLogCache);
CallLogListItemViewHolder viewHolder = new CallLogListItemViewHolder(context, null, null, /* expandCollapseListener */
callLogCache, new CallLogListItemHelper(phoneCallDetailsHelper, resources, callLogCache), null, /* voicemailPlaybackPresenter */
null, /* filteredNumberAsyncQueryHandler */
null, /* filteredNumberDialogCallback */
new View(context), new QuickContactBadge(context), new View(context), PhoneCallDetailsViews.createForTest(context), new CardView(context), new TextView(context), new ImageView(context), false);
viewHolder.detailsButtonView = new TextView(context);
viewHolder.actionsView = new View(context);
viewHolder.voicemailPlaybackView = new VoicemailPlaybackLayout(context);
viewHolder.workIconView = new ImageButton(context);
viewHolder.userMarkButtonView = new TextView(context);
return viewHolder;
}
use of android.widget.QuickContactBadge in project Etar-Calendar by Etar-Group.
the class AttendeesView method updateAttendeeView.
/**
* Set up each element in {@link AttendeeItem#mView} using the latest information. View
* object is reused.
*/
private View updateAttendeeView(AttendeeItem item) {
final Attendee attendee = item.mAttendee;
final View view = item.mView;
final TextView nameView = (TextView) view.findViewById(R.id.name);
nameView.setText(TextUtils.isEmpty(attendee.mName) ? attendee.mEmail : attendee.mName);
if (item.mRemoved) {
nameView.setPaintFlags(Paint.STRIKE_THRU_TEXT_FLAG | nameView.getPaintFlags());
} else {
nameView.setPaintFlags((~Paint.STRIKE_THRU_TEXT_FLAG) & nameView.getPaintFlags());
}
// Set up the Image button even if the view is disabled
// Everything will be ready when the view is enabled later
final ImageButton button = (ImageButton) view.findViewById(R.id.contact_remove);
button.setVisibility(isEnabled() ? View.VISIBLE : View.GONE);
button.setTag(item);
if (item.mRemoved) {
button.setImageResource(R.drawable.ic_menu_add_field_holo_light);
button.setContentDescription(mContext.getString(R.string.accessibility_add_attendee));
} else {
button.setImageResource(R.drawable.ic_menu_remove_field_holo_light);
button.setContentDescription(mContext.getString(R.string.accessibility_remove_attendee));
}
button.setOnClickListener(this);
final QuickContactBadge badgeView = (QuickContactBadge) view.findViewById(R.id.badge);
Drawable badge = null;
// Search for photo in recycled photos
if (mRecycledPhotos != null) {
badge = mRecycledPhotos.get(item.mAttendee.mEmail);
}
if (badge != null) {
item.mBadge = badge;
}
badgeView.setImageDrawable(item.mBadge);
if (item.mAttendee.mStatus == Attendees.ATTENDEE_STATUS_NONE) {
item.mBadge.setAlpha(mNoResponsePhotoAlpha);
} else {
item.mBadge.setAlpha(mDefaultPhotoAlpha);
}
if (item.mAttendee.mStatus == Attendees.ATTENDEE_STATUS_DECLINED) {
item.mBadge.setColorFilter(mGrayscaleFilter);
} else {
item.mBadge.setColorFilter(null);
}
// the lookup uri (yet), we can set Email and QuickContact will lookup once tapped.
if (item.mContactLookupUri != null) {
badgeView.assignContactUri(item.mContactLookupUri);
} else {
badgeView.assignContactFromEmail(item.mAttendee.mEmail, true);
}
badgeView.setMaxHeight(60);
return view;
}
use of android.widget.QuickContactBadge in project android_frameworks_base by DirtyUnicorns.
the class RenderSessionImpl method postInflateProcess.
/**
* Post process on a view hierarchy that was just inflated.
* <p/>
* At the moment this only supports TabHost: If {@link TabHost} is detected, look for the
* {@link TabWidget}, and the corresponding {@link FrameLayout} and make new tabs automatically
* based on the content of the {@link FrameLayout}.
* @param view the root view to process.
* @param layoutlibCallback callback to the project.
* @param skip the view and it's children are not processed.
*/
// For the use of Pair
@SuppressWarnings("deprecation")
private void postInflateProcess(View view, LayoutlibCallback layoutlibCallback, View skip) throws PostInflateException {
if (view == skip) {
return;
}
if (view instanceof TabHost) {
setupTabHost((TabHost) view, layoutlibCallback);
} else if (view instanceof QuickContactBadge) {
QuickContactBadge badge = (QuickContactBadge) view;
badge.setImageToDefault();
} else if (view instanceof AdapterView<?>) {
// get the view ID.
int id = view.getId();
BridgeContext context = getContext();
// get a ResourceReference from the integer ID.
ResourceReference listRef = context.resolveId(id);
if (listRef != null) {
SessionParams params = getParams();
AdapterBinding binding = params.getAdapterBindings().get(listRef);
// if there was no adapter binding, trying to get it from the call back.
if (binding == null) {
binding = layoutlibCallback.getAdapterBinding(listRef, context.getViewKey(view), view);
}
if (binding != null) {
if (view instanceof AbsListView) {
if ((binding.getFooterCount() > 0 || binding.getHeaderCount() > 0) && view instanceof ListView) {
ListView list = (ListView) view;
boolean skipCallbackParser = false;
int count = binding.getHeaderCount();
for (int i = 0; i < count; i++) {
Pair<View, Boolean> pair = context.inflateView(binding.getHeaderAt(i), list, false, skipCallbackParser);
if (pair.getFirst() != null) {
list.addHeaderView(pair.getFirst());
}
skipCallbackParser |= pair.getSecond();
}
count = binding.getFooterCount();
for (int i = 0; i < count; i++) {
Pair<View, Boolean> pair = context.inflateView(binding.getFooterAt(i), list, false, skipCallbackParser);
if (pair.getFirst() != null) {
list.addFooterView(pair.getFirst());
}
skipCallbackParser |= pair.getSecond();
}
}
if (view instanceof ExpandableListView) {
((ExpandableListView) view).setAdapter(new FakeExpandableAdapter(listRef, binding, layoutlibCallback));
} else {
((AbsListView) view).setAdapter(new FakeAdapter(listRef, binding, layoutlibCallback));
}
} else if (view instanceof AbsSpinner) {
((AbsSpinner) view).setAdapter(new FakeAdapter(listRef, binding, layoutlibCallback));
}
}
}
} else if (view instanceof ViewGroup) {
mInflater.postInflateProcess(view);
ViewGroup group = (ViewGroup) view;
final int count = group.getChildCount();
for (int c = 0; c < count; c++) {
View child = group.getChildAt(c);
postInflateProcess(child, layoutlibCallback, skip);
}
}
}
Aggregations