Java Code Examples for org.telegram.messenger.LocaleController#formatUserStatus()

The following examples show how to use org.telegram.messenger.LocaleController#formatUserStatus() . 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: DialogCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void setStatusColor()
{
    String s = LocaleController.formatUserStatus(currentAccount,  user);
    if (s.equals(LocaleController.getString("ALongTimeAgo", R.string.ALongTimeAgo)))
        statusBG.setColor(Color.BLACK);
    else if (s.equals(LocaleController.getString("Online", R.string.Online)))
        statusBG.setColor(0xff00e676);
    else if (s.equals(LocaleController.getString("Lately", R.string.Lately)))
        statusBG.setColor(Color.LTGRAY);
    else
        statusBG.setColor(Color.GRAY);

    int l = user.status != null ? ConnectionsManager.getInstance(currentAccount).getCurrentTime() - user.status.expires : -2;
    if (l > 0 && l < 86400)
        statusBG.setColor(Color.LTGRAY);
}
 
Example 2
Source File: DialogCell.java    From TelePlus-Android with GNU General Public License v2.0 6 votes vote down vote up
private void setStatusColor()
{
    String s = LocaleController.formatUserStatus(currentAccount,  user);
    if (s.equals(LocaleController.getString("ALongTimeAgo", R.string.ALongTimeAgo)))
        statusBG.setColor(Color.BLACK);
    else if (s.equals(LocaleController.getString("Online", R.string.Online)))
        statusBG.setColor(0xff00e676);
    else if (s.equals(LocaleController.getString("Lately", R.string.Lately)))
        statusBG.setColor(Color.LTGRAY);
    else
        statusBG.setColor(Color.GRAY);

    int l = user.status != null ? ConnectionsManager.getInstance(currentAccount).getCurrentTime() - user.status.expires : -2;
    if (l > 0 && l < 86400)
        statusBG.setColor(Color.LTGRAY);
}
 
Example 3
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void updateSubtitle() {
    if (parentFragment == null) {
        return;
    }
    TLRPC.User user = parentFragment.getCurrentUser();
    if (UserObject.isUserSelf(user)) {
        if (subtitleTextView.getVisibility() != GONE) {
            subtitleTextView.setVisibility(GONE);
        }
        return;
    }
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    CharSequence printString = MessagesController.getInstance(currentAccount).printingStrings.get(parentFragment.getDialogId());
    if (printString != null) {
        printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""});
    }
    CharSequence newSubtitle;
    if (printString == null || printString.length() == 0 || ChatObject.isChannel(chat) && !chat.megagroup) {
        setTypingAnimation(false);
        if (chat != null) {
            TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
            if (ChatObject.isChannel(chat)) {
                if (info != null && info.participants_count != 0) {
                    if (chat.megagroup && info.participants_count <= 200) {
                        if (onlineCount > 1 && info.participants_count != 0) {
                            newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("OnlineCount", onlineCount));
                        } else {
                            newSubtitle = LocaleController.formatPluralString("Members", info.participants_count);
                        }
                    } else {
                        int result[] = new int[1];
                        String shortNumber = LocaleController.formatShortNumber(info.participants_count, result);
                        if (chat.megagroup) {
                            newSubtitle = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber);
                        } else {
                            newSubtitle = LocaleController.formatPluralString("Subscribers", result[0]).replace(String.format("%d", result[0]), shortNumber);
                        }
                    }
                } else {
                    if (chat.megagroup) {
                        newSubtitle = LocaleController.getString("Loading", R.string.Loading).toLowerCase();
                    } else {
                        if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) {
                            newSubtitle = LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase();
                        } else {
                            newSubtitle = LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase();
                        }
                    }
                }
            } else {
                if (ChatObject.isKickedFromChat(chat)) {
                    newSubtitle = LocaleController.getString("YouWereKicked", R.string.YouWereKicked);
                } else if (ChatObject.isLeftFromChat(chat)) {
                    newSubtitle = LocaleController.getString("YouLeft", R.string.YouLeft);
                } else {
                    int count = chat.participants_count;
                    if (info != null && info.participants != null) {
                        count = info.participants.participants.size();
                    }
                    if (onlineCount > 1 && count != 0) {
                        newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("OnlineCount", onlineCount));
                    } else {
                        newSubtitle = LocaleController.formatPluralString("Members", count);
                    }
                }
            }
        } else if (user != null) {
            TLRPC.User newUser = MessagesController.getInstance(currentAccount).getUser(user.id);
            if (newUser != null) {
                user = newUser;
            }
            String newStatus;
            if (user.id == UserConfig.getInstance(currentAccount).getClientUserId()) {
                newStatus = LocaleController.getString("ChatYourSelf", R.string.ChatYourSelf);
            } else if (user.id == 333000 || user.id == 777000) {
                newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications);
            } else if (user.bot) {
                newStatus = LocaleController.getString("Bot", R.string.Bot);
            } else {
                newStatus = LocaleController.formatUserStatus(currentAccount, user);
            }
            newSubtitle = newStatus;
        } else {
            newSubtitle = "";
        }
    } else {
        newSubtitle = printString;
        setTypingAnimation(true);
    }
    if (lastSubtitle == null) {
        subtitleTextView.setText(newSubtitle);
    } else {
        lastSubtitle = newSubtitle;
    }
}
 
Example 4
Source File: ChatAvatarContainer.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
public void updateSubtitle() {
    if (parentFragment == null) {
        return;
    }
    TLRPC.User user = parentFragment.getCurrentUser();
    if (UserObject.isUserSelf(user)) {
        if (subtitleTextView.getVisibility() != GONE) {
            subtitleTextView.setVisibility(GONE);
        }
        return;
    }
    TLRPC.Chat chat = parentFragment.getCurrentChat();
    CharSequence printString = MessagesController.getInstance(currentAccount).printingStrings.get(parentFragment.getDialogId());
    if (printString != null) {
        printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""});
    }
    CharSequence newSubtitle;
    if (printString == null || printString.length() == 0 || ChatObject.isChannel(chat) && !chat.megagroup) {
        setTypingAnimation(false);
        if (chat != null) {
            TLRPC.ChatFull info = parentFragment.getCurrentChatInfo();
            if (ChatObject.isChannel(chat)) {
                if (info != null && info.participants_count != 0) {
                    if (chat.megagroup && info.participants_count <= 200) {
                        if (onlineCount > 1 && info.participants_count != 0) {
                            newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("OnlineCount", onlineCount));
                        } else {
                            newSubtitle = LocaleController.formatPluralString("Members", info.participants_count);
                        }
                    } else {
                        int result[] = new int[1];
                        String shortNumber = LocaleController.formatShortNumber(info.participants_count, result);
                        if (chat.megagroup) {
                            newSubtitle = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber);
                        } else {
                            newSubtitle = LocaleController.formatPluralString("Subscribers", result[0]).replace(String.format("%d", result[0]), shortNumber);
                        }
                    }
                } else {
                    if (chat.megagroup) {
                        newSubtitle = LocaleController.getString("Loading", R.string.Loading).toLowerCase();
                    } else {
                        if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) {
                            newSubtitle = LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase();
                        } else {
                            newSubtitle = LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase();
                        }
                    }
                }
            } else {
                if (ChatObject.isKickedFromChat(chat)) {
                    newSubtitle = LocaleController.getString("YouWereKicked", R.string.YouWereKicked);
                } else if (ChatObject.isLeftFromChat(chat)) {
                    newSubtitle = LocaleController.getString("YouLeft", R.string.YouLeft);
                } else {
                    int count = chat.participants_count;
                    if (info != null && info.participants != null) {
                        count = info.participants.participants.size();
                    }
                    if (onlineCount > 1 && count != 0) {
                        newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("OnlineCount", onlineCount));
                    } else {
                        newSubtitle = LocaleController.formatPluralString("Members", count);
                    }
                }
            }
        } else if (user != null) {
            TLRPC.User newUser = MessagesController.getInstance(currentAccount).getUser(user.id);
            if (newUser != null) {
                user = newUser;
            }
            String newStatus;
            if (user.id == UserConfig.getInstance(currentAccount).getClientUserId()) {
                newStatus = LocaleController.getString("ChatYourSelf", R.string.ChatYourSelf);
            } else if (user.id == 333000 || user.id == 777000) {
                newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications);
            } else if (user.bot) {
                newStatus = LocaleController.getString("Bot", R.string.Bot);
            } else {
                newStatus = LocaleController.formatUserStatus(currentAccount, user);
            }
            newSubtitle = newStatus;
        } else {
            newSubtitle = "";
        }
    } else {
        newSubtitle = printString;
        setTypingAnimation(true);
    }
    if (lastSubtitle == null) {
        subtitleTextView.setText(newSubtitle);
    } else {
        lastSubtitle = newSubtitle;
    }
}