From 97ac030a650968b6ef77457add9d9f6528492d59 Mon Sep 17 00:00:00 2001 From: DrKLO Date: Thu, 3 Jul 2014 18:55:04 +0400 Subject: [PATCH] Added Plural Rules --- .../telegram/android/LocaleController.java | 318 ++++++++++++++++++ .../telegram/android/MessagesController.java | 2 +- .../java/org/telegram/ui/ChatActivity.java | 12 +- .../org/telegram/ui/ChatProfileActivity.java | 7 +- .../org/telegram/ui/GroupCreateActivity.java | 6 +- .../telegram/ui/GroupCreateFinalActivity.java | 6 +- .../java/org/telegram/ui/LaunchActivity.java | 2 - .../java/org/telegram/ui/MediaActivity.java | 1 + .../org/telegram/ui/PhotoPickerActivity.java | 1 + .../java/org/telegram/ui/PhotoViewer.java | 3 + .../org/telegram/ui/SettingsActivity.java | 1 + .../org/telegram/ui/UserProfileActivity.java | 1 + .../src/main/res/values-ar/strings.xml | 43 ++- .../src/main/res/values-de/strings.xml | 43 ++- .../src/main/res/values-es/strings.xml | 43 ++- .../src/main/res/values-it/strings.xml | 43 ++- .../src/main/res/values-nl/strings.xml | 43 ++- .../src/main/res/values-pt-rBR/strings.xml | 43 ++- .../src/main/res/values-pt-rPT/strings.xml | 43 ++- TMessagesProj/src/main/res/values/strings.xml | 43 ++- 20 files changed, 635 insertions(+), 69 deletions(-) diff --git a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java index 852e6435..df53514f 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java @@ -39,6 +39,13 @@ import java.util.TimeZone; public class LocaleController { + static final int QUANTITY_OTHER = 0x0000; + static final int QUANTITY_ZERO = 0x0001; + static final int QUANTITY_ONE = 0x0002; + static final int QUANTITY_TWO = 0x0004; + static final int QUANTITY_FEW = 0x0008; + static final int QUANTITY_MANY = 0x0010; + public static boolean isRTL = false; private static boolean is24HourFormat = false; public static FastDateFormat formatterDay; @@ -49,8 +56,11 @@ public class LocaleController { public static FastDateFormat chatDate; public static FastDateFormat chatFullDate; + private HashMap allRules = new HashMap(); + private Locale currentLocale; private Locale systemDefaultLocale; + private PluralRules currentPluralRules; private LocaleInfo currentLocaleInfo; private LocaleInfo defaultLocalInfo; private HashMap localeValues = new HashMap(); @@ -118,6 +128,30 @@ public class LocaleController { } public LocaleController() { + addRules(new String[]{"bem", "brx", "da", "de", "el", "en", "eo", "es", "et", "fi", "fo", "gl", "he", "iw", "it", "nb", + "nl", "nn", "no", "sv", "af", "bg", "bn", "ca", "eu", "fur", "fy", "gu", "ha", "is", "ku", + "lb", "ml", "mr", "nah", "ne", "om", "or", "pa", "pap", "ps", "so", "sq", "sw", "ta", "te", + "tk", "ur", "zu", "mn", "gsw", "chr", "rm", "pt"}, new PluralRules_One()); + addRules(new String[]{"cs", "sk"}, new PluralRules_Czech()); + addRules(new String[]{"ff", "fr", "kab"}, new PluralRules_French()); + addRules(new String[]{"hr", "ru", "sr", "uk", "be", "bs", "sh"}, new PluralRules_Balkan()); + addRules(new String[]{"lv"}, new PluralRules_Latvian()); + addRules(new String[]{"lt"}, new PluralRules_Lithuanian()); + addRules(new String[]{"pl"}, new PluralRules_Polish()); + addRules(new String[]{"ro", "mo"}, new PluralRules_Romanian()); + addRules(new String[]{"sl"}, new PluralRules_Slovenian()); + addRules(new String[]{"ar"}, new PluralRules_Arabic()); + addRules(new String[]{"mk"}, new PluralRules_Macedonian()); + addRules(new String[]{"cy"}, new PluralRules_Welsh()); + addRules(new String[]{"br"}, new PluralRules_Breton()); + addRules(new String[]{"lag"}, new PluralRules_Langi()); + addRules(new String[]{"shi"}, new PluralRules_Tachelhit()); + addRules(new String[]{"mt"}, new PluralRules_Maltese()); + addRules(new String[]{"ga", "se", "sma", "smi", "smj", "smn", "sms"}, new PluralRules_Two()); + addRules(new String[]{"ak", "am", "bh", "fil", "tl", "guw", "hi", "ln", "mg", "nso", "ti", "wa"}, new PluralRules_Zero()); + addRules(new String[]{"az", "bm", "fa", "ig", "hu", "ja", "kde", "kea", "ko", "my", "ses", "sg", "to", + "tr", "vi", "wo", "yo", "zh", "bo", "dz", "id", "jv", "ka", "km", "kn", "ms", "th"}, new PluralRules_None()); + LocaleInfo localeInfo = new LocaleInfo(); localeInfo.name = "English"; localeInfo.nameEnglish = "English"; @@ -239,6 +273,29 @@ public class LocaleController { } } + private void addRules(String[] languages, PluralRules rules) { + for (String language : languages) { + allRules.put(language, rules); + } + } + + private String stringForQuantity(int quantity) { + switch (quantity) { + case QUANTITY_ZERO: + return "zero"; + case QUANTITY_ONE: + return "one"; + case QUANTITY_TWO: + return "two"; + case QUANTITY_FEW: + return "few"; + case QUANTITY_MANY: + return "many"; + default: + return "other"; + } + } + private String getLocaleString(Locale locale) { if (locale == null) { return ""; @@ -461,6 +518,7 @@ public class LocaleController { } currentLocale = newLocale; currentLocaleInfo = localeInfo; + currentPluralRules = allRules.get(currentLocale.getLanguage()); changingConfiguration = true; Locale.setDefault(currentLocale); android.content.res.Configuration config = new android.content.res.Configuration(); @@ -491,6 +549,16 @@ public class LocaleController { return value; } + public static String formatPluralString(String key, int plural) { + if (key == null || key.length() == 0 || getInstance().currentPluralRules == null) { + return "LOC_ERR:" + key; + } + String param = getInstance().stringForQuantity(getInstance().currentPluralRules.quantityForNumber(plural)); + param = key + "_" + param; + int resourceId = ApplicationLoader.applicationContext.getResources().getIdentifier(param, "string", ApplicationLoader.applicationContext.getPackageName()); + return formatString(param, resourceId, plural); + } + public static String formatString(String key, int res, Object... args) { String value = getInstance().localeValues.get(key); if (value == null) { @@ -540,6 +608,7 @@ public class LocaleController { recreateFormatters(); } currentLocale = newLocale; + currentPluralRules = allRules.get(currentLocale.getLanguage()); } } } @@ -676,4 +745,253 @@ public class LocaleController { } } } + + + abstract public static class PluralRules { + abstract int quantityForNumber(int n); + } + + public static class PluralRules_Zero extends PluralRules { + public int quantityForNumber(int count) { + if (count == 0 || count == 1) { + return QUANTITY_ONE; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Welsh extends PluralRules { + public int quantityForNumber(int count) { + if (count == 0) { + return QUANTITY_ZERO; + } else if (count == 1) { + return QUANTITY_ONE; + } else if (count == 2) { + return QUANTITY_TWO; + } else if (count == 3) { + return QUANTITY_FEW; + } else if (count == 6) { + return QUANTITY_MANY; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Two extends PluralRules { + public int quantityForNumber(int count) { + if (count == 1) { + return QUANTITY_ONE; + } else if (count == 2) { + return QUANTITY_TWO; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Tachelhit extends PluralRules { + public int quantityForNumber(int count) { + if (count >= 0 && count <= 1) { + return QUANTITY_ONE; + } else if (count >= 2 && count <= 10) { + return QUANTITY_FEW; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Slovenian extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + if (rem100 == 1) { + return QUANTITY_ONE; + } else if (rem100 == 2) { + return QUANTITY_TWO; + } else if (rem100 >= 3 && rem100 <= 4) { + return QUANTITY_FEW; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Romanian extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + if (count == 1) { + return QUANTITY_ONE; + } else if ((count == 0 || (rem100 >= 1 && rem100 <= 19))) { + return QUANTITY_FEW; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Polish extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + int rem10 = count % 10; + if (count == 1) { + return QUANTITY_ONE; + } else if (rem10 >= 2 && rem10 <= 4 && !(rem100 >= 12 && rem100 <= 14) && !(rem100 >= 22 && rem100 <= 24)) { + return QUANTITY_FEW; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_One extends PluralRules { + public int quantityForNumber(int count) { + return count == 1 ? QUANTITY_ONE : QUANTITY_OTHER; + } + } + + public static class PluralRules_None extends PluralRules { + public int quantityForNumber(int count) { + return QUANTITY_OTHER; + } + } + + public static class PluralRules_Maltese extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + if (count == 1) { + return QUANTITY_ONE; + } else if (count == 0 || (rem100 >= 2 && rem100 <= 10)) { + return QUANTITY_FEW; + } else if (rem100 >= 11 && rem100 <= 19) { + return QUANTITY_MANY; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Macedonian extends PluralRules { + public int quantityForNumber(int count) { + if (count % 10 == 1 && count != 11) { + return QUANTITY_ONE; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Lithuanian extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + int rem10 = count % 10; + if (rem10 == 1 && !(rem100 >= 11 && rem100 <= 19)) { + return QUANTITY_ONE; + } else if (rem10 >= 2 && rem10 <= 9 && !(rem100 >= 11 && rem100 <= 19)) { + return QUANTITY_FEW; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Latvian extends PluralRules { + public int quantityForNumber(int count) { + if (count == 0) { + return QUANTITY_ZERO; + } else if (count % 10 == 1 && count % 100 != 11) { + return QUANTITY_ONE; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Langi extends PluralRules { + public int quantityForNumber(int count) { + if (count == 0) { + return QUANTITY_ZERO; + } else if (count > 0 && count < 2) { + return QUANTITY_ONE; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_French extends PluralRules { + public int quantityForNumber(int count) { + if (count >= 0 && count < 2) { + return QUANTITY_ONE; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Czech extends PluralRules { + public int quantityForNumber(int count) { + if (count == 1) { + return QUANTITY_ONE; + } else if (count >= 2 && count <= 4) { + return QUANTITY_FEW; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Breton extends PluralRules { + public int quantityForNumber(int count) { + if (count == 0) { + return QUANTITY_ZERO; + } else if (count == 1) { + return QUANTITY_ONE; + } else if (count == 2) { + return QUANTITY_TWO; + } else if (count == 3) { + return QUANTITY_FEW; + } else if (count == 6) { + return QUANTITY_MANY; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Balkan extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + int rem10 = count % 10; + if (rem10 == 1 && rem100 != 11) { + return QUANTITY_ONE; + } else if (rem10 >= 2 && rem10 <= 4 && !(rem100 >= 12 && rem100 <= 14)) { + return QUANTITY_FEW; + } else if ((rem10 == 0 || (rem10 >= 5 && rem10 <= 9) || (rem100 >= 11 && rem100 <= 14))) { + return QUANTITY_MANY; + } else { + return QUANTITY_OTHER; + } + } + } + + public static class PluralRules_Arabic extends PluralRules { + public int quantityForNumber(int count) { + int rem100 = count % 100; + if (count == 0) { + return QUANTITY_ZERO; + } else if (count == 1) { + return QUANTITY_ONE; + } else if (count == 2) { + return QUANTITY_TWO; + } else if (rem100 >= 3 && rem100 <= 10) { + return QUANTITY_FEW; + } else if (rem100 >= 11 && rem100 <= 99) { + return QUANTITY_MANY; + } else { + return QUANTITY_OTHER; + } + } + } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java index e514dc6c..8d7d8974 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java @@ -998,7 +998,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (label.length() != 0) { if (count > 1) { if (arr.size() > 2) { - newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s %s", label, String.format(LocaleController.getString("AndMoreTyping", R.string.AndMoreTyping), arr.size() - 2), LocaleController.getString("AreTyping", R.string.AreTyping)))); + newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, LocaleController.formatPluralString("AndMoreTyping", arr.size() - 2)))); } else { newPrintingStrings.put(key, Html.fromHtml(String.format("%s %s", label, LocaleController.getString("AreTyping", R.string.AreTyping)))); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 712c2cf5..894ad061 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1210,9 +1210,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not actionBarLayer.setSubtitle(LocaleController.getString("YouLeft", R.string.YouLeft)); } else { if (onlineCount > 0 && currentChat.participants_count != 0) { - actionBarLayer.setSubtitle(String.format("%d %s, %d %s", currentChat.participants_count, LocaleController.getString("Members", R.string.Members), onlineCount, LocaleController.getString("Online", R.string.Online))); + actionBarLayer.setSubtitle(String.format("%s, %d %s", LocaleController.formatPluralString("Members", currentChat.participants_count), onlineCount, LocaleController.getString("Online", R.string.Online))); } else { - actionBarLayer.setSubtitle(String.format("%d %s", currentChat.participants_count, LocaleController.getString("Members", R.string.Members))); + actionBarLayer.setSubtitle(LocaleController.formatPluralString("Members", currentChat.participants_count)); } } } else if (currentUser != null) { @@ -3261,6 +3261,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not return; } if (message.type == 1) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(message, ChatActivity.this); } else if (message.type == 3) { try { @@ -3460,11 +3461,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not addContactView.setVisibility(View.GONE); } } else if (type == 7) { - if (unread_to_load == 1) { - messageTextView.setText(LocaleController.formatString("OneNewMessage", R.string.OneNewMessage, unread_to_load)); - } else { - messageTextView.setText(LocaleController.formatString("FewNewMessages", R.string.FewNewMessages, unread_to_load)); - } + messageTextView.setText(LocaleController.formatPluralString("NewMessages", unread_to_load)); } else if (type == 8 || type == 9) { TLRPC.Document document = message.messageOwner.media.document; if (document instanceof TLRPC.TL_document || document instanceof TLRPC.TL_documentEncrypted) { @@ -3893,6 +3890,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } if (message != null) { if (message.type == 11) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(message, ChatActivity.this); } else if (message.type == 8 || message.type == 9) { File f = null; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java index 6eb1d792..edd21c47 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatProfileActivity.java @@ -443,6 +443,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen if (action == 0) { TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id); if (chat.photo != null && chat.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(chat.photo.photo_big, this); } } else if (action == 1) { @@ -603,9 +604,9 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen textView.setText(chat.title); if (chat.participants_count != 0 && onlineCount > 0) { - onlineText.setText(Html.fromHtml(String.format("%d %s, %d %s", chat.participants_count, LocaleController.getString("Members", R.string.Members), onlineCount, LocaleController.getString("Online", R.string.Online)))); + onlineText.setText(Html.fromHtml(String.format("%s, %d %s", LocaleController.formatPluralString("Members", chat.participants_count), onlineCount, LocaleController.getString("Online", R.string.Online)))); } else { - onlineText.setText(String.format("%d %s", chat.participants_count, LocaleController.getString("Members", R.string.Members))); + onlineText.setText(LocaleController.formatPluralString("Members", chat.participants_count)); } TLRPC.FileLocation photo = null; @@ -629,7 +630,7 @@ public class ChatProfileActivity extends BaseFragment implements NotificationCen textView.setText(LocaleController.getString("SHAREDMEDIA", R.string.SHAREDMEDIA)); } else if (i == membersSectionRow) { TLRPC.Chat chat = MessagesController.getInstance().chats.get(chat_id); - textView.setText(String.format("%d %s", chat.participants_count, LocaleController.getString("MEMBERS", R.string.MEMBERS))); + textView.setText(LocaleController.formatPluralString("Members", chat.participants_count).toUpperCase()); } } else if (type == 2) { if (view == null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java index 28e7f77e..6baa5a90 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateActivity.java @@ -127,7 +127,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen actionBarLayer.setDisplayHomeAsUpEnabled(true, R.drawable.ic_ab_back); actionBarLayer.setBackOverlay(R.layout.updating_state_layout); actionBarLayer.setTitle(LocaleController.getString("NewGroup", R.string.NewGroup)); - actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members))); + actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200)); actionBarLayer.setActionBarMenuOnItemClick(new ActionBarLayer.ActionBarMenuOnItemClick() { @Override @@ -201,7 +201,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen selectedContacts.remove(sp.uid); } } - actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members))); + actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200)); listView.invalidateViews(); } else { search = true; @@ -267,7 +267,7 @@ public class GroupCreateActivity extends BaseFragment implements NotificationCen span.uid = user.id; ignoreChange = false; } - actionBarLayer.setSubtitle(String.format("%d/200 %s", selectedContacts.size(), LocaleController.getString("Members", R.string.Members))); + actionBarLayer.setSubtitle(LocaleController.formatString("MembersCount", R.string.MembersCount, selectedContacts.size(), 200)); if (searching || searchWas) { searching = false; searchWas = false; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java index ff2380ce..6d8e2c55 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/GroupCreateFinalActivity.java @@ -407,11 +407,7 @@ public class GroupCreateFinalActivity extends BaseFragment implements Notificati convertView.setBackgroundColor(0xffffffff); } TextView textView = (TextView)convertView.findViewById(R.id.settings_section_text); - if (selectedContacts.size() == 1) { - textView.setText(selectedContacts.size() + " " + LocaleController.getString("MEMBER", R.string.MEMBER)); - } else { - textView.setText(selectedContacts.size() + " " + LocaleController.getString("MEMBERS", R.string.MEMBERS)); - } + textView.setText(LocaleController.formatPluralString("Members", selectedContacts.size()).toUpperCase()); return convertView; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index e0e7c221..fc8b21b2 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -140,8 +140,6 @@ public class LaunchActivity extends ActionBarActivity implements NotificationCen } handleIntent(getIntent(), false, savedInstanceState != null); - - PhotoViewer.getInstance().setParentActivity(this); } private void handleIntent(Intent intent, boolean isNew, boolean restore) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java index 25513bb8..52a10241 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/MediaActivity.java @@ -114,6 +114,7 @@ public class MediaActivity extends BaseFragment implements NotificationCenter.No listView.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView adapterView, View view, int i, long l) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(messages, i, MediaActivity.this); } }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java index ab4777b0..093555c6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoPickerActivity.java @@ -159,6 +159,7 @@ public class PhotoPickerActivity extends BaseFragment implements NotificationCen if (i < 0 || i >= selectedAlbum.photos.size()) { return; } + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhotoForSelect(selectedAlbum.photos, i, PhotoPickerActivity.this); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 668bd25d..d7211fb6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -445,6 +445,9 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } public void setParentActivity(Activity activity) { + if (parentActivity == activity) { + return; + } parentActivity = activity; scroller = new Scroller(activity); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java index 082a3d66..98e7a401 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java @@ -748,6 +748,7 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter if (i == 0 && full) { TLRPC.User user = MessagesController.getInstance().users.get(UserConfig.getClientUserId()); if (user != null && user.photo != null && user.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(user.photo.photo_big, SettingsActivity.this); } } else if (i == 0 && !full || i == 1 && full) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java index 63ba93f3..9d1c47c1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/UserProfileActivity.java @@ -524,6 +524,7 @@ public class UserProfileActivity extends BaseFragment implements NotificationCen public void onClick(View view) { TLRPC.User user = MessagesController.getInstance().users.get(user_id); if (user.photo != null && user.photo.photo_big != null) { + PhotoViewer.getInstance().setParentActivity(getParentActivity()); PhotoViewer.getInstance().openPhoto(user.photo.photo_big, UserProfileActivity.this); } } diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml index d76a09ed..f6140b69 100644 --- a/TMessagesProj/src/main/res/values-ar/strings.xml +++ b/TMessagesProj/src/main/res/values-ar/strings.xml @@ -76,7 +76,6 @@ أرفق يكتب… يكتبون… - و %d آخرون كتبون هل يوجد لديك سؤال\nحول تيليجرام؟ التقط صورة صورة @@ -90,7 +89,6 @@ الرسالة المعاد توجيهها من لا توجد رسائل أحدث - أعضاء الرسالة أكتب رسالة تحميل @@ -104,8 +102,6 @@ لا تترك أثرًا في خوادمنا تمتلك عداد للتدمير الذاتي لا تسمح بتحويل الرسائل - %1$d رسالة جديدة - %1$d رسائل جديدة لقد تم إخراجك من هذه المجموعة لقد قمت بمغادرة المجموعة حذف هذه المجموعة @@ -172,10 +168,9 @@ إرسال الرسالة إلى... أدخل اسم للمجموعة - عضو اسم المجموعة - أعضاء جميع جهات الاتصال + %1$d/%2$d members أدخل سم للمجموعة @@ -385,6 +380,42 @@ تيليجرام]]> الرسائل مشفرة بشكل قوي وتستطيع تدمير ذاتها إبدأ المراسلة + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index 1f6fdc2c..d59ae358 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -76,7 +76,6 @@ Anhängen schreibt... tippen… - und %d weitere Personen Du hast eine Frage\nzu Telegram? Foto aufnehmen Galerie @@ -90,7 +89,6 @@ Weitergeleitete Nachricht Von Keine aktuellen - Mitglieder Nachricht Nachricht verfassen Download @@ -104,8 +102,6 @@ Hinterlassen keine Spuren auf unseren Servern Haben einen Selbstzerstörungs-Timer Erlauben keine Weiterleitung von Nachrichten - %1$d neue Nachricht - %1$d neue Nachrichten Du wurdest aus der Gruppe entfernt Du hast die Gruppe verlassen Diese Gruppe löschen @@ -172,10 +168,9 @@ Sende Nachricht an… Gruppennamen eingeben - MITGLIED Gruppenname - MITGLIEDER ALLE KONTAKTE + %1$d/%2$d members GRUPPENNAMEN EINGEBEN @@ -385,6 +380,42 @@ Telegram]]>-Nachrichten sind stark verschlüsselt und können sich selbst zerstören Jetzt beginnen + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index 913d7583..bb22fce3 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -76,7 +76,6 @@ Adjuntar está escribiendo... están escribiendo... - y %d personas más ¿Tienes una pregunta\nsobre Telegram? Hacer foto Galería @@ -90,7 +89,6 @@ Mensaje reenviado De No hay recientes - miembros Mensaje Escribe un mensaje Descargar @@ -104,8 +102,6 @@ No dejan rastro en nuestros servidores Tienen autodestrucción de mensajes No permiten reenvíos de mensajes - %1$d nuevo mensaje - %1$d nuevos mensajes Has sido expulsado de este grupo Has abandonado este grupo Eliminar este grupo @@ -172,10 +168,9 @@ Enviar mensaje a... El nombre del grupo - MIEMBRO Nombre del grupo - MIEMBROS TODOS LOS CONTACTOS + %1$d/%2$d members INGRESA EL NOMBRE DEL GRUPO @@ -385,6 +380,42 @@ Los mensajes de Telegram]]> están fuertemente]]>cifrados y se pueden autodestruir. Empieza a conversar + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index 8d1f05d6..741d366d 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -76,7 +76,6 @@ Allega sta scrivendo… stanno scrivendo… - e altre %d persone Hai una domanda\nsu Telegram? Scatta una foto Galleria @@ -90,7 +89,6 @@ Messaggio inoltrato Da Nessuno recente - membri Messaggio Scrivi il messaggio Scarica @@ -104,8 +102,6 @@ Non lasciano traccia sui nostri server Hanno un contatore di autodistruzione Non permettono l’inoltro - %1$d nuovo messaggio - %1$d nuovi messaggi Sei stato espulso da questo gruppo Hai lasciato il gruppo Elimina questo gruppo @@ -172,10 +168,9 @@ Invia messaggio a... Immetti il nome del gruppo - MEMBRO Nome gruppo - MEMBRI TUTTI I CONTATTI + %1$d/%2$d members INSERISCI IL NOME DEL GRUPPO @@ -385,6 +380,42 @@ Telegram]]> cifra in maniera sicura i messaggi e può far sì che si autodistruggano Inizia a inviare messaggi + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index 1e027d64..e3005f5e 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -76,7 +76,6 @@ Bijvoegen is aan het typen… zijn aan het typen… - en nog %d personen Heb je een vraag\nover Telegram? Foto maken Galerij @@ -90,7 +89,6 @@ Doorgestuurd bericht Van Niets recents - deelnemers Bericht Typ een bericht... Downloaden @@ -104,8 +102,6 @@ laten geen sporen achter op onze server verlopen automatisch staan doorsturen niet toe - %1$d nieuw bericht - %1$d nieuwe berichten Je bent verwijderd uit deze groep Je hebt deze groep verlaten Deze groep verwijderen @@ -172,10 +168,9 @@ Bericht verzenden naar… Groepsnaam... - DEELNEMER Groepsnaam - DEELNEMERS ALLE CONTACTEN + %1$d/%2$d members GROEPSNAAM INSTELLEN @@ -385,6 +380,42 @@ Telegram]]> berichten zijn sterk versleuteld en kunnen zichzelf vernietigen Begin nu met chatten + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 40f1347a..21691d0a 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -76,7 +76,6 @@ Anexar está escrevendo... estão escrevendo... - e %d mais pessoas Tem alguma dúvida\nsobre o Telegram? Tirar foto Galeria @@ -90,7 +89,6 @@ Mensagem encaminhada De Nada recente - membros Mensagem Escrever mensagem Baixar @@ -104,8 +102,6 @@ Não deixam rastro em nossos servidores Têm temporizador para a autodestruição das mensagens Não permitem o reencaminhamento - %1$d nova mensagem - %1$d novas mensagens Você foi removido deste grupo Você saiu deste grupo Apagar este grupo @@ -172,10 +168,9 @@ Enviar mensagem para... Digite o nome do grupo - MEMBRO Nome do grupo - MEMBROS TODOS OS CONTATOS + %1$d/%2$d members DIGITE O NOME DO GRUPO @@ -385,6 +380,42 @@ As mensagens do Telegram]]> são fortemente criptografadas]]>e podem se autodestruir Comece a conversar + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index e7739fea..2a96eb91 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -76,7 +76,6 @@ Anexar está a escrever... estão a escrever... - e mais %d pessoas Tem alguma pergunta\nacerca do Telegram? Tirar uma foto Galeria @@ -90,7 +89,6 @@ Mensagem reencaminhada De Não há recentes - membros Mensagem Escrever mensagem Transferir @@ -104,8 +102,6 @@ Não deixam rasto nos nossos servidores Têm temporizador para a autodestruição das mensagens Não permitem o reencaminhamento - %1$d nova mensagem - %1$d novas mensagens Foi removido do grupo Deixou este grupo Eliminar este grupo @@ -172,10 +168,9 @@ Enviar mensagem para... Introduza o nome do grupo - MEMBRO Nome do grupo - MEMBROS TODOS OS CONTACTOS + %1$d/%2$d members INTRODUZA O NOME DO GRUPO @@ -385,6 +380,42 @@ As mensagens do Telegram]]> estão fortemente encriptadas]]>e podem ser autodestruídas Comece a conversar + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index e8955b69..0c9a7fed 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -76,7 +76,6 @@ Attach is typing... are typing... - and %d more people Got a question\nabout Telegram? Take photo Gallery @@ -90,7 +89,6 @@ Forwarded message From No recent - members Message Type message Download @@ -104,8 +102,6 @@ Leave no trace on our servers Have a self-destruct timer Do not allow forwarding - %1$d new message - %1$d new messages You were removed from this group You left this group Delete this group @@ -172,10 +168,9 @@ Send message to... Enter group name - MEMBER Group name - MEMBERS ALL CONTACTS + %1$d/%2$d members ENTER GROUP NAME @@ -385,6 +380,42 @@ Telegram]]> messages are heavily encrypted]]>and can self-destruct Start Messaging + + no members + %1$d member + %1$d members + %1$d members + %1$d members + %1$d members + + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + and %1$d more people are typing + + no new messages + %1$d new message + %1$d new messages + %1$d new messages + %1$d new messages + %1$d new messages + + no messages + %1$d message + %1$d messages + %1$d messages + %1$d messages + %1$d messages + + from no contacts + from %1$d contact + from %1$d contacts + from %1$d contacts + from %1$d contacts + from %1$d contacts + CACHE_TAG \ No newline at end of file