Java Code Examples for org.telegram.ui.Cells.TextSettingsCell#setTextColor()

The following examples show how to use org.telegram.ui.Cells.TextSettingsCell#setTextColor() . 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: TwoStepVerificationActivity.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;
            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), false);
            } else if (position == setRecoveryEmailRow) {
                textCell.setText(LocaleController.getString("SetRecoveryEmail", R.string.SetRecoveryEmail), 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 == passwordEnabledDetailRow) {
                privacyCell.setText(LocaleController.getString("EnabledPasswordText", R.string.EnabledPasswordText));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 2
Source File: TwoStepVerificationActivity.java    From Telegram 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;
            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), false);
            } else if (position == setRecoveryEmailRow) {
                textCell.setText(LocaleController.getString("SetRecoveryEmail", R.string.SetRecoveryEmail), 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 == passwordEnabledDetailRow) {
                privacyCell.setText(LocaleController.getString("EnabledPasswordText", R.string.EnabledPasswordText));
                privacyCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow));
            }
            break;
    }
}
 
Example 3
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 4
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 5
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 6
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 7
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 8
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 9
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 10
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 11
Source File: DataUsageActivity.java    From Telegram 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 12
Source File: SessionsActivity.java    From Telegram 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;
    }
}