Java Code Examples for org.telegram.messenger.UserObject#getUserName()

The following examples show how to use org.telegram.messenger.UserObject#getUserName() . 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: ManageChatUserCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    if (currentUser == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            newName = UserObject.getUserName(currentUser);
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName);
    } else {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        nameTextView.setText(lastName);
    }
    if (currrntStatus != null) {
        statusTextView.setTextColor(statusColor);
        statusTextView.setText(currrntStatus);
    } else if (currentUser != null) {
        if (currentUser.bot) {
            statusTextView.setTextColor(statusColor);
            if (currentUser.bot_chat_history || isAdmin) {
                statusTextView.setText(LocaleController.getString("BotStatusRead", R.string.BotStatusRead));
            } else {
                statusTextView.setText(LocaleController.getString("BotStatusCantRead", R.string.BotStatusCantRead));
            }
        } else {
            if (currentUser.id == UserConfig.getInstance(currentAccount).getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance(currentAccount).getCurrentTime() || MessagesController.getInstance(currentAccount).onlinePrivacy.containsKey(currentUser.id)) {
                statusTextView.setTextColor(statusOnlineColor);
                statusTextView.setText(LocaleController.getString("Online", R.string.Online));
            } else {
                statusTextView.setTextColor(statusColor);
                statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
            }
        }
    }
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example 2
Source File: GroupCreateUserCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    if (currentUser == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && currentStatus == null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            newName = UserObject.getUserName(currentUser);
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    lastStatus = currentUser.status != null ? currentUser.status.expires : 0;

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName, true);
    } else {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        nameTextView.setText(lastName);
    }

    if (currentStatus != null) {
        statusTextView.setText(currentStatus, true);
        statusTextView.setTag(Theme.key_groupcreate_offlineText);
        statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
    } else {
        if (currentUser.bot) {
            statusTextView.setTag(Theme.key_groupcreate_offlineText);
            statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
            statusTextView.setText(LocaleController.getString("Bot", R.string.Bot));
        } else {
            if (currentUser.id == UserConfig.getInstance(currentAccount).getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance(currentAccount).getCurrentTime() || MessagesController.getInstance(currentAccount).onlinePrivacy.containsKey(currentUser.id)) {
                statusTextView.setTag(Theme.key_groupcreate_offlineText);
                statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_onlineText));
                statusTextView.setText(LocaleController.getString("Online", R.string.Online));
            } else {
                statusTextView.setTag(Theme.key_groupcreate_offlineText);
                statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
                statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
            }
        }
    }

    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example 3
Source File: ManageChatUserCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    if (currentUser == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            newName = UserObject.getUserName(currentUser);
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName);
    } else {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        nameTextView.setText(lastName);
    }
    if (currrntStatus != null) {
        statusTextView.setTextColor(statusColor);
        statusTextView.setText(currrntStatus);
    } else if (currentUser != null) {
        if (currentUser.bot) {
            statusTextView.setTextColor(statusColor);
            if (currentUser.bot_chat_history || isAdmin) {
                statusTextView.setText(LocaleController.getString("BotStatusRead", R.string.BotStatusRead));
            } else {
                statusTextView.setText(LocaleController.getString("BotStatusCantRead", R.string.BotStatusCantRead));
            }
        } else {
            if (currentUser.id == UserConfig.getInstance(currentAccount).getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance(currentAccount).getCurrentTime() || MessagesController.getInstance(currentAccount).onlinePrivacy.containsKey(currentUser.id)) {
                statusTextView.setTextColor(statusOnlineColor);
                statusTextView.setText(LocaleController.getString("Online", R.string.Online));
            } else {
                statusTextView.setTextColor(statusColor);
                statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
            }
        }
    }
    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example 4
Source File: GroupCreateUserCell.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    if (currentUser == null) {
        return;
    }
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null && lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && currentStatus == null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            newName = UserObject.getUserName(currentUser);
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    lastStatus = currentUser.status != null ? currentUser.status.expires : 0;

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName, true);
    } else {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        nameTextView.setText(lastName);
    }

    if (currentStatus != null) {
        statusTextView.setText(currentStatus, true);
        statusTextView.setTag(Theme.key_groupcreate_offlineText);
        statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
    } else {
        if (currentUser.bot) {
            statusTextView.setTag(Theme.key_groupcreate_offlineText);
            statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
            statusTextView.setText(LocaleController.getString("Bot", R.string.Bot));
        } else {
            if (currentUser.id == UserConfig.getInstance(currentAccount).getClientUserId() || currentUser.status != null && currentUser.status.expires > ConnectionsManager.getInstance(currentAccount).getCurrentTime() || MessagesController.getInstance(currentAccount).onlinePrivacy.containsKey(currentUser.id)) {
                statusTextView.setTag(Theme.key_groupcreate_offlineText);
                statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_onlineText));
                statusTextView.setText(LocaleController.getString("Online", R.string.Online));
            } else {
                statusTextView.setTag(Theme.key_groupcreate_offlineText);
                statusTextView.setTextColor(Theme.getColor(Theme.key_groupcreate_offlineText));
                statusTextView.setText(LocaleController.formatUserStatus(currentAccount, currentUser));
            }
        }
    }

    avatarImageView.setImage(photo, "50_50", avatarDrawable);
}
 
Example 5
Source File: PollVotesAlert.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentUser != null) {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
    } else {
        lastName = "";
    }
    nameTextView.setText(lastName);

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}
 
Example 6
Source File: ChatAttachAlertContactsLayout.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    if (currentUser != null) {
        avatarDrawable.setInfo(currentUser);
        if (currentUser.status != null) {
            lastStatus = currentUser.status.expires;
        } else {
            lastStatus = 0;
        }
    } else if (currentName != null) {
        avatarDrawable.setInfo(currentId, currentName.toString(), null);
    } else {
        avatarDrawable.setInfo(currentId, "#", null);
    }

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName);
    } else {
        if (currentUser != null) {
            lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        } else {
            lastName = "";
        }
        nameTextView.setText(lastName);
    }
    if (currentStatus != null) {
        statusTextView.setText(currentStatus);
    } else if (currentUser != null) {
        if (TextUtils.isEmpty(currentUser.phone)) {
            statusTextView.setText(LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
        } else {
            statusTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        }
    }

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}
 
Example 7
Source File: PollVotesAlert.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    avatarDrawable.setInfo(currentUser);
    if (currentUser.status != null) {
        lastStatus = currentUser.status.expires;
    } else {
        lastStatus = 0;
    }

    if (currentUser != null) {
        lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
    } else {
        lastName = "";
    }
    nameTextView.setText(lastName);

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}
 
Example 8
Source File: ChatAttachAlertContactsLayout.java    From Telegram with GNU General Public License v2.0 4 votes vote down vote up
public void update(int mask) {
    TLRPC.FileLocation photo = null;
    String newName = null;
    if (currentUser != null && currentUser.photo != null) {
        photo = currentUser.photo.photo_small;
    }

    if (mask != 0) {
        boolean continueUpdate = false;
        if ((mask & MessagesController.UPDATE_MASK_AVATAR) != 0) {
            if (lastAvatar != null && photo == null || lastAvatar == null && photo != null || lastAvatar != null && photo != null && (lastAvatar.volume_id != photo.volume_id || lastAvatar.local_id != photo.local_id)) {
                continueUpdate = true;
            }
        }
        if (currentUser != null && !continueUpdate && (mask & MessagesController.UPDATE_MASK_STATUS) != 0) {
            int newStatus = 0;
            if (currentUser.status != null) {
                newStatus = currentUser.status.expires;
            }
            if (newStatus != lastStatus) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate && currentName == null && lastName != null && (mask & MessagesController.UPDATE_MASK_NAME) != 0) {
            if (currentUser != null) {
                newName = UserObject.getUserName(currentUser);
            }
            if (!newName.equals(lastName)) {
                continueUpdate = true;
            }
        }
        if (!continueUpdate) {
            return;
        }
    }

    if (currentUser != null) {
        avatarDrawable.setInfo(currentUser);
        if (currentUser.status != null) {
            lastStatus = currentUser.status.expires;
        } else {
            lastStatus = 0;
        }
    } else if (currentName != null) {
        avatarDrawable.setInfo(currentId, currentName.toString(), null);
    } else {
        avatarDrawable.setInfo(currentId, "#", null);
    }

    if (currentName != null) {
        lastName = null;
        nameTextView.setText(currentName);
    } else {
        if (currentUser != null) {
            lastName = newName == null ? UserObject.getUserName(currentUser) : newName;
        } else {
            lastName = "";
        }
        nameTextView.setText(lastName);
    }
    if (currentStatus != null) {
        statusTextView.setText(currentStatus);
    } else if (currentUser != null) {
        if (TextUtils.isEmpty(currentUser.phone)) {
            statusTextView.setText(LocaleController.getString("NumberUnknown", R.string.NumberUnknown));
        } else {
            statusTextView.setText(PhoneFormat.getInstance().format("+" + currentUser.phone));
        }
    }

    lastAvatar = photo;
    if (currentUser != null) {
        avatarImageView.setImage(ImageLocation.getForUser(currentUser, false), "50_50", avatarDrawable, currentUser);
    } else {
        avatarImageView.setImageDrawable(avatarDrawable);
    }
}