Java Code Examples for org.telegram.messenger.LocaleController#formatPluralString()
The following examples show how to use
org.telegram.messenger.LocaleController#formatPluralString() .
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: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static void showFloodWaitAlert(String error, final BaseFragment fragment) { if (error == null || !error.startsWith("FLOOD_WAIT") || fragment == null || fragment.getParentActivity() == null) { return; } int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); fragment.showDialog(builder.create(), true, null); }
Example 2
Source File: AlertsCreator.java From Telegram with GNU General Public License v2.0 | 6 votes |
public static void showFloodWaitAlert(String error, final BaseFragment fragment) { if (error == null || !error.startsWith("FLOOD_WAIT") || fragment == null || fragment.getParentActivity() == null) { return; } int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); fragment.showDialog(builder.create(), true, null); }
Example 3
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
public static void showFloodWaitAlert(String error, final BaseFragment fragment) { if (error == null || !error.startsWith("FLOOD_WAIT") || fragment == null || fragment.getParentActivity() == null) { return; } int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); fragment.showDialog(builder.create(), true, null); }
Example 4
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 6 votes |
public static void showFloodWaitAlert(String error, final BaseFragment fragment) { if (error == null || !error.startsWith("FLOOD_WAIT") || fragment == null || fragment.getParentActivity() == null) { return; } int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); builder.setTitle(LocaleController.getString("AppName", R.string.AppName)); builder.setMessage(LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString)); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), null); fragment.showDialog(builder.create(), true, null); }
Example 5
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static String getFloodWaitString(String error) { int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } return LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString); }
Example 6
Source File: AlertsCreator.java From Telegram with GNU General Public License v2.0 | 5 votes |
private static String getFloodWaitString(String error) { int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } return LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString); }
Example 7
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private static String getFloodWaitString(String error) { int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } return LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString); }
Example 8
Source File: NotificationsSettingsActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void showExceptionsAlert(int position) { ArrayList<NotificationException> exceptions; String alertText = null; if (position == privateRow) { exceptions = exceptionUsers; if (exceptions != null && !exceptions.isEmpty()) { alertText = LocaleController.formatPluralString("ChatsException", exceptions.size()); } } else if (position == groupRow) { exceptions = exceptionChats; if (exceptions != null && !exceptions.isEmpty()) { alertText = LocaleController.formatPluralString("Groups", exceptions.size()); } } else { exceptions = exceptionChannels; if (exceptions != null && !exceptions.isEmpty()) { alertText = LocaleController.formatPluralString("Channels", exceptions.size()); } } if (alertText == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (exceptions.size() == 1) { builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("NotificationsExceptionsSingleAlert", R.string.NotificationsExceptionsSingleAlert, alertText))); } else { builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("NotificationsExceptionsAlert", R.string.NotificationsExceptionsAlert, alertText))); } builder.setTitle(LocaleController.getString("NotificationsExceptions", R.string.NotificationsExceptions)); builder.setNeutralButton(LocaleController.getString("ViewExceptions", R.string.ViewExceptions), (dialogInterface, i) -> presentFragment(new NotificationsCustomSettingsActivity(-1, exceptions))); builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null); showDialog(builder.create()); }
Example 9
Source File: NotificationsSettingsActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void showExceptionsAlert(int position) { ArrayList<NotificationException> exceptions; String alertText = null; if (position == privateRow) { exceptions = exceptionUsers; if (exceptions != null && !exceptions.isEmpty()) { alertText = LocaleController.formatPluralString("ChatsException", exceptions.size()); } } else if (position == groupRow) { exceptions = exceptionChats; if (exceptions != null && !exceptions.isEmpty()) { alertText = LocaleController.formatPluralString("Groups", exceptions.size()); } } else { exceptions = exceptionChannels; if (exceptions != null && !exceptions.isEmpty()) { alertText = LocaleController.formatPluralString("Channels", exceptions.size()); } } if (alertText == null) { return; } AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); if (exceptions.size() == 1) { builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("NotificationsExceptionsSingleAlert", R.string.NotificationsExceptionsSingleAlert, alertText))); } else { builder.setMessage(AndroidUtilities.replaceTags(LocaleController.formatString("NotificationsExceptionsAlert", R.string.NotificationsExceptionsAlert, alertText))); } builder.setTitle(LocaleController.getString("NotificationsExceptions", R.string.NotificationsExceptions)); builder.setNeutralButton(LocaleController.getString("ViewExceptions", R.string.ViewExceptions), (dialogInterface, i) -> presentFragment(new NotificationsCustomSettingsActivity(-1, exceptions))); builder.setNegativeButton(LocaleController.getString("OK", R.string.OK), null); showDialog(builder.create()); }
Example 10
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private static String getFloodWaitString(String error) { int time = Utilities.parseInt(error); String timeString; if (time < 60) { timeString = LocaleController.formatPluralString("Seconds", time); } else { timeString = LocaleController.formatPluralString("Minutes", time / 60); } return LocaleController.formatString("FloodWaitTime", R.string.FloodWaitTime, timeString); }
Example 11
Source File: AlertsCreator.java From Telegram with GNU General Public License v2.0 | 4 votes |
public static Dialog createFreeSpaceDialog(final LaunchActivity parentActivity) { final int[] selected = new int[1]; if (SharedConfig.keepMedia == 2) { selected[0] = 3; } else if (SharedConfig.keepMedia == 0) { selected[0] = 1; } else if (SharedConfig.keepMedia == 1) { selected[0] = 2; } else if (SharedConfig.keepMedia == 3) { selected[0] = 0; } String[] descriptions = new String[]{ LocaleController.formatPluralString("Days", 3), LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("LowDiskSpaceNeverRemove", R.string.LowDiskSpaceNeverRemove) }; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); TextView titleTextView = new TextView(parentActivity); titleTextView.setText(LocaleController.getString("LowDiskSpaceTitle2", R.string.LowDiskSpaceTitle2)); titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8)); for (int a = 0; a < descriptions.length; a++) { RadioColorCell cell = new RadioColorCell(parentActivity); cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); cell.setTag(a); cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); cell.setTextAndValue(descriptions[a], selected[0] == a); linearLayout.addView(cell); cell.setOnClickListener(v -> { int num = (Integer) v.getTag(); if (num == 0) { selected[0] = 3; } else if (num == 1) { selected[0] = 0; } else if (num == 2) { selected[0] = 1; } else if (num == 3) { selected[0] = 2; } int count = linearLayout.getChildCount(); for (int a1 = 0; a1 < count; a1++) { View child = linearLayout.getChildAt(a1); if (child instanceof RadioColorCell) { ((RadioColorCell) child).setChecked(child == v, true); } } }); } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("LowDiskSpaceTitle", R.string.LowDiskSpaceTitle)); builder.setMessage(LocaleController.getString("LowDiskSpaceMessage", R.string.LowDiskSpaceMessage)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> SharedConfig.setKeepMedia(selected[0])); builder.setNeutralButton(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), (dialog, which) -> parentActivity.presentFragment(new CacheControlActivity())); return builder.create(); }
Example 12
Source File: CacheControlActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@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 13
Source File: PrivacyUsersActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
@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 14
Source File: AlertsCreator.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public static Dialog createFreeSpaceDialog(final LaunchActivity parentActivity) { final int[] selected = new int[1]; if (SharedConfig.keepMedia == 2) { selected[0] = 3; } else if (SharedConfig.keepMedia == 0) { selected[0] = 1; } else if (SharedConfig.keepMedia == 1) { selected[0] = 2; } else if (SharedConfig.keepMedia == 3) { selected[0] = 0; } String[] descriptions = new String[]{ LocaleController.formatPluralString("Days", 3), LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("LowDiskSpaceNeverRemove", R.string.LowDiskSpaceNeverRemove) }; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); TextView titleTextView = new TextView(parentActivity); titleTextView.setText(LocaleController.getString("LowDiskSpaceTitle2", R.string.LowDiskSpaceTitle2)); titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8)); for (int a = 0; a < descriptions.length; a++) { RadioColorCell cell = new RadioColorCell(parentActivity); cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); cell.setTag(a); cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); cell.setTextAndValue(descriptions[a], selected[0] == a); linearLayout.addView(cell); cell.setOnClickListener(v -> { int num = (Integer) v.getTag(); if (num == 0) { selected[0] = 3; } else if (num == 1) { selected[0] = 0; } else if (num == 2) { selected[0] = 1; } else if (num == 3) { selected[0] = 2; } int count = linearLayout.getChildCount(); for (int a1 = 0; a1 < count; a1++) { View child = linearLayout.getChildAt(a1); if (child instanceof RadioColorCell) { ((RadioColorCell) child).setChecked(child == v, true); } } }); } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("LowDiskSpaceTitle", R.string.LowDiskSpaceTitle)); builder.setMessage(LocaleController.getString("LowDiskSpaceMessage", R.string.LowDiskSpaceMessage)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> SharedConfig.setKeepMedia(selected[0])); builder.setNeutralButton(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), (dialog, which) -> parentActivity.presentFragment(new CacheControlActivity())); return builder.create(); }
Example 15
Source File: PrivacyUsersActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
@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 16
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static Dialog createFreeSpaceDialog(final LaunchActivity parentActivity) { final int selected[] = new int[1]; SharedPreferences preferences = MessagesController.getGlobalMainSettings(); int keepMedia = preferences.getInt("keep_media", 2); if (keepMedia == 2) { selected[0] = 3; } else if (keepMedia == 0) { selected[0] = 1; } else if (keepMedia == 1) { selected[0] = 2; } else if (keepMedia == 3) { selected[0] = 0; } String[] descriptions = new String[]{ LocaleController.formatPluralString("Days", 3), LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("LowDiskSpaceNeverRemove", R.string.LowDiskSpaceNeverRemove) }; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); TextView titleTextView = new TextView(parentActivity); titleTextView.setText(LocaleController.getString("LowDiskSpaceTitle2", R.string.LowDiskSpaceTitle2)); titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8)); for (int a = 0; a < descriptions.length; a++) { RadioColorCell cell = new RadioColorCell(parentActivity); cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); cell.setTag(a); cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); cell.setTextAndValue(descriptions[a], selected[0] == a); linearLayout.addView(cell); cell.setOnClickListener(v -> { int num = (Integer) v.getTag(); if (num == 0) { selected[0] = 3; } else if (num == 1) { selected[0] = 0; } else if (num == 2) { selected[0] = 1; } else if (num == 3) { selected[0] = 2; } int count = linearLayout.getChildCount(); for (int a1 = 0; a1 < count; a1++) { View child = linearLayout.getChildAt(a1); if (child instanceof RadioColorCell) { ((RadioColorCell) child).setChecked(child == v, true); } } }); } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("LowDiskSpaceTitle", R.string.LowDiskSpaceTitle)); builder.setMessage(LocaleController.getString("LowDiskSpaceMessage", R.string.LowDiskSpaceMessage)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> MessagesController.getGlobalMainSettings().edit().putInt("keep_media", selected[0]).commit()); builder.setNeutralButton(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), (dialog, which) -> parentActivity.presentFragment(new CacheControlActivity())); return builder.create(); }
Example 17
Source File: ChatAvatarContainer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void updateSubtitle() { if (parentFragment == null) { return; } TLRPC.User user = parentFragment.getCurrentUser(); if (UserObject.isUserSelf(user)) { if (subtitleTextView.getVisibility() != GONE) { subtitleTextView.setVisibility(GONE); } return; } TLRPC.Chat chat = parentFragment.getCurrentChat(); CharSequence printString = MessagesController.getInstance(currentAccount).printingStrings.get(parentFragment.getDialogId()); if (printString != null) { printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""}); } CharSequence newSubtitle; if (printString == null || printString.length() == 0 || ChatObject.isChannel(chat) && !chat.megagroup) { setTypingAnimation(false); if (chat != null) { TLRPC.ChatFull info = parentFragment.getCurrentChatInfo(); if (ChatObject.isChannel(chat)) { if (info != null && info.participants_count != 0) { if (chat.megagroup && info.participants_count <= 200) { if (onlineCount > 1 && info.participants_count != 0) { newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("OnlineCount", onlineCount)); } else { newSubtitle = LocaleController.formatPluralString("Members", info.participants_count); } } else { int result[] = new int[1]; String shortNumber = LocaleController.formatShortNumber(info.participants_count, result); if (chat.megagroup) { newSubtitle = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber); } else { newSubtitle = LocaleController.formatPluralString("Subscribers", result[0]).replace(String.format("%d", result[0]), shortNumber); } } } else { if (chat.megagroup) { newSubtitle = LocaleController.getString("Loading", R.string.Loading).toLowerCase(); } else { if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) { newSubtitle = LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase(); } else { newSubtitle = LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase(); } } } } else { if (ChatObject.isKickedFromChat(chat)) { newSubtitle = LocaleController.getString("YouWereKicked", R.string.YouWereKicked); } else if (ChatObject.isLeftFromChat(chat)) { newSubtitle = LocaleController.getString("YouLeft", R.string.YouLeft); } else { int count = chat.participants_count; if (info != null && info.participants != null) { count = info.participants.participants.size(); } if (onlineCount > 1 && count != 0) { newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("OnlineCount", onlineCount)); } else { newSubtitle = LocaleController.formatPluralString("Members", count); } } } } else if (user != null) { TLRPC.User newUser = MessagesController.getInstance(currentAccount).getUser(user.id); if (newUser != null) { user = newUser; } String newStatus; if (user.id == UserConfig.getInstance(currentAccount).getClientUserId()) { newStatus = LocaleController.getString("ChatYourSelf", R.string.ChatYourSelf); } else if (user.id == 333000 || user.id == 777000) { newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications); } else if (user.bot) { newStatus = LocaleController.getString("Bot", R.string.Bot); } else { newStatus = LocaleController.formatUserStatus(currentAccount, user); } newSubtitle = newStatus; } else { newSubtitle = ""; } } else { newSubtitle = printString; setTypingAnimation(true); } if (lastSubtitle == null) { subtitleTextView.setText(newSubtitle); } else { lastSubtitle = newSubtitle; } }
Example 18
Source File: CacheControlActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
@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 19
Source File: AlertsCreator.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public static Dialog createFreeSpaceDialog(final LaunchActivity parentActivity) { final int selected[] = new int[1]; SharedPreferences preferences = MessagesController.getGlobalMainSettings(); int keepMedia = preferences.getInt("keep_media", 2); if (keepMedia == 2) { selected[0] = 3; } else if (keepMedia == 0) { selected[0] = 1; } else if (keepMedia == 1) { selected[0] = 2; } else if (keepMedia == 3) { selected[0] = 0; } String[] descriptions = new String[]{ LocaleController.formatPluralString("Days", 3), LocaleController.formatPluralString("Weeks", 1), LocaleController.formatPluralString("Months", 1), LocaleController.getString("LowDiskSpaceNeverRemove", R.string.LowDiskSpaceNeverRemove) }; final LinearLayout linearLayout = new LinearLayout(parentActivity); linearLayout.setOrientation(LinearLayout.VERTICAL); TextView titleTextView = new TextView(parentActivity); titleTextView.setText(LocaleController.getString("LowDiskSpaceTitle2", R.string.LowDiskSpaceTitle2)); titleTextView.setTextColor(Theme.getColor(Theme.key_dialogTextBlack)); titleTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); titleTextView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP); linearLayout.addView(titleTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 24, 0, 24, 8)); for (int a = 0; a < descriptions.length; a++) { RadioColorCell cell = new RadioColorCell(parentActivity); cell.setPadding(AndroidUtilities.dp(4), 0, AndroidUtilities.dp(4), 0); cell.setTag(a); cell.setCheckColor(Theme.getColor(Theme.key_radioBackground), Theme.getColor(Theme.key_dialogRadioBackgroundChecked)); cell.setTextAndValue(descriptions[a], selected[0] == a); linearLayout.addView(cell); cell.setOnClickListener(v -> { int num = (Integer) v.getTag(); if (num == 0) { selected[0] = 3; } else if (num == 1) { selected[0] = 0; } else if (num == 2) { selected[0] = 1; } else if (num == 3) { selected[0] = 2; } int count = linearLayout.getChildCount(); for (int a1 = 0; a1 < count; a1++) { View child = linearLayout.getChildAt(a1); if (child instanceof RadioColorCell) { ((RadioColorCell) child).setChecked(child == v, true); } } }); } AlertDialog.Builder builder = new AlertDialog.Builder(parentActivity); builder.setTitle(LocaleController.getString("LowDiskSpaceTitle", R.string.LowDiskSpaceTitle)); builder.setMessage(LocaleController.getString("LowDiskSpaceMessage", R.string.LowDiskSpaceMessage)); builder.setView(linearLayout); builder.setPositiveButton(LocaleController.getString("OK", R.string.OK), (dialog, which) -> MessagesController.getGlobalMainSettings().edit().putInt("keep_media", selected[0]).commit()); builder.setNeutralButton(LocaleController.getString("ClearMediaCache", R.string.ClearMediaCache), (dialog, which) -> parentActivity.presentFragment(new CacheControlActivity())); return builder.create(); }
Example 20
Source File: ChatAvatarContainer.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public void updateSubtitle() { if (parentFragment == null) { return; } TLRPC.User user = parentFragment.getCurrentUser(); if (UserObject.isUserSelf(user)) { if (subtitleTextView.getVisibility() != GONE) { subtitleTextView.setVisibility(GONE); } return; } TLRPC.Chat chat = parentFragment.getCurrentChat(); CharSequence printString = MessagesController.getInstance(currentAccount).printingStrings.get(parentFragment.getDialogId()); if (printString != null) { printString = TextUtils.replace(printString, new String[]{"..."}, new String[]{""}); } CharSequence newSubtitle; if (printString == null || printString.length() == 0 || ChatObject.isChannel(chat) && !chat.megagroup) { setTypingAnimation(false); if (chat != null) { TLRPC.ChatFull info = parentFragment.getCurrentChatInfo(); if (ChatObject.isChannel(chat)) { if (info != null && info.participants_count != 0) { if (chat.megagroup && info.participants_count <= 200) { if (onlineCount > 1 && info.participants_count != 0) { newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", info.participants_count), LocaleController.formatPluralString("OnlineCount", onlineCount)); } else { newSubtitle = LocaleController.formatPluralString("Members", info.participants_count); } } else { int result[] = new int[1]; String shortNumber = LocaleController.formatShortNumber(info.participants_count, result); if (chat.megagroup) { newSubtitle = LocaleController.formatPluralString("Members", result[0]).replace(String.format("%d", result[0]), shortNumber); } else { newSubtitle = LocaleController.formatPluralString("Subscribers", result[0]).replace(String.format("%d", result[0]), shortNumber); } } } else { if (chat.megagroup) { newSubtitle = LocaleController.getString("Loading", R.string.Loading).toLowerCase(); } else { if ((chat.flags & TLRPC.CHAT_FLAG_IS_PUBLIC) != 0) { newSubtitle = LocaleController.getString("ChannelPublic", R.string.ChannelPublic).toLowerCase(); } else { newSubtitle = LocaleController.getString("ChannelPrivate", R.string.ChannelPrivate).toLowerCase(); } } } } else { if (ChatObject.isKickedFromChat(chat)) { newSubtitle = LocaleController.getString("YouWereKicked", R.string.YouWereKicked); } else if (ChatObject.isLeftFromChat(chat)) { newSubtitle = LocaleController.getString("YouLeft", R.string.YouLeft); } else { int count = chat.participants_count; if (info != null && info.participants != null) { count = info.participants.participants.size(); } if (onlineCount > 1 && count != 0) { newSubtitle = String.format("%s, %s", LocaleController.formatPluralString("Members", count), LocaleController.formatPluralString("OnlineCount", onlineCount)); } else { newSubtitle = LocaleController.formatPluralString("Members", count); } } } } else if (user != null) { TLRPC.User newUser = MessagesController.getInstance(currentAccount).getUser(user.id); if (newUser != null) { user = newUser; } String newStatus; if (user.id == UserConfig.getInstance(currentAccount).getClientUserId()) { newStatus = LocaleController.getString("ChatYourSelf", R.string.ChatYourSelf); } else if (user.id == 333000 || user.id == 777000) { newStatus = LocaleController.getString("ServiceNotifications", R.string.ServiceNotifications); } else if (user.bot) { newStatus = LocaleController.getString("Bot", R.string.Bot); } else { newStatus = LocaleController.formatUserStatus(currentAccount, user); } newSubtitle = newStatus; } else { newSubtitle = ""; } } else { newSubtitle = printString; setTypingAnimation(true); } if (lastSubtitle == null) { subtitleTextView.setText(newSubtitle); } else { lastSubtitle = newSubtitle; } }