Java Code Examples for org.telegram.ui.Cells.TextInfoPrivacyCell#setText()

The following examples show how to use org.telegram.ui.Cells.TextInfoPrivacyCell#setText() . 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: ConvertGroupActivity.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) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == convertRow) {
                textCell.setText(LocaleController.getString("ConvertGroup", R.string.ConvertGroup), false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == convertInfoRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ConvertGroupInfo2", R.string.ConvertGroupInfo2)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == convertDetailRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ConvertGroupInfo3", R.string.ConvertGroupInfo3)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 2
Source File: ChatUsersActivity.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) {
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            userCell.setTag(position);
            TLRPC.ChatParticipant participant = getItem(position);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
            if (user != null) {
                userCell.setData(user, null, null);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == participantsInfoRow) {
                privacyCell.setText("");
            }
            break;
    }
}
 
Example 3
Source File: ChatUsersActivity.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) {
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            userCell.setTag(position);
            TLRPC.ChatParticipant participant = getItem(position);
            TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(participant.user_id);
            if (user != null) {
                userCell.setData(user, null, null);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == participantsInfoRow) {
                privacyCell.setText("");
            }
            break;
    }
}
 
Example 4
Source File: ConvertGroupActivity.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) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == convertRow) {
                textCell.setText(LocaleController.getString("ConvertGroup", R.string.ConvertGroup), false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == convertInfoRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ConvertGroupInfo2", R.string.ConvertGroupInfo2)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == convertDetailRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("ConvertGroupInfo3", R.string.ConvertGroupInfo3)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 5
Source File: CacheControlActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == databaseRow) {
                textCell.setTextAndValue(LocaleController.getString("ClearLocalDatabase", R.string.ClearLocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == databaseInfoRow) {
                privacyCell.setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == cacheInfoRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == keepMediaInfoRow) {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            StroageUsageView stroageUsageView = (StroageUsageView) holder.itemView;
            stroageUsageView.setStorageUsage(calculating, databaseSize, totalSize, totalDeviceFreeSize, totalDeviceSize);
            break;
        case 3:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == keepMediaHeaderRow) {
                headerCell.setText(LocaleController.getString("KeepMedia", R.string.KeepMedia));
            } else if (position == deviseStorageHeaderRow) {
                headerCell.setText(LocaleController.getString("DeviceStorage", R.string.DeviceStorage));
            }
            break;
    }
}
 
Example 6
Source File: ChatLinkActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            userCell.setTag(position);
            TLRPC.Chat chat = chats.get(position - chatStartRow);
            userCell.setData(chat, null, TextUtils.isEmpty(chat.username) ? null : "@" + chat.username, position != chatEndRow - 1 || info.linked_chat_id != 0);
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == detailRow) {
                if (isChannel) {
                    privacyCell.setText(LocaleController.getString("DiscussionChannelHelp2", R.string.DiscussionChannelHelp2));
                } else {
                    privacyCell.setText(LocaleController.getString("DiscussionGroupHelp2", R.string.DiscussionGroupHelp2));
                }
            }
            break;
        case 2:
            ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
            if (isChannel) {
                if (info.linked_chat_id != 0) {
                    actionCell.setColors(Theme.key_windowBackgroundWhiteRedText5, Theme.key_windowBackgroundWhiteRedText5);
                    actionCell.setText(LocaleController.getString("DiscussionUnlinkGroup", R.string.DiscussionUnlinkGroup), null, R.drawable.actions_remove_user, false);
                } else {
                    actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
                    actionCell.setText(LocaleController.getString("DiscussionCreateGroup", R.string.DiscussionCreateGroup), null, R.drawable.menu_groups, true);
                }
            } else {
                actionCell.setColors(Theme.key_windowBackgroundWhiteRedText5, Theme.key_windowBackgroundWhiteRedText5);
                actionCell.setText(LocaleController.getString("DiscussionUnlinkChannel", R.string.DiscussionUnlinkChannel), null, R.drawable.actions_remove_user, false);
            }
            break;
    }
}
 
Example 7
Source File: GroupInviteActivity.java    From Telegram-FOSS with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == copyLinkRow) {
                textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true);
            } else if (position == shareLinkRow) {
                textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false);
            } else if (position == revokeLinkRow) {
                textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == shadowRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == linkInfoRow) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chat_id);
                if (ChatObject.isChannel(chat) && !chat.megagroup) {
                    privacyCell.setText(LocaleController.getString("ChannelLinkInfo", R.string.ChannelLinkInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("LinkInfo", R.string.LinkInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            TextBlockCell textBlockCell = (TextBlockCell) holder.itemView;
            textBlockCell.setText(invite != null ? invite.link : "error", false);
            break;
    }
}
 
Example 8
Source File: GroupInviteActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == copyLinkRow) {
                textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true);
            } else if (position == shareLinkRow) {
                textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false);
            } else if (position == revokeLinkRow) {
                textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == shadowRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == linkInfoRow) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chat_id);
                if (ChatObject.isChannel(chat) && !chat.megagroup) {
                    privacyCell.setText(LocaleController.getString("ChannelLinkInfo", R.string.ChannelLinkInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("LinkInfo", R.string.LinkInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            TextBlockCell textBlockCell = (TextBlockCell) holder.itemView;
            textBlockCell.setText(invite != null ? invite.link : "error", false);
            break;
    }
}
 
Example 9
Source File: GroupInviteActivity.java    From TelePlus-Android with GNU General Public License v2.0 5 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == copyLinkRow) {
                textCell.setText(LocaleController.getString("CopyLink", R.string.CopyLink), true);
            } else if (position == shareLinkRow) {
                textCell.setText(LocaleController.getString("ShareLink", R.string.ShareLink), false);
            } else if (position == revokeLinkRow) {
                textCell.setText(LocaleController.getString("RevokeLink", R.string.RevokeLink), true);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == shadowRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == linkInfoRow) {
                TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(chat_id);
                if (ChatObject.isChannel(chat) && !chat.megagroup) {
                    privacyCell.setText(LocaleController.getString("ChannelLinkInfo", R.string.ChannelLinkInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("LinkInfo", R.string.LinkInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            TextBlockCell textBlockCell = (TextBlockCell) holder.itemView;
            textBlockCell.setText(invite != null ? invite.link : "error", false);
            break;
    }
}
 
Example 10
Source File: SessionsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty());
            } else {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 11
Source File: TwoStepVerificationActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
            textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
            if (position == changePasswordRow) {
                textCell.setText(LocaleController.getString("ChangePassword", R.string.ChangePassword), true);
            } else if (position == setPasswordRow) {
                textCell.setText(LocaleController.getString("SetAdditionalPassword", R.string.SetAdditionalPassword), true);
            } else if (position == turnPasswordOffRow) {
                textCell.setText(LocaleController.getString("TurnPasswordOff", R.string.TurnPasswordOff), true);
            } else if (position == changeRecoveryEmailRow) {
                textCell.setText(LocaleController.getString("ChangeRecoveryEmail", R.string.ChangeRecoveryEmail), abortPasswordRow != -1);
            } else if (position == setRecoveryEmailRow) {
                textCell.setText(LocaleController.getString("SetRecoveryEmail", R.string.SetRecoveryEmail), false);
            } else if (position == abortPasswordRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText3);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText3));
                textCell.setText(LocaleController.getString("AbortPassword", R.string.AbortPassword), false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == setPasswordDetailRow) {
                privacyCell.setText(LocaleController.getString("SetAdditionalPasswordInfo", R.string.SetAdditionalPasswordInfo));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == shadowRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == passwordSetupDetailRow) {
                privacyCell.setText(LocaleController.formatString("EmailPasswordConfirmText", R.string.EmailPasswordConfirmText, currentPassword.email_unconfirmed_pattern != null ? currentPassword.email_unconfirmed_pattern : ""));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_top, Theme.key_windowBackgroundGrayShadow));
            } else if (position == passwordEnabledDetailRow) {
                privacyCell.setText(LocaleController.getString("EnabledPasswordText", R.string.EnabledPasswordText));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == passwordEmailVerifyDetailRow) {
                privacyCell.setText(LocaleController.formatString("PendingEmailText", R.string.PendingEmailText, currentPassword.email_unconfirmed_pattern != null ? currentPassword.email_unconfirmed_pattern : ""));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 12
Source File: DataUsageActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    int total = StatsController.getInstance(currentAccount).getCallsTotalTime(currentType);
                    int hours = total / 3600;
                    total -= hours * 3600;
                    int minutes = total / 60;
                    total -= minutes * 60;
                    String time;
                    if (hours != 0) {
                        time = String.format("%d:%02d:%02d", hours, minutes, total);
                    } else {
                        time = String.format("%d:%02d", minutes, total);
                    }
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position != totalBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}
 
Example 13
Source File: DataUsageActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    String time = AndroidUtilities.formatShortDuration(StatsController.getInstance(currentAccount).getCallsTotalTime(currentType));
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position == callsBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}
 
Example 14
Source File: CacheControlActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
    switch (holder.getItemViewType())
    {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == databaseRow)
            {
                textCell.setTextAndValue(LocaleController.getString("LocalDatabase", R.string.LocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
            }
            else if (position == cacheRow)
            {
                if (calculating)
                {
                    textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), LocaleController.getString("CalculatingSize", R.string.CalculatingSize), false);
                }
                else
                {
                    textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), totalSize == 0 ? LocaleController.getString("CacheEmpty", R.string.CacheEmpty) : AndroidUtilities.formatFileSize(totalSize), false);
                }
            }
            else if (position == keepMediaRow)
            {
                SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                int keepMedia = preferences.getInt("keep_media", 2);
                String value;
                if (keepMedia == 0)
                {
                    value = LocaleController.formatPluralString("Weeks", 1);
                }
                else if (keepMedia == 1)
                {
                    value = LocaleController.formatPluralString("Months", 1);
                }
                else if (keepMedia == 3)
                {
                    value = LocaleController.formatPluralString("Days", 3);
                }
                else
                {
                    value = LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever);
                }
                textCell.setTextAndValue(LocaleController.getString("KeepMedia", R.string.KeepMedia), value, false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == databaseInfoRow)
            {
                privacyCell.setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            else if (position == cacheInfoRow)
            {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            else if (position == keepMediaInfoRow)
            {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 15
Source File: CacheControlActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position)
{
    switch (holder.getItemViewType())
    {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == databaseRow)
            {
                textCell.setTextAndValue(LocaleController.getString("LocalDatabase", R.string.LocalDatabase), AndroidUtilities.formatFileSize(databaseSize), false);
            }
            else if (position == cacheRow)
            {
                if (calculating)
                {
                    textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), LocaleController.getString("CalculatingSize", R.string.CalculatingSize), false);
                }
                else
                {
                    textCell.setTextAndValue(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), totalSize == 0 ? LocaleController.getString("CacheEmpty", R.string.CacheEmpty) : AndroidUtilities.formatFileSize(totalSize), false);
                }
            }
            else if (position == keepMediaRow)
            {
                SharedPreferences preferences = MessagesController.getGlobalMainSettings();
                int keepMedia = preferences.getInt("keep_media", 2);
                String value;
                if (keepMedia == 0)
                {
                    value = LocaleController.formatPluralString("Weeks", 1);
                }
                else if (keepMedia == 1)
                {
                    value = LocaleController.formatPluralString("Months", 1);
                }
                else if (keepMedia == 3)
                {
                    value = LocaleController.formatPluralString("Days", 3);
                }
                else
                {
                    value = LocaleController.getString("KeepMediaForever", R.string.KeepMediaForever);
                }
                textCell.setTextAndValue(LocaleController.getString("KeepMedia", R.string.KeepMedia), value, false);
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == databaseInfoRow)
            {
                privacyCell.setText(LocaleController.getString("LocalDatabaseInfo", R.string.LocalDatabaseInfo));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            else if (position == cacheInfoRow)
            {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            else if (position == keepMediaInfoRow)
            {
                privacyCell.setText(AndroidUtilities.replaceTags(LocaleController.getString("KeepMediaInfo", R.string.KeepMediaInfo)));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 16
Source File: DataUsageActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            if (position == resetSection2Row) {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else {
                holder.itemView.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        }
        case 1: {
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == resetRow) {
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                textCell.setText(LocaleController.getString("ResetStatistics", R.string.ResetStatistics), false);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
            } else {
                int type;
                textCell.setTag(Theme.key_windowBackgroundWhiteBlackText);
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
                if (position == callsSentRow || position == callsReceivedRow || position == callsBytesSentRow || position == callsBytesReceivedRow) {
                    type = StatsController.TYPE_CALLS;
                } else if (position == messagesSentRow || position == messagesReceivedRow || position == messagesBytesSentRow || position == messagesBytesReceivedRow) {
                    type = StatsController.TYPE_MESSAGES;
                } else if (position == photosSentRow || position == photosReceivedRow || position == photosBytesSentRow || position == photosBytesReceivedRow) {
                    type = StatsController.TYPE_PHOTOS;
                } else if (position == audiosSentRow || position == audiosReceivedRow || position == audiosBytesSentRow || position == audiosBytesReceivedRow) {
                    type = StatsController.TYPE_AUDIOS;
                } else if (position == videosSentRow || position == videosReceivedRow || position == videosBytesSentRow || position == videosBytesReceivedRow) {
                    type = StatsController.TYPE_VIDEOS;
                } else if (position == filesSentRow || position == filesReceivedRow || position == filesBytesSentRow || position == filesBytesReceivedRow) {
                    type = StatsController.TYPE_FILES;
                } else {
                    type = StatsController.TYPE_TOTAL;
                }
                if (position == callsSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("OutgoingCalls", R.string.OutgoingCalls), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == callsReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("IncomingCalls", R.string.IncomingCalls), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == callsTotalTimeRow) {
                    int total = StatsController.getInstance(currentAccount).getCallsTotalTime(currentType);
                    int hours = total / 3600;
                    total -= hours * 3600;
                    int minutes = total / 60;
                    total -= minutes * 60;
                    String time;
                    if (hours != 0) {
                        time = String.format("%d:%02d:%02d", hours, minutes, total);
                    } else {
                        time = String.format("%d:%02d", minutes, total);
                    }
                    textCell.setTextAndValue(LocaleController.getString("CallsTotalTime", R.string.CallsTotalTime), time, false);
                } else if (position == messagesSentRow || position == photosSentRow || position == videosSentRow || position == audiosSentRow || position == filesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountSent", R.string.CountSent), String.format("%d", StatsController.getInstance(currentAccount).getSentItemsCount(currentType, type)), true);
                } else if (position == messagesReceivedRow || position == photosReceivedRow || position == videosReceivedRow || position == audiosReceivedRow || position == filesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("CountReceived", R.string.CountReceived), String.format("%d", StatsController.getInstance(currentAccount).getRecivedItemsCount(currentType, type)), true);
                } else if (position == messagesBytesSentRow || position == photosBytesSentRow || position == videosBytesSentRow || position == audiosBytesSentRow || position == filesBytesSentRow || position == callsBytesSentRow || position == totalBytesSentRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesSent", R.string.BytesSent), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getSentBytesCount(currentType, type)), true);
                } else if (position == messagesBytesReceivedRow || position == photosBytesReceivedRow || position == videosBytesReceivedRow || position == audiosBytesReceivedRow || position == filesBytesReceivedRow || position == callsBytesReceivedRow || position == totalBytesReceivedRow) {
                    textCell.setTextAndValue(LocaleController.getString("BytesReceived", R.string.BytesReceived), AndroidUtilities.formatFileSize(StatsController.getInstance(currentAccount).getReceivedBytesCount(currentType, type)), position != totalBytesReceivedRow);
                }
            }
            break;
        }
        case 2: {
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == totalSectionRow) {
                headerCell.setText(LocaleController.getString("TotalDataUsage", R.string.TotalDataUsage));
            } else if (position == callsSectionRow) {
                headerCell.setText(LocaleController.getString("CallsDataUsage", R.string.CallsDataUsage));
            } else if (position == filesSectionRow) {
                headerCell.setText(LocaleController.getString("FilesDataUsage", R.string.FilesDataUsage));
            } else if (position == audiosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalAudioCache", R.string.LocalAudioCache));
            } else if (position == videosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalVideoCache", R.string.LocalVideoCache));
            } else if (position == photosSectionRow) {
                headerCell.setText(LocaleController.getString("LocalPhotoCache", R.string.LocalPhotoCache));
            } else if (position == messagesSectionRow) {
                headerCell.setText(LocaleController.getString("MessagesDataUsage", R.string.MessagesDataUsage));
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            cell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            cell.setText(LocaleController.formatString("NetworkUsageSince", R.string.NetworkUsageSince, LocaleController.getInstance().formatterStats.format(StatsController.getInstance(currentAccount).getResetStatsDate(currentType))));
            break;
        }
        default:
            break;
    }
}
 
Example 17
Source File: SessionsActivity.java    From TelePlus-Android with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty());
            } else {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 18
Source File: SessionsActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            TextSettingsCell textCell = (TextSettingsCell) holder.itemView;
            if (position == terminateAllSessionsRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteRedText2));
                textCell.setTag(Theme.key_windowBackgroundWhiteRedText2);
                if (currentType == 0) {
                    textCell.setText(LocaleController.getString("TerminateAllSessions", R.string.TerminateAllSessions), false);
                } else {
                    textCell.setText(LocaleController.getString("TerminateAllWebSessions", R.string.TerminateAllWebSessions), false);
                }
            } else if (position == qrCodeRow) {
                textCell.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlueText4));
                textCell.setTag(Theme.key_windowBackgroundWhiteBlueText4);
                textCell.setText(LocaleController.getString("AuthAnotherClient", R.string.AuthAnotherClient), !sessions.isEmpty());
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == terminateAllSessionsDetailRow) {
                if (currentType == 0) {
                    privacyCell.setText(LocaleController.getString("ClearOtherSessionsHelp", R.string.ClearOtherSessionsHelp));
                } else {
                    privacyCell.setText(LocaleController.getString("ClearOtherWebSessionsHelp", R.string.ClearOtherWebSessionsHelp));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
            } else if (position == otherSessionsTerminateDetail) {
                if (currentType == 0) {
                    if (sessions.isEmpty()) {
                        privacyCell.setText("");
                    } else {
                        privacyCell.setText(LocaleController.getString("TerminateSessionInfo", R.string.TerminateSessionInfo));
                    }
                } else {
                    privacyCell.setText(LocaleController.getString("TerminateWebSessionInfo", R.string.TerminateWebSessionInfo));
                }
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            } else if (position == passwordSessionsDetailRow) {
                privacyCell.setText(LocaleController.getString("LoginAttemptsInfo", R.string.LoginAttemptsInfo));
                if (otherSessionsTerminateDetail == -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                }
            }
            break;
        case 2:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == currentSessionSectionRow) {
                headerCell.setText(LocaleController.getString("CurrentSession", R.string.CurrentSession));
            } else if (position == otherSessionsSectionRow) {
                if (currentType == 0) {
                    headerCell.setText(LocaleController.getString("OtherSessions", R.string.OtherSessions));
                } else {
                    headerCell.setText(LocaleController.getString("OtherWebSessions", R.string.OtherWebSessions));
                }
            } else if (position == passwordSessionsSectionRow) {
                headerCell.setText(LocaleController.getString("LoginAttempts", R.string.LoginAttempts));
            }
            break;
        case 3:
            ViewGroup.LayoutParams layoutParams = emptyLayout.getLayoutParams();
            if (layoutParams != null) {
                layoutParams.height = Math.max(AndroidUtilities.dp(220), AndroidUtilities.displaySize.y - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(128 + (qrCodeRow == -1 ? 0 : 30)) - (Build.VERSION.SDK_INT >= 21 ? AndroidUtilities.statusBarHeight : 0));
                emptyLayout.setLayoutParams(layoutParams);
            }
            break;
        default:
            SessionCell sessionCell = (SessionCell) holder.itemView;
            if (position == currentSessionRow) {
                sessionCell.setSession(currentSession, !sessions.isEmpty() || !passwordSessions.isEmpty() || qrCodeRow != -1);
            } else if (position >= otherSessionsStartRow && position < otherSessionsEndRow) {
                sessionCell.setSession(sessions.get(position - otherSessionsStartRow), position != otherSessionsEndRow - 1);
            } else if (position >= passwordSessionsStartRow && position < passwordSessionsEndRow) {
                sessionCell.setSession(passwordSessions.get(position - passwordSessionsStartRow), position != passwordSessionsEndRow - 1);
            }
            break;
    }
}
 
Example 19
Source File: PrivacyUsersActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0:
            ManageChatUserCell userCell = (ManageChatUserCell) holder.itemView;
            int uid;
            if (currentType == TYPE_BLOCKED) {
                uid = getMessagesController().blockedUsers.keyAt(position - usersStartRow);
            } else {
                uid = uidArray.get(position - usersStartRow);
            }
            userCell.setTag(uid);
            if (uid > 0) {
                TLRPC.User user = getMessagesController().getUser(uid);
                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.setData(user, null, number, position != usersEndRow - 1);
                }
            } else {
                TLRPC.Chat chat = getMessagesController().getChat(-uid);
                if (chat != null) {
                    String subtitle;
                    if (chat.participants_count != 0) {
                        subtitle = LocaleController.formatPluralString("Members", chat.participants_count);
                    } else if (chat.has_geo) {
                        subtitle = LocaleController.getString("MegaLocation", R.string.MegaLocation);
                    } else if (TextUtils.isEmpty(chat.username)) {
                        subtitle = LocaleController.getString("MegaPrivate", R.string.MegaPrivate);
                    } else {
                        subtitle = LocaleController.getString("MegaPublic", R.string.MegaPublic);
                    }
                    userCell.setData(chat, null, subtitle, position != usersEndRow - 1);
                }
            }
            break;
        case 1:
            TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
            if (position == blockUserDetailRow) {
                if (currentType == TYPE_BLOCKED) {
                    privacyCell.setText(LocaleController.getString("BlockedUsersInfo", R.string.BlockedUsersInfo));
                } else {
                    privacyCell.setText(null);
                }
                if (usersStartRow == -1) {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
                } else {
                    privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow));
                }
            } else if (position == usersDetailRow) {
                privacyCell.setText("");
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
        case 2:
            ManageChatTextCell actionCell = (ManageChatTextCell) holder.itemView;
            actionCell.setColors(Theme.key_windowBackgroundWhiteBlueIcon, Theme.key_windowBackgroundWhiteBlueButton);
            if (currentType == TYPE_BLOCKED) {
                actionCell.setText(LocaleController.getString("BlockUser", R.string.BlockUser), null, R.drawable.actions_addmember2, false);
            } else {
                actionCell.setText(LocaleController.getString("PrivacyAddAnException", R.string.PrivacyAddAnException), null, R.drawable.actions_addmember2, false);
            }
            break;
        case 3:
            HeaderCell headerCell = (HeaderCell) holder.itemView;
            if (position == usersHeaderRow) {
                if (currentType == TYPE_BLOCKED) {
                    headerCell.setText(LocaleController.formatPluralString("BlockedUsersCount", getMessagesController().totalBlockedCount));
                } else {
                    headerCell.setText(LocaleController.getString("PrivacyExceptions", R.string.PrivacyExceptions));
                }
            }
            break;
    }
}
 
Example 20
Source File: WallpapersListActivity.java    From Telegram-FOSS with GNU General Public License v2.0 4 votes vote down vote up
@Override
public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) {
    switch (holder.getItemViewType()) {
        case 0: {
            TextCell textCell = (TextCell) holder.itemView;
            if (position == uploadImageRow) {
                textCell.setTextAndIcon(LocaleController.getString("SelectFromGallery", R.string.SelectFromGallery), R.drawable.profile_photos, true);
            } else if (position == setColorRow) {
                textCell.setTextAndIcon(LocaleController.getString("SetColor", R.string.SetColor), R.drawable.menu_palette, false);
            } else if (position == resetRow) {
                textCell.setText(LocaleController.getString("ResetChatBackgrounds", R.string.ResetChatBackgrounds), false);
            }
            break;
        }
        case 3: {
            TextInfoPrivacyCell cell = (TextInfoPrivacyCell) holder.itemView;
            if (position == resetInfoRow) {
                cell.setText(LocaleController.getString("ResetChatBackgroundsInfo", R.string.ResetChatBackgroundsInfo));
            }
            break;
        }
        case 2: {
            WallpaperCell wallpaperCell = (WallpaperCell) holder.itemView;
            position = (position - wallPaperStartRow) * columnsCount;
            wallpaperCell.setParams(columnsCount, position == 0, position / columnsCount == totalWallpaperRows - 1);
            for (int a = 0; a < columnsCount; a++) {
                int p = position + a;
                Object object = p < wallPapers.size() ? wallPapers.get(p) : null;
                String slugFinal;
                long id;
                if (object instanceof TLRPC.TL_wallPaper) {
                    TLRPC.TL_wallPaper wallPaper = (TLRPC.TL_wallPaper) object;
                    Theme.OverrideWallpaperInfo info = Theme.getActiveTheme().overrideWallpaper;
                    if (selectedBackgroundSlug.equals(wallPaper.slug) && wallPaper.settings != null &&
                            (selectedColor != wallPaper.settings.background_color ||
                            selectedGradientColor != wallPaper.settings.second_background_color ||
                            (selectedGradientColor != 0 && selectedGradientRotation != AndroidUtilities.getWallpaperRotation(wallPaper.settings.rotation, false)) &&
                            (wallPaper.settings.intensity - selectedIntensity) > 0.001f)) {
                        slugFinal = "";
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = wallPaper.id;
                } else {
                    if (object instanceof ColorWallpaper) {
                        ColorWallpaper colorWallpaper = (ColorWallpaper) object;
                        if (colorWallpaper.color != selectedColor || colorWallpaper.gradientColor != selectedGradientColor) {
                            slugFinal = "";
                        } else {
                            slugFinal = selectedBackgroundSlug;
                        }
                    } else {
                        slugFinal = selectedBackgroundSlug;
                    }
                    id = 0;
                }
                wallpaperCell.setWallpaper(currentType, a, object, slugFinal, null, false);
                if (actionBar.isActionModeShowed()) {
                    wallpaperCell.setChecked(a, selectedWallPapers.indexOfKey(id) >= 0, !scrolling);
                } else {
                    wallpaperCell.setChecked(a, false, !scrolling);
                }
            }
            break;
        }
    }
}