org.telegram.PhoneFormat.PhoneFormat Java Examples

The following examples show how to use org.telegram.PhoneFormat.PhoneFormat. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: ChatAttachAlertContactsLayout.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        UserCell userCell = (UserCell) holder.itemView;

        boolean divider = position != getItemCount() - 2;
        Object object = getItem(position);
        TLRPC.User user = null;
        if (object instanceof ContactsController.Contact) {
            ContactsController.Contact contact = (ContactsController.Contact) object;
            if (contact.user != null) {
                user = contact.user;
            } else {
                userCell.setCurrentId(contact.contact_id);
                userCell.setData(null, searchResultNames.get(position - 1), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), divider);
            }
        } else {
            user = (TLRPC.User) object;
        }
        if (user != null) {
            userCell.setData(user, searchResultNames.get(position - 1), PhoneFormat.getInstance().format("+" + user.phone), divider);
        }
    }
}
 
Example #2
Source File: PhonebookSearchAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        UserCell userCell = (UserCell) holder.itemView;

        Object object = getItem(position);
        TLRPC.User user = null;
        if (object instanceof ContactsController.Contact) {
            ContactsController.Contact contact = (ContactsController.Contact) object;
            if (contact.user != null) {
                user = contact.user;
            } else {
                userCell.setCurrentId(contact.contact_id);
                userCell.setData(null, searchResultNames.get(position), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0);
            }
        } else {
            user = (TLRPC.User) object;
        }
        if (user != null) {
            userCell.setData(user, searchResultNames.get(position), PhoneFormat.getInstance().format("+" + user.phone), 0);
        }
    }
}
 
Example #3
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position));
        if (user != null) {
            String number;
            if (user.bot) {
                number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
            } else if (user.phone != null && user.phone.length() != 0) {
                number = PhoneFormat.getInstance().format("+" + user.phone);
            } else {
                number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
            }
            ((UserCell) holder.itemView).setData(user, null, number, 0);
        }
    }
}
 
Example #4
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position));
        if (user != null) {
            String number;
            if (user.bot) {
                number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
            } else if (user.phone != null && user.phone.length() != 0) {
                number = PhoneFormat.getInstance().format("+" + user.phone);
            } else {
                number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
            }
            ((UserCell) holder.itemView).setData(user, null, number, 0);
        }
    }
}
 
Example #5
Source File: DrawerProfileCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user, boolean accounts) {
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    accountsShowed = accounts;
    arrowView.setImageResource(accountsShowed ? R.drawable.collapse_up : R.drawable.collapse_down);
    nameTextView.setText(UserObject.getUserName(user));
    phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    AvatarDrawable avatarDrawable = new AvatarDrawable(user);
    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example #6
Source File: PhonebookAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    switch (holder.getItemViewType()) {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            Object object = getItem(section, position);
            TLRPC.User user = null;
            if (object instanceof ContactsController.Contact) {
                ContactsController.Contact contact = (ContactsController.Contact) object;
                if (contact.user != null) {
                    user = contact.user;
                } else {
                    userCell.setCurrentId(contact.contact_id);
                    userCell.setData(null, ContactsController.formatName(contact.first_name, contact.last_name), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0);
                }
            } else {
                user = (TLRPC.User) object;
            }
            if (user != null) {
                userCell.setData(user, null, PhoneFormat.getInstance().format("+" + user.phone), 0);
            }
            break;
    }
}
 
Example #7
Source File: ContactAddActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
    if (user == null) {
        return;
    }
    nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));

    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    avatarImage.setImage(photo, "50_50", avatarDrawable = new AvatarDrawable(user));
}
 
Example #8
Source File: AndroidUtilities.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkPhonePattern(String pattern, String phone)
{
    if (TextUtils.isEmpty(pattern) || pattern.equals("*"))
    {
        return true;
    }
    String args[] = pattern.split("\\*");
    phone = PhoneFormat.stripExceptNumbers(phone);
    int checkStart = 0;
    int index;
    for (int a = 0; a < args.length; a++)
    {
        String arg = args[a];
        if (!TextUtils.isEmpty(arg))
        {
            if ((index = phone.indexOf(arg, checkStart)) == -1)
            {
                return false;
            }
            checkStart = index + arg.length();
        }
    }
    return true;
}
 
Example #9
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position));
        if (user != null) {
            String number;
            if (user.bot) {
                number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
            } else if (user.phone != null && user.phone.length() != 0) {
                number = PhoneFormat.getInstance().format("+" + user.phone);
            } else {
                number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
            }
            ((UserCell) holder.itemView).setData(user, null, number, 0);
        }
    }
}
 
Example #10
Source File: PhonebookSearchAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        UserCell userCell = (UserCell) holder.itemView;

        Object object = getItem(position);
        TLRPC.User user = null;
        if (object instanceof ContactsController.Contact) {
            ContactsController.Contact contact = (ContactsController.Contact) object;
            if (contact.user != null) {
                user = contact.user;
            } else {
                userCell.setCurrentId(contact.contact_id);
                userCell.setData(null, searchResultNames.get(position), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0);
            }
        } else {
            user = (TLRPC.User) object;
        }
        if (user != null) {
            userCell.setData(user, searchResultNames.get(position), PhoneFormat.getInstance().format("+" + user.phone), 0);
        }
    }
}
 
Example #11
Source File: PhonebookAdapter.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    switch (holder.getItemViewType()) {
        case 0:
            UserCell userCell = (UserCell) holder.itemView;
            Object object = getItem(section, position);
            TLRPC.User user = null;
            if (object instanceof ContactsController.Contact) {
                ContactsController.Contact contact = (ContactsController.Contact) object;
                if (contact.user != null) {
                    user = contact.user;
                } else {
                    userCell.setCurrentId(contact.contact_id);
                    userCell.setData(null, ContactsController.formatName(contact.first_name, contact.last_name), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), 0);
                }
            } else {
                user = (TLRPC.User) object;
            }
            if (user != null) {
                userCell.setData(user, null, PhoneFormat.getInstance().format("+" + user.phone), 0);
            }
            break;
    }
}
 
Example #12
Source File: BlockedUsersActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(MessagesController.getInstance(currentAccount).blockedUsers.keyAt(position));
        if (user != null) {
            String number;
            if (user.bot) {
                number = LocaleController.getString("Bot", R.string.Bot).substring(0, 1).toUpperCase() + LocaleController.getString("Bot", R.string.Bot).substring(1);
            } else if (user.phone != null && user.phone.length() != 0) {
                number = PhoneFormat.getInstance().format("+" + user.phone);
            } else {
                number = LocaleController.getString("NumberUnknown", R.string.NumberUnknown);
            }
            ((UserCell) holder.itemView).setData(user, null, number, 0);
        }
    }
}
 
Example #13
Source File: DrawerProfileCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public void setUser(TLRPC.User user, boolean accounts) {
    if (user == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    accountsShowed = accounts;
    arrowView.setImageResource(accountsShowed ? R.drawable.collapse_up : R.drawable.collapse_down);
    nameTextView.setText(UserObject.getUserName(user));
    phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    AvatarDrawable avatarDrawable = new AvatarDrawable(user);
    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example #14
Source File: AndroidUtilities.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkPhonePattern(String pattern, String phone) {
    if (TextUtils.isEmpty(pattern) || pattern.equals("*")) {
        return true;
    }
    String[] args = pattern.split("\\*");
    phone = PhoneFormat.stripExceptNumbers(phone);
    int checkStart = 0;
    int index;
    for (int a = 0; a < args.length; a++) {
        String arg = args[a];
        if (!TextUtils.isEmpty(arg)) {
            if ((index = phone.indexOf(arg, checkStart)) == -1) {
                return false;
            }
            checkStart = index + arg.length();
        }
    }
    return true;
}
 
Example #15
Source File: ContactAddActivity.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = getMessagesController().getUser(user_id);
    if (user == null) {
        return;
    }
    if (TextUtils.isEmpty(user.phone)) {
        nameTextView.setText(LocaleController.getString("MobileHidden", R.string.MobileHidden));
        infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileHiddenExceptionInfo", R.string.MobileHiddenExceptionInfo, UserObject.getFirstName(user))));
    } else {
        nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
        if (needAddException) {
            infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileVisibleInfo", R.string.MobileVisibleInfo, UserObject.getFirstName(user))));
        }
    }
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));
    avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable = new AvatarDrawable(user), user);
}
 
Example #16
Source File: ContactAddActivity.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(user_id);
    if (user == null) {
        return;
    }
    nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));

    TLRPC.FileLocation photo = null;
    if (user.photo != null) {
        photo = user.photo.photo_small;
    }
    avatarImage.setImage(photo, "50_50", avatarDrawable = new AvatarDrawable(user));
}
 
Example #17
Source File: ChatAttachAlertContactsLayout.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    if (holder.getItemViewType() == 0) {
        UserCell userCell = (UserCell) holder.itemView;
        Object object = getItem(section, position);
        TLRPC.User user = null;
        boolean divider = section != getSectionCount() - 2 || position != getCountForSection(section) - 1;
        if (object instanceof ContactsController.Contact) {
            ContactsController.Contact contact = (ContactsController.Contact) object;
            if (contact.user != null) {
                user = contact.user;
            } else {
                userCell.setCurrentId(contact.contact_id);
                userCell.setData(null, ContactsController.formatName(contact.first_name, contact.last_name), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), divider);
            }
        } else {
            user = (TLRPC.User) object;
        }
        if (user != null) {
            userCell.setData(user, null, PhoneFormat.getInstance().format("+" + user.phone), divider);
        }
    }
}
 
Example #18
Source File: AndroidUtilities.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkPhonePattern(String pattern, String phone)
{
    if (TextUtils.isEmpty(pattern) || pattern.equals("*"))
    {
        return true;
    }
    String args[] = pattern.split("\\*");
    phone = PhoneFormat.stripExceptNumbers(phone);
    int checkStart = 0;
    int index;
    for (int a = 0; a < args.length; a++)
    {
        String arg = args[a];
        if (!TextUtils.isEmpty(arg))
        {
            if ((index = phone.indexOf(arg, checkStart)) == -1)
            {
                return false;
            }
            checkStart = index + arg.length();
        }
    }
    return true;
}
 
Example #19
Source File: ChatAttachAlertContactsLayout.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(int section, int position, RecyclerView.ViewHolder holder) {
    if (holder.getItemViewType() == 0) {
        UserCell userCell = (UserCell) holder.itemView;
        Object object = getItem(section, position);
        TLRPC.User user = null;
        boolean divider = section != getSectionCount() - 2 || position != getCountForSection(section) - 1;
        if (object instanceof ContactsController.Contact) {
            ContactsController.Contact contact = (ContactsController.Contact) object;
            if (contact.user != null) {
                user = contact.user;
            } else {
                userCell.setCurrentId(contact.contact_id);
                userCell.setData(null, ContactsController.formatName(contact.first_name, contact.last_name), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), divider);
            }
        } else {
            user = (TLRPC.User) object;
        }
        if (user != null) {
            userCell.setData(user, null, PhoneFormat.getInstance().format("+" + user.phone), divider);
        }
    }
}
 
Example #20
Source File: ChatAttachAlertContactsLayout.java    From Telegram-FOSS with GNU General Public License v2.0 6 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    if (holder.getItemViewType() == 0) {
        UserCell userCell = (UserCell) holder.itemView;

        boolean divider = position != getItemCount() - 2;
        Object object = getItem(position);
        TLRPC.User user = null;
        if (object instanceof ContactsController.Contact) {
            ContactsController.Contact contact = (ContactsController.Contact) object;
            if (contact.user != null) {
                user = contact.user;
            } else {
                userCell.setCurrentId(contact.contact_id);
                userCell.setData(null, searchResultNames.get(position - 1), contact.phones.isEmpty() ? "" : PhoneFormat.getInstance().format(contact.phones.get(0)), divider);
            }
        } else {
            user = (TLRPC.User) object;
        }
        if (user != null) {
            userCell.setData(user, searchResultNames.get(position - 1), PhoneFormat.getInstance().format("+" + user.phone), divider);
        }
    }
}
 
Example #21
Source File: ContactAddActivity.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
private void updateAvatarLayout() {
    if (nameTextView == null) {
        return;
    }
    TLRPC.User user = getMessagesController().getUser(user_id);
    if (user == null) {
        return;
    }
    if (TextUtils.isEmpty(user.phone)) {
        nameTextView.setText(LocaleController.getString("MobileHidden", R.string.MobileHidden));
        infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileHiddenExceptionInfo", R.string.MobileHiddenExceptionInfo, UserObject.getFirstName(user))));
    } else {
        nameTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
        if (needAddException) {
            infoTextView.setText(AndroidUtilities.replaceTags(LocaleController.formatString("MobileVisibleInfo", R.string.MobileVisibleInfo, UserObject.getFirstName(user))));
        }
    }
    onlineTextView.setText(LocaleController.formatUserStatus(currentAccount, user));
    avatarImage.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable = new AvatarDrawable(user), user);
}
 
Example #22
Source File: AndroidUtilities.java    From Telegram with GNU General Public License v2.0 6 votes vote down vote up
public static boolean checkPhonePattern(String pattern, String phone) {
    if (TextUtils.isEmpty(pattern) || pattern.equals("*")) {
        return true;
    }
    String[] args = pattern.split("\\*");
    phone = PhoneFormat.stripExceptNumbers(phone);
    int checkStart = 0;
    int index;
    for (int a = 0; a < args.length; a++) {
        String arg = args[a];
        if (!TextUtils.isEmpty(arg)) {
            if ((index = phone.indexOf(arg, checkStart)) == -1) {
                return false;
            }
            checkStart = index + arg.length();
        }
    }
    return true;
}
 
Example #23
Source File: PopupNotificationActivity.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
private void updateSubtitle() {
    if (actionBar == null || currentMessageObject == null) {
        return;
    }
    if (currentChat != null || currentUser == null) {
        return;
    }
    if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.get(currentUser.id) == null && (ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.size() != 0 || !ContactsController.getInstance(currentMessageObject.currentAccount).isLoadingContacts())) {
        if (currentUser.phone != null && currentUser.phone.length() != 0) {
            nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        } else {
            nameTextView.setText(UserObject.getUserName(currentUser));
        }
    } else {
        nameTextView.setText(UserObject.getUserName(currentUser));
    }
    if (currentUser != null && currentUser.id == 777000) {
        onlineTextView.setText(LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications));
    } else {
        CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
        if (printString == null || printString.length() == 0) {
            lastPrintString = null;
            setTypingAnimation(false);
            TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
            if (user != null) {
                currentUser = user;
            }
            onlineTextView.setText(LocaleController.formatUserStatus(currentMessageObject.currentAccount, currentUser));
        } else {
            lastPrintString = printString;
            onlineTextView.setText(printString);
            setTypingAnimation(true);
        }
    }
}
 
Example #24
Source File: PopupNotificationActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private void updateSubtitle() {
    if (actionBar == null || currentMessageObject == null) {
        return;
    }
    if (currentChat != null || currentUser == null) {
        return;
    }
    if (currentUser.id / 1000 != 777 && currentUser.id / 1000 != 333 && ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.get(currentUser.id) == null && (ContactsController.getInstance(currentMessageObject.currentAccount).contactsDict.size() != 0 || !ContactsController.getInstance(currentMessageObject.currentAccount).isLoadingContacts())) {
        if (currentUser.phone != null && currentUser.phone.length() != 0) {
            nameTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        } else {
            nameTextView.setText(UserObject.getUserName(currentUser));
        }
    } else {
        nameTextView.setText(UserObject.getUserName(currentUser));
    }
    if (currentUser != null && currentUser.id == 777000) {
        onlineTextView.setText(LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications));
    } else {
        CharSequence printString = MessagesController.getInstance(currentMessageObject.currentAccount).printingStrings.get(currentMessageObject.getDialogId());
        if (printString == null || printString.length() == 0) {
            lastPrintString = null;
            setTypingAnimation(false);
            TLRPC.User user = MessagesController.getInstance(currentMessageObject.currentAccount).getUser(currentUser.id);
            if (user != null) {
                currentUser = user;
            }
            onlineTextView.setText(LocaleController.formatUserStatus(currentMessageObject.currentAccount, currentUser));
        } else {
            lastPrintString = printString;
            onlineTextView.setText(printString);
            setTypingAnimation(true);
        }
    }
}
 
Example #25
Source File: DrawerProfileCell.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public void setUser(TLRPC.User user, boolean accounts) {
    if (user == null) {
        return;
    }
    accountsShown = accounts;
    setArrowState(false);
    nameTextView.setText(UserObject.getUserName(user));
    phoneTextView.setText(PhoneFormat.getInstance().format("+" + user.phone));
    AvatarDrawable avatarDrawable = new AvatarDrawable(user);
    avatarDrawable.setColor(Theme.getColor(Theme.key_avatar_backgroundInProfileBlue));
    avatarImageView.setImage(ImageLocation.getForUser(user, false), "50_50", avatarDrawable, user);

    applyBackground(true);
}
 
Example #26
Source File: CancelAccountDeletionActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private String getCode() {
    if (codeField == null) {
        return "";
    }
    StringBuilder codeBuilder = new StringBuilder();
    for (int a = 0; a < codeField.length; a++) {
        codeBuilder.append(PhoneFormat.stripExceptNumbers(codeField[a].getText().toString()));
    }
    return codeBuilder.toString();
}
 
Example #27
Source File: ChangePhoneActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
private String getCode() {
    if (codeField == null) {
        return "";
    }
    StringBuilder codeBuilder = new StringBuilder();
    for (int a = 0; a < codeField.length; a++) {
        codeBuilder.append(PhoneFormat.stripExceptNumbers(codeField[a].getText().toString()));
    }
    return codeBuilder.toString();
}
 
Example #28
Source File: UserObject.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
public static String getUserName(TLRPC.User user) {
    if (user == null || isDeleted(user)) {
        return LocaleController.getString("HiddenName", R.string.HiddenName);
    }
    String name = ContactsController.formatName(user.first_name, user.last_name);
    return name.length() != 0 || TextUtils.isEmpty(user.phone) ? name : PhoneFormat.getInstance().format("+" + user.phone);
}
 
Example #29
Source File: CallReceiver.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onReceive(final Context context, Intent intent) {
    if (intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
        String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
        if (TelephonyManager.EXTRA_STATE_RINGING.equals(phoneState)) {
            String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveCall, PhoneFormat.stripExceptNumbers(phoneNumber));
        }
    }
}
 
Example #30
Source File: CallReceiver.java    From Telegram with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onReceive(final Context context, Intent intent) {
    if (intent.getAction().equals(TelephonyManager.ACTION_PHONE_STATE_CHANGED)) {
        String phoneState = intent.getStringExtra(TelephonyManager.EXTRA_STATE);
        if (TelephonyManager.EXTRA_STATE_RINGING.equals(phoneState)) {
            String phoneNumber = intent.getStringExtra(TelephonyManager.EXTRA_INCOMING_NUMBER);
            NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.didReceiveCall, PhoneFormat.stripExceptNumbers(phoneNumber));
        }
    }
}