Java Code Examples for org.telegram.messenger.LocaleController#LocaleInfo
The following examples show how to use
org.telegram.messenger.LocaleController#LocaleInfo .
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: LanguageSelectActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
@Override public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int position) { LanguageCell textSettingsCell = (LanguageCell) holder.itemView; LocaleController.LocaleInfo localeInfo; boolean last; if (search) { localeInfo = searchResult.get(position); last = position == searchResult.size() - 1; } else { localeInfo = sortedLanguages.get(position); last = position == sortedLanguages.size() - 1; } if (localeInfo.isLocal() && !localeInfo.isBuiltIn()) textSettingsCell.setLanguage(localeInfo, String.format("%1$s (%2$s)", localeInfo.name, LocaleController.getString("LanguageCustom", R.string.LanguageCustom)), !last); else textSettingsCell.setLanguage(localeInfo, null, !last); textSettingsCell.setLanguageSelected(localeInfo == LocaleController.getInstance().getCurrentLocaleInfo()); }
Example 2
Source File: LanguageSelectActivity.java From TelePlus-Android with GNU General Public License v2.0 | 6 votes |
private void fillLanguages() { sortedLanguages = new ArrayList<>(LocaleController.getInstance().languages); final LocaleController.LocaleInfo currentLocale = LocaleController.getInstance().getCurrentLocaleInfo(); Collections.sort(sortedLanguages, (o, o2) -> { if (o == currentLocale) { return -1; } else if (o2 == currentLocale) { return 1; } return o.name.compareTo(o2.name); }); }
Example 3
Source File: LanguageSelectActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) { AndroidUtilities.runOnUIThread(() -> { searchResult = arrCounties; searchListViewAdapter.notifyDataSetChanged(); }); }
Example 4
Source File: LanguageSelectActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: { LanguageCell textSettingsCell = (LanguageCell) holder.itemView; LocaleController.LocaleInfo localeInfo; boolean last; if (search) { localeInfo = searchResult.get(position); last = position == searchResult.size() - 1; } else if (!unofficialLanguages.isEmpty() && position >= 0 && position < unofficialLanguages.size()) { localeInfo = unofficialLanguages.get(position); last = position == unofficialLanguages.size() - 1; } else { if (!unofficialLanguages.isEmpty()) { position -= unofficialLanguages.size() + 1; } localeInfo = sortedLanguages.get(position); last = position == sortedLanguages.size() - 1; } if (localeInfo.isLocal()) { textSettingsCell.setLanguage(localeInfo, String.format("%1$s (%2$s)", localeInfo.name, LocaleController.getString("LanguageCustom", R.string.LanguageCustom)), !last); } else { textSettingsCell.setLanguage(localeInfo, null, !last); } textSettingsCell.setLanguageSelected(localeInfo == LocaleController.getInstance().getCurrentLocaleInfo()); break; } case 1: { ShadowSectionCell sectionCell = (ShadowSectionCell) holder.itemView; if (!unofficialLanguages.isEmpty() && position == unofficialLanguages.size()) { sectionCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } else { sectionCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } break; } } }
Example 5
Source File: LanguageCell.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
public void setLanguage(LocaleController.LocaleInfo language, String desc, boolean divider) { textView.setText(desc != null ? desc : language.name); textView2.setText(language.nameEnglish); currentLocale = language; needDivider = divider; }
Example 6
Source File: LanguageSelectActivity.java From Telegram with GNU General Public License v2.0 | 5 votes |
private void fillLanguages() { final LocaleController.LocaleInfo currentLocale = LocaleController.getInstance().getCurrentLocaleInfo(); Comparator<LocaleController.LocaleInfo> comparator = (o, o2) -> { if (o == currentLocale) { return -1; } else if (o2 == currentLocale) { return 1; } else if (o.serverIndex == o2.serverIndex) { return o.name.compareTo(o2.name); } if (o.serverIndex > o2.serverIndex) { return 1; } else if (o.serverIndex < o2.serverIndex) { return -1; } return 0; }; sortedLanguages = new ArrayList<>(); unofficialLanguages = new ArrayList<>(LocaleController.getInstance().unofficialLanguages); ArrayList<LocaleController.LocaleInfo> arrayList = LocaleController.getInstance().languages; for (int a = 0, size = arrayList.size(); a < size; a++) { LocaleController.LocaleInfo info = arrayList.get(a); if (info.serverIndex != Integer.MAX_VALUE) { sortedLanguages.add(info); } else { unofficialLanguages.add(info); } } Collections.sort(sortedLanguages, comparator); Collections.sort(unofficialLanguages, comparator); }
Example 7
Source File: LanguageSelectActivity.java From TelePlus-Android with GNU General Public License v2.0 | 5 votes |
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) { AndroidUtilities.runOnUIThread(() -> { searchResult = arrCounties; searchListViewAdapter.notifyDataSetChanged(); }); }
Example 8
Source File: LanguageSelectActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
@Override public void onBindViewHolder(RecyclerView.ViewHolder holder, int position) { switch (holder.getItemViewType()) { case 0: { LanguageCell textSettingsCell = (LanguageCell) holder.itemView; LocaleController.LocaleInfo localeInfo; boolean last; if (search) { localeInfo = searchResult.get(position); last = position == searchResult.size() - 1; } else if (!unofficialLanguages.isEmpty() && position >= 0 && position < unofficialLanguages.size()) { localeInfo = unofficialLanguages.get(position); last = position == unofficialLanguages.size() - 1; } else { if (!unofficialLanguages.isEmpty()) { position -= unofficialLanguages.size() + 1; } localeInfo = sortedLanguages.get(position); last = position == sortedLanguages.size() - 1; } if (localeInfo.isLocal()) { textSettingsCell.setLanguage(localeInfo, String.format("%1$s (%2$s)", localeInfo.name, LocaleController.getString("LanguageCustom", R.string.LanguageCustom)), !last); } else { textSettingsCell.setLanguage(localeInfo, null, !last); } textSettingsCell.setLanguageSelected(localeInfo == LocaleController.getInstance().getCurrentLocaleInfo()); break; } case 1: { ShadowSectionCell sectionCell = (ShadowSectionCell) holder.itemView; if (!unofficialLanguages.isEmpty() && position == unofficialLanguages.size()) { sectionCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider, Theme.key_windowBackgroundGrayShadow)); } else { sectionCell.setBackgroundDrawable(Theme.getThemedDrawable(mContext, R.drawable.greydivider_bottom, Theme.key_windowBackgroundGrayShadow)); } break; } } }
Example 9
Source File: LanguageSelectActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 5 votes |
private void fillLanguages() { final LocaleController.LocaleInfo currentLocale = LocaleController.getInstance().getCurrentLocaleInfo(); Comparator<LocaleController.LocaleInfo> comparator = (o, o2) -> { if (o == currentLocale) { return -1; } else if (o2 == currentLocale) { return 1; } else if (o.serverIndex == o2.serverIndex) { return o.name.compareTo(o2.name); } if (o.serverIndex > o2.serverIndex) { return 1; } else if (o.serverIndex < o2.serverIndex) { return -1; } return 0; }; sortedLanguages = new ArrayList<>(); unofficialLanguages = new ArrayList<>(LocaleController.getInstance().unofficialLanguages); ArrayList<LocaleController.LocaleInfo> arrayList = LocaleController.getInstance().languages; for (int a = 0, size = arrayList.size(); a < size; a++) { LocaleController.LocaleInfo info = arrayList.get(a); if (info.serverIndex != Integer.MAX_VALUE) { sortedLanguages.add(info); } else { unofficialLanguages.add(info); } } Collections.sort(sortedLanguages, comparator); Collections.sort(unofficialLanguages, comparator); }
Example 10
Source File: LanguageSelectActivity.java From Telegram with GNU General Public License v2.0 | 4 votes |
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) { AndroidUtilities.runOnUIThread(() -> { searchResult = arrCounties; searchListViewAdapter.notifyDataSetChanged(); }); }
Example 11
Source File: LanguageCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public LocaleController.LocaleInfo getCurrentLocale() { return currentLocale; }
Example 12
Source File: LanguageCell.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
public void setLanguage(LocaleController.LocaleInfo language, String desc, boolean divider) { textView.setText(desc != null ? desc : language.name); textView2.setText(language.nameEnglish); currentLocale = language; needDivider = divider; }
Example 13
Source File: IntroActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void checkContinueText() { LocaleController.LocaleInfo englishInfo = null; LocaleController.LocaleInfo systemInfo = null; LocaleController.LocaleInfo currentLocaleInfo = LocaleController.getInstance().getCurrentLocaleInfo(); final String systemLang = MessagesController.getInstance(currentAccount).suggestedLangCode; String arg = systemLang.contains("-") ? systemLang.split("-")[0] : systemLang; String alias = LocaleController.getLocaleAlias(arg); for (int a = 0; a < LocaleController.getInstance().languages.size(); a++) { LocaleController.LocaleInfo info = LocaleController.getInstance().languages.get(a); if (info.shortName.equals("en")) { englishInfo = info; } if (info.shortName.replace("_", "-").equals(systemLang) || info.shortName.equals(arg) || info.shortName.equals(alias)) { systemInfo = info; } if (englishInfo != null && systemInfo != null) { break; } } if (englishInfo == null || systemInfo == null || englishInfo == systemInfo) { return; } TLRPC.TL_langpack_getStrings req = new TLRPC.TL_langpack_getStrings(); if (systemInfo != currentLocaleInfo) { req.lang_code = systemInfo.getLangCode(); localeInfo = systemInfo; } else { req.lang_code = englishInfo.getLangCode(); localeInfo = englishInfo; } req.keys.add("ContinueOnThisLanguage"); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { if (response != null) { TLRPC.Vector vector = (TLRPC.Vector) response; if (vector.objects.isEmpty()) { return; } final TLRPC.LangPackString string = (TLRPC.LangPackString) vector.objects.get(0); if (string instanceof TLRPC.TL_langPackString) { AndroidUtilities.runOnUIThread(() -> { if (!destroyed) { textView.setText(string.value); SharedPreferences preferences = MessagesController.getGlobalMainSettings(); preferences.edit().putString("language_showed2", systemLang.toLowerCase()).commit(); } }); } } }, ConnectionsManager.RequestFlagWithoutLogin); }
Example 14
Source File: LanguageSelectActivity.java From Telegram-FOSS with GNU General Public License v2.0 | 4 votes |
private void updateSearchResults(final ArrayList<LocaleController.LocaleInfo> arrCounties) { AndroidUtilities.runOnUIThread(() -> { searchResult = arrCounties; searchListViewAdapter.notifyDataSetChanged(); }); }
Example 15
Source File: LanguageCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public LocaleController.LocaleInfo getCurrentLocale() { return currentLocale; }
Example 16
Source File: LanguageCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public void setLanguage(LocaleController.LocaleInfo language, String desc, boolean divider) { textView.setText(desc != null ? desc : language.name); textView2.setText(language.nameEnglish); currentLocale = language; needDivider = divider; }
Example 17
Source File: IntroActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void checkContinueText() { LocaleController.LocaleInfo englishInfo = null; LocaleController.LocaleInfo systemInfo = null; LocaleController.LocaleInfo currentLocaleInfo = LocaleController.getInstance().getCurrentLocaleInfo(); String systemLang = LocaleController.getSystemLocaleStringIso639().toLowerCase(); String arg = systemLang.contains("-") ? systemLang.split("-")[0] : systemLang; String alias = LocaleController.getLocaleAlias(arg); for (int a = 0; a < LocaleController.getInstance().languages.size(); a++) { LocaleController.LocaleInfo info = LocaleController.getInstance().languages.get(a); if (info.shortName.equals("en")) { englishInfo = info; } if (info.shortName.replace("_", "-").equals(systemLang) || info.shortName.equals(arg) || alias != null && info.shortName.equals(alias)) { systemInfo = info; } if (englishInfo != null && systemInfo != null) { break; } } if (englishInfo == null || systemInfo == null || englishInfo == systemInfo) { return; } TLRPC.TL_langpack_getStrings req = new TLRPC.TL_langpack_getStrings(); if (systemInfo != currentLocaleInfo) { req.lang_code = systemInfo.shortName.replace("_", "-"); localeInfo = systemInfo; } else { req.lang_code = englishInfo.shortName.replace("_", "-"); localeInfo = englishInfo; } req.keys.add("ContinueOnThisLanguage"); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { if (response != null) { TLRPC.Vector vector = (TLRPC.Vector) response; if (vector.objects.isEmpty()) { return; } final TLRPC.LangPackString string = (TLRPC.LangPackString) vector.objects.get(0); if (string instanceof TLRPC.TL_langPackString) { AndroidUtilities.runOnUIThread(() -> { if (!destroyed) { textView.setText(string.value); SharedPreferences preferences = MessagesController.getGlobalMainSettings(); preferences.edit().putString("language_showed2", LocaleController.getSystemLocaleStringIso639().toLowerCase()).apply(); } }); } } }, ConnectionsManager.RequestFlagWithoutLogin); }
Example 18
Source File: LanguageCell.java From Telegram with GNU General Public License v2.0 | 4 votes |
public LocaleController.LocaleInfo getCurrentLocale() { return currentLocale; }
Example 19
Source File: LanguageCell.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
public LocaleController.LocaleInfo getCurrentLocale() { return currentLocale; }
Example 20
Source File: IntroActivity.java From TelePlus-Android with GNU General Public License v2.0 | 4 votes |
private void checkContinueText() { LocaleController.LocaleInfo englishInfo = null; LocaleController.LocaleInfo systemInfo = null; LocaleController.LocaleInfo currentLocaleInfo = LocaleController.getInstance().getCurrentLocaleInfo(); String systemLang = LocaleController.getSystemLocaleStringIso639().toLowerCase(); String arg = systemLang.contains("-") ? systemLang.split("-")[0] : systemLang; String alias = LocaleController.getLocaleAlias(arg); for (int a = 0; a < LocaleController.getInstance().languages.size(); a++) { LocaleController.LocaleInfo info = LocaleController.getInstance().languages.get(a); if (info.shortName.equals("en")) { englishInfo = info; } if (info.shortName.replace("_", "-").equals(systemLang) || info.shortName.equals(arg) || alias != null && info.shortName.equals(alias)) { systemInfo = info; } if (englishInfo != null && systemInfo != null) { break; } } if (englishInfo == null || systemInfo == null || englishInfo == systemInfo) { return; } TLRPC.TL_langpack_getStrings req = new TLRPC.TL_langpack_getStrings(); if (systemInfo != currentLocaleInfo) { req.lang_code = systemInfo.shortName.replace("_", "-"); localeInfo = systemInfo; } else { req.lang_code = englishInfo.shortName.replace("_", "-"); localeInfo = englishInfo; } req.keys.add("ContinueOnThisLanguage"); ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> { if (response != null) { TLRPC.Vector vector = (TLRPC.Vector) response; if (vector.objects.isEmpty()) { return; } final TLRPC.LangPackString string = (TLRPC.LangPackString) vector.objects.get(0); if (string instanceof TLRPC.TL_langPackString) { AndroidUtilities.runOnUIThread(() -> { if (!destroyed) { textView.setText(string.value); SharedPreferences preferences = MessagesController.getGlobalMainSettings(); preferences.edit().putString("language_showed2", LocaleController.getSystemLocaleStringIso639().toLowerCase()).apply(); } }); } } }, ConnectionsManager.RequestFlagWithoutLogin); }