private void updateInterfaceForCurrentMessage(int move) { if (actionBar == null) { return; } currentChat = null; currentUser = null; long dialog_id = currentMessageObject.getDialogId(); chatActivityEnterView.setDialogId(dialog_id); if ((int) dialog_id != 0) { int lower_id = (int) dialog_id; if (lower_id > 0) { currentUser = MessagesController.getInstance().getUser(lower_id); } else { currentChat = MessagesController.getInstance().getChat(-lower_id); currentUser = MessagesController.getInstance().getUser(currentMessageObject.messageOwner.from_id); } } else { TLRPC.EncryptedChat encryptedChat = MessagesController.getInstance().getEncryptedChat((int) (dialog_id >> 32)); currentUser = MessagesController.getInstance().getUser(encryptedChat.user_id); } if (currentChat != null && currentUser != null) { nameTextView.setText(currentChat.title); onlineTextView.setText( ContactsController.formatName(currentUser.first_name, currentUser.last_name)); nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); nameTextView.setCompoundDrawablePadding(0); } else if (currentUser != null) { nameTextView.setText( ContactsController.formatName(currentUser.first_name, currentUser.last_name)); if ((int) dialog_id == 0) { nameTextView.setCompoundDrawablesWithIntrinsicBounds(R.drawable.ic_lock_white, 0, 0, 0); nameTextView.setCompoundDrawablePadding(AndroidUtilities.dp(4)); } else { nameTextView.setCompoundDrawablesWithIntrinsicBounds(0, 0, 0, 0); nameTextView.setCompoundDrawablePadding(0); } } prepareLayouts(move); updateSubtitle(); checkAndUpdateAvatar(); applyViewsLayoutParams(0); }
private void updateSubtitle() { if (actionBar == null) { return; } if (currentChat != null || currentUser == null) { return; } if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance().contactsDict.get(currentUser.id) == null && (ContactsController.getInstance().contactsDict.size() != 0 || !ContactsController.getInstance().isLoadingContacts())) { if (currentUser.phone != null && currentUser.phone.length() != 0) { nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone)); } else { nameTextView.setText( ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } } else { nameTextView.setText( ContactsController.formatName(currentUser.first_name, currentUser.last_name)); } CharSequence printString = MessagesController.getInstance().printingStrings.get(currentMessageObject.getDialogId()); if (printString == null || printString.length() == 0) { lastPrintString = null; setTypingAnimation(false); TLRPC.User user = MessagesController.getInstance().getUser(currentUser.id); if (user != null) { currentUser = user; } onlineTextView.setText(LocaleController.formatUserStatus(currentUser)); } else { lastPrintString = printString; onlineTextView.setText(printString); setTypingAnimation(true); } }
public XImageSpan createAndPutChipForUser(TLRPC.User user) { LayoutInflater lf = (LayoutInflater) ApplicationLoader.applicationContext.getSystemService(Activity.LAYOUT_INFLATER_SERVICE); View textView = lf.inflate(R.layout.group_create_bubble, null); TextView text = (TextView) textView.findViewById(R.id.bubble_text_view); String name = ContactsController.formatName(user.first_name, user.last_name); if (name.length() == 0 && user.phone != null && user.phone.length() != 0) { name = PhoneFormat.getInstance().format("+" + user.phone); } text.setText(name + ", "); int spec = View.MeasureSpec.makeMeasureSpec(0, View.MeasureSpec.UNSPECIFIED); textView.measure(spec, spec); textView.layout(0, 0, textView.getMeasuredWidth(), textView.getMeasuredHeight()); Bitmap b = Bitmap.createBitmap(textView.getWidth(), textView.getHeight(), Bitmap.Config.ARGB_8888); Canvas canvas = new Canvas(b); canvas.translate(-textView.getScrollX(), -textView.getScrollY()); textView.draw(canvas); textView.setDrawingCacheEnabled(true); Bitmap cacheBmp = textView.getDrawingCache(); Bitmap viewBmp = cacheBmp.copy(Bitmap.Config.ARGB_8888, true); textView.destroyDrawingCache(); final BitmapDrawable bmpDrawable = new BitmapDrawable(b); bmpDrawable.setBounds(0, 0, b.getWidth(), b.getHeight()); SpannableStringBuilder ssb = new SpannableStringBuilder(""); XImageSpan span = new XImageSpan(bmpDrawable, ImageSpan.ALIGN_BASELINE); allSpans.add(span); selectedContacts.put(user.id, span); for (ImageSpan sp : allSpans) { ssb.append("<<"); ssb.setSpan( sp, ssb.length() - 2, ssb.length(), SpannableStringBuilder.SPAN_EXCLUSIVE_EXCLUSIVE); } userSelectEditText.setText(ssb); userSelectEditText.setSelection(ssb.length()); return span; }
@Override public View getItemView(int section, int position, View convertView, ViewGroup parent) { TLRPC.User user; int size; if (searchWas && searching) { user = MessagesController.getInstance().getUser(searchResult.get(position).id); size = searchResult.size(); } else { ArrayList<TLRPC.TL_contact> arr = ContactsController.getInstance() .usersSectionsDict .get(ContactsController.getInstance().sortedUsersSectionsArray.get(section)); user = MessagesController.getInstance().getUser(arr.get(position).user_id); size = arr.size(); } if (convertView == null) { LayoutInflater li = (LayoutInflater) mContext.getSystemService(Context.LAYOUT_INFLATER_SERVICE); convertView = li.inflate(R.layout.group_create_row_layout, parent, false); } ContactListRowHolder holder = (ContactListRowHolder) convertView.getTag(); if (holder == null) { holder = new ContactListRowHolder(convertView); convertView.setTag(holder); } ImageView checkButton = (ImageView) convertView.findViewById(R.id.settings_row_check_button); if (selectedContacts.containsKey(user.id)) { checkButton.setImageResource(R.drawable.btn_check_on_holo_light); } else { checkButton.setImageResource(R.drawable.btn_check_off_holo_light); } View divider = convertView.findViewById(R.id.settings_row_divider); if (position == size - 1) { divider.setVisibility(View.INVISIBLE); } else { divider.setVisibility(View.VISIBLE); } if (searchWas && searching) { holder.nameTextView.setText(searchResultNames.get(position)); } else { String name = ContactsController.formatName(user.first_name, user.last_name); if (name.length() == 0) { if (user.phone != null && user.phone.length() != 0) { name = PhoneFormat.getInstance().format("+" + user.phone); } else { name = LocaleController.getString("HiddenName", R.string.HiddenName); } } holder.nameTextView.setText(name); } TLRPC.FileLocation photo = null; if (user.photo != null) { photo = user.photo.photo_small; } int placeHolderId = AndroidUtilities.getUserAvatarForId(user.id); holder.avatarImage.setImage(photo, "50_50", placeHolderId); holder.messageTextView.setText(LocaleController.formatUserStatus(user)); if (user.status != null && user.status.expires > ConnectionsManager.getInstance().getCurrentTime()) { holder.messageTextView.setTextColor(0xff357aa8); } else { holder.messageTextView.setTextColor(0xff808080); } return convertView; }