diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 3a416eb7..c67ee3ba 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -80,7 +80,7 @@ android { defaultConfig { minSdkVersion 8 targetSdkVersion 21 - versionCode 392 + versionCode 393 versionName "2.0.3" } } diff --git a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java index 6da2ae3b..ce0f2472 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/LocaleController.java @@ -791,6 +791,11 @@ public class LocaleController { user.status.expires = -102; } } + if (user != null && user.status != null && user.status.expires <= 0) { + if (MessagesController.getInstance().onlinePrivacy.containsKey(user.id)) { + return getString("Online", R.string.Online); + } + } if (user == null || user.status == null || user.status.expires == 0 || user instanceof TLRPC.TL_userDeleted || user instanceof TLRPC.TL_userEmpty) { return getString("ALongTimeAgo", R.string.ALongTimeAgo); } else { diff --git a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java index f42c63ca..21c5c230 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/MessagesController.java @@ -52,9 +52,10 @@ public class MessagesController implements NotificationCenter.NotificationCenter public ArrayList dialogsServerOnly = new ArrayList(); public ConcurrentHashMap dialogs_dict = new ConcurrentHashMap(100, 1.0f, 2); public HashMap dialogMessage = new HashMap(); - public ConcurrentHashMap> printingUsers = new ConcurrentHashMap>(100, 1.0f, 2); + public ConcurrentHashMap> printingUsers = new ConcurrentHashMap>(20, 1.0f, 2); public HashMap printingStrings = new HashMap(); public HashMap sendingTypings = new HashMap(); + public ConcurrentHashMap onlinePrivacy = new ConcurrentHashMap(20, 1.0f, 2); private int lastPrintingStringCount = 0; public boolean loadingBlockedUsers = false; @@ -316,6 +317,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter dialogMessage.clear(); printingUsers.clear(); printingStrings.clear(); + onlinePrivacy.clear(); totalDialogsCount = 0; lastPrintingStringCount = 0; updatesQueue.clear(); @@ -1068,15 +1070,17 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (offset == 0) { TLRPC.TL_dialog dialog = dialogs_dict.get(did); - if (!onlyHistory) { - dialogs.remove(dialog); - dialogsServerOnly.remove(dialog); - dialogs_dict.remove(did); - totalDialogsCount--; - } else { - dialog.unread_count = 0; + if (dialog != null) { + if (!onlyHistory) { + dialogs.remove(dialog); + dialogsServerOnly.remove(dialog); + dialogs_dict.remove(did); + totalDialogsCount--; + } else { + dialog.unread_count = 0; + } + dialogMessage.remove(dialog.top_message); } - dialogMessage.remove(dialog.top_message); MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @Override public void run() { @@ -1214,6 +1218,29 @@ public class MessagesController implements NotificationCenter.NotificationCenter processUpdatesQueue(0); } } + if (!onlinePrivacy.isEmpty()) { + ArrayList toRemove = null; + int currentServerTime = ConnectionsManager.getInstance().getCurrentTime(); + for (ConcurrentHashMap.Entry entry : onlinePrivacy.entrySet()) { + if (entry.getValue() < currentServerTime - 30) { + if (toRemove == null) { + toRemove = new ArrayList(); + } + toRemove.add(entry.getKey()); + } + } + if (toRemove != null) { + for (Integer uid : toRemove) { + onlinePrivacy.remove(uid); + } + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_STATUS); + } + }); + } + } if (!printingUsers.isEmpty() || lastPrintingStringCount != printingUsers.size()) { boolean updated = false; ArrayList keys = new ArrayList(printingUsers.keySet()); @@ -2678,12 +2705,18 @@ public class MessagesController implements NotificationCenter.NotificationCenter boolean needGetDiff = false; boolean needReceivedQueue = false; boolean addedToQueue = false; + boolean updateStatus = false; if (updates instanceof TLRPC.TL_updateShort) { ArrayList arr = new ArrayList(); arr.add(updates.update); processUpdateArray(arr, null, null); } else if (updates instanceof TLRPC.TL_updateShortChatMessage) { - boolean missingData = getChat(updates.chat_id) == null || getUser(updates.from_id) == null; + TLRPC.User user = getUser(updates.from_id); + if (user != null && user.status != null && user.status.expires <= 0) { + onlinePrivacy.put(user.id, ConnectionsManager.getInstance().getCurrentTime()); + updateStatus = true; + } + boolean missingData = getChat(updates.chat_id) == null || user == null; if (missingData) { needGetDiff = true; } else { @@ -2748,7 +2781,12 @@ public class MessagesController implements NotificationCenter.NotificationCenter } } } else if (updates instanceof TLRPC.TL_updateShortMessage) { - boolean missingData = getUser(updates.from_id) == null; + TLRPC.User user = getUser(updates.from_id); + if (user != null && user.status != null && user.status.expires <= 0) { + onlinePrivacy.put(user.id, ConnectionsManager.getInstance().getCurrentTime()); + updateStatus = true; + } + boolean missingData = user == null; if (missingData) { needGetDiff = true; } else { @@ -2895,6 +2933,14 @@ public class MessagesController implements NotificationCenter.NotificationCenter } }); } + if (updateStatus) { + AndroidUtilities.runOnUIThread(new Runnable() { + @Override + public void run() { + NotificationCenter.getInstance().postNotificationName(NotificationCenter.updateInterfaces, UPDATE_MASK_STATUS); + } + }); + } MessagesStorage.getInstance().saveDiffParams(MessagesStorage.lastSeqValue, MessagesStorage.lastPtsValue, MessagesStorage.lastDateValue, MessagesStorage.lastQtsValue); } @@ -2954,9 +3000,15 @@ public class MessagesController implements NotificationCenter.NotificationCenter if (update instanceof TLRPC.TL_updateNewMessage) { TLRPC.TL_updateNewMessage upd = (TLRPC.TL_updateNewMessage)update; if (checkForUsers) { - if (usersDict.get(upd.message.from_id) == null && getUser(upd.message.from_id) == null || upd.message.to_id.chat_id != 0 && chatsDict.get(upd.message.to_id.chat_id) == null && getChat(upd.message.to_id.chat_id) == null) { + TLRPC.User user = getUser(upd.message.from_id); + if (usersDict.get(upd.message.from_id) == null && user == null || upd.message.to_id.chat_id != 0 && chatsDict.get(upd.message.to_id.chat_id) == null && getChat(upd.message.to_id.chat_id) == null) { return false; } + + if (user != null && user.status != null && user.status.expires <= 0) { + onlinePrivacy.put(upd.message.from_id, ConnectionsManager.getInstance().getCurrentTime()); + interfaceUpdateMask |= UPDATE_MASK_STATUS; + } } messagesArr.add(upd.message); MessageObject obj = new MessageObject(upd.message, usersDict, 2); @@ -3018,6 +3070,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter arr.add(newUser); printChanged = true; } + onlinePrivacy.put(update.user_id, ConnectionsManager.getInstance().getCurrentTime()); } } else if (update instanceof TLRPC.TL_updateChatParticipants) { interfaceUpdateMask |= UPDATE_MASK_CHAT_MEMBERS; @@ -3143,6 +3196,7 @@ public class MessagesController implements NotificationCenter.NotificationCenter arr.add(newUser); printChanged = true; } + onlinePrivacy.put(update.user_id, ConnectionsManager.getInstance().getCurrentTime()); } } else if (update instanceof TLRPC.TL_updateEncryptedMessagesRead) { markAsReadEncrypted.put(update.chat_id, Math.max(update.max_date, update.date)); diff --git a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java index 3b5a7a3b..7ad65c2b 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/android/NotificationsController.java @@ -8,6 +8,7 @@ package org.telegram.android; +import android.app.Activity; import android.app.AlarmManager; import android.app.PendingIntent; import android.content.Context; @@ -235,8 +236,10 @@ public class NotificationsController { try { AlarmManager alarm = (AlarmManager) ApplicationLoader.applicationContext.getSystemService(Context.ALARM_SERVICE); PendingIntent pintent = PendingIntent.getService(ApplicationLoader.applicationContext, 0, new Intent(ApplicationLoader.applicationContext, NotificationRepeat.class), 0); - if (personal_count > 0) { - alarm.set(AlarmManager.ELAPSED_REALTIME_WAKEUP, SystemClock.elapsedRealtime() + 60 * 60 * 1000, pintent); + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + int minutes = preferences.getInt("repeat_messages", 60); + if (minutes > 0 || personal_count > 0) { + alarm.set(AlarmManager.RTC_WAKEUP, System.currentTimeMillis() + minutes * 60 * 1000, pintent); } else { alarm.cancel(pintent); } @@ -289,6 +292,9 @@ public class NotificationsController { boolean inAppSounds = false; boolean inAppVibrate = false; boolean inAppPreview = false; + boolean inAppPriority = false; + int priority = 0; + int priority_override = 0; int vibrate_override = 0; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Context.MODE_PRIVATE); @@ -302,7 +308,9 @@ public class NotificationsController { inAppSounds = preferences.getBoolean("EnableInAppSounds", true); inAppVibrate = preferences.getBoolean("EnableInAppVibrate", true); inAppPreview = preferences.getBoolean("EnableInAppPreview", true); + inAppPriority = preferences.getBoolean("EnableInAppPriority", false); vibrate_override = preferences.getInt("vibrate_" + dialog_id, 0); + priority_override = preferences.getInt("priority_" + dialog_id, 3); choosenSoundPath = preferences.getString("sound_path_" + dialog_id, null); if (chat_id != 0) { @@ -312,6 +320,7 @@ public class NotificationsController { choosenSoundPath = preferences.getString("GroupSoundPath", defaultPath); } needVibrate = preferences.getInt("vibrate_group", 0); + priority = preferences.getInt("priority_group", 1); ledColor = preferences.getInt("GroupLed", 0xff00ff00); } else if (user_id != 0) { if (choosenSoundPath != null && choosenSoundPath.equals(defaultPath)) { @@ -320,12 +329,17 @@ public class NotificationsController { choosenSoundPath = preferences.getString("GlobalSoundPath", defaultPath); } needVibrate = preferences.getInt("vibrate_messages", 0); + priority = preferences.getInt("priority_group", 1); ledColor = preferences.getInt("MessagesLed", 0xff00ff00); } if (preferences.contains("color_" + dialog_id)) { ledColor = preferences.getInt("color_" + dialog_id, 0); } + if (priority_override != 3) { + priority = priority_override; + } + if (needVibrate == 2 && (vibrate_override == 1 || vibrate_override == 3 || vibrate_override == 5) || needVibrate != 2 && vibrate_override == 2 || vibrate_override != 0) { needVibrate = vibrate_override; } @@ -336,6 +350,11 @@ public class NotificationsController { if (!inAppVibrate) { needVibrate = 2; } + if (!inAppPriority) { + priority = 0; + } else if (priority == 2) { + priority = 1; + } } } @@ -397,9 +416,13 @@ public class NotificationsController { .setGroup("messages") .setGroupSummary(true); - //if (ApplicationLoader.mainInterfacePaused) { - // mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH); - //} + if (priority == 0) { + mBuilder.setPriority(NotificationCompat.PRIORITY_DEFAULT); + } else if (priority == 1) { + mBuilder.setPriority(NotificationCompat.PRIORITY_HIGH); + } else if (priority == 2) { + mBuilder.setPriority(NotificationCompat.PRIORITY_MAX); + } String lastMessage = null; String lastMessageFull = null; diff --git a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java index 9146bd60..bdf376f5 100644 --- a/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/android/SendMessagesHelper.java @@ -1856,10 +1856,21 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } } - private static void prepareSendingDocumentInternal(final String path, String originalPath, final long dialog_id) { - if (path == null || path.length() == 0) { + private static void prepareSendingDocumentInternal(String path, String originalPath, Uri uri, String mime, final long dialog_id) { + if ((path == null || path.length() == 0) && uri == null) { return; } + MimeTypeMap myMime = MimeTypeMap.getSingleton(); + if (uri != null) { + String extension = null; + if (mime != null) { + extension = myMime.getExtensionFromMimeType(mime); + } + if (extension == null) { + extension = "txt"; + } + path = MediaController.copyDocumentToCache(uri, extension); + } final File f = new File(path); if (!f.exists() || f.length() == 0) { return; @@ -1893,7 +1904,6 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter document.size = (int)f.length(); document.dc_id = 0; if (ext.length() != 0) { - MimeTypeMap myMime = MimeTypeMap.getSingleton(); String mimeType = myMime.getMimeTypeFromExtension(ext.toLowerCase()); if (mimeType != null) { document.mime_type = mimeType; @@ -1921,34 +1931,46 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter final TLRPC.TL_document documentFinal = document; final String originalPathFinal = originalPath; + final String pathFinal = path; AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { - SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, path, dialog_id); + SendMessagesHelper.getInstance().sendMessage(documentFinal, originalPathFinal, pathFinal, dialog_id); } }); } - public static void prepareSendingDocument(String path, String originalPath, long dialog_id) { - if (path == null || originalPath == null) { + public static void prepareSendingDocument(String path, String originalPath, Uri uri, String mine, long dialog_id) { + if ((path == null || originalPath == null) && uri == null) { return; } ArrayList paths = new ArrayList(); ArrayList originalPaths = new ArrayList(); + ArrayList uris = null; + if (uri != null) { + uris = new ArrayList(); + } paths.add(path); originalPaths.add(originalPath); - prepareSendingDocuments(paths, originalPaths, dialog_id); + prepareSendingDocuments(paths, originalPaths, uris, mine, dialog_id); } - public static void prepareSendingDocuments(final ArrayList paths, final ArrayList originalPaths, final long dialog_id) { - if (paths == null && originalPaths == null || paths != null && originalPaths != null && paths.size() != originalPaths.size()) { + public static void prepareSendingDocuments(final ArrayList paths, final ArrayList originalPaths, final ArrayList uris, final String mime, final long dialog_id) { + if (paths == null && originalPaths == null && uris == null || paths != null && originalPaths != null && paths.size() != originalPaths.size()) { return; } new Thread(new Runnable() { @Override public void run() { - for (int a = 0; a < paths.size(); a++) { - prepareSendingDocumentInternal(paths.get(a), originalPaths.get(a), dialog_id); + if (paths != null) { + for (int a = 0; a < paths.size(); a++) { + prepareSendingDocumentInternal(paths.get(a), originalPaths.get(a), null, mime, dialog_id); + } + } + if (uris != null) { + for (int a = 0; a < uris.size(); a++) { + prepareSendingDocumentInternal(null, null, uris.get(a), mime, dialog_id); + } } } }).start(); @@ -2050,7 +2072,7 @@ public class SendMessagesHelper implements NotificationCenter.NotificationCenter } if (sendAsDocuments != null && !sendAsDocuments.isEmpty()) { for (int a = 0; a < sendAsDocuments.size(); a++) { - prepareSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a), dialog_id); + prepareSendingDocumentInternal(sendAsDocuments.get(a), sendAsDocumentsOriginal.get(a), null, "gif", dialog_id); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java index fe968b6f..a7875f18 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarLayout.java @@ -628,7 +628,7 @@ public class ActionBarLayout extends FrameLayout { currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether( ObjectAnimatorProxy.ofFloat(containerView, "alpha", 0.0f, 1.0f), - ObjectAnimatorProxy.ofFloat(containerView, "translationY", AndroidUtilities.dp(48), 0)); + ObjectAnimatorProxy.ofFloat(containerView, "translationX", AndroidUtilities.dp(48), 0)); currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { @@ -730,14 +730,14 @@ public class ActionBarLayout extends FrameLayout { @Override public void run() { closeLastFragmentInternalRemoveOld(currentFragment); - ViewProxy.setTranslationY(containerViewBack, 0); + ViewProxy.setTranslationX(containerViewBack, 0); } }; currentAnimation = new AnimatorSetProxy(); currentAnimation.playTogether( ObjectAnimatorProxy.ofFloat(containerViewBack, "alpha", 1.0f, 0.0f), - ObjectAnimatorProxy.ofFloat(containerViewBack, "translationY", 0, AndroidUtilities.dp(48))); + ObjectAnimatorProxy.ofFloat(containerViewBack, "translationX", 0, AndroidUtilities.dp(48))); currentAnimation.setInterpolator(new DecelerateInterpolator(1.5f)); currentAnimation.setDuration(200); currentAnimation.addListener(new AnimatorListenerAdapterProxy() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java index 01ca0585..79c194fd 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java @@ -52,6 +52,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter { private boolean needMessagesSearch; private boolean messagesSearchEndReached; private String lastMessagesSearchString; + private int lastSearchId = 0; public static interface MessagesActivitySearchAdapterDelegate { public abstract void searchStateChanged(boolean searching); @@ -137,15 +138,17 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter { }, true, RPCRequest.RPCRequestClassGeneric | RPCRequest.RPCRequestClassFailOnServerErrors); } - private void searchDialogsInternal(final String query, final boolean serverOnly) { + private void searchDialogsInternal(final String query, final boolean serverOnly, final int searchId) { MessagesStorage.getInstance().getStorageQueue().postRunnable(new Runnable() { @Override public void run() { try { + FileLog.e("tmessages", "trigger search"); ArrayList encUsers = new ArrayList(); String q = query.trim().toLowerCase(); if (q.length() == 0) { - updateSearchResults(new ArrayList(), new ArrayList(), new ArrayList()); + lastSearchId = -1; + updateSearchResults(new ArrayList(), new ArrayList(), new ArrayList(), lastSearchId); return; } ArrayList resultArray = new ArrayList(); @@ -253,7 +256,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter { } } cursor.dispose(); - updateSearchResults(resultArray, resultArrayNames, encUsers); + updateSearchResults(resultArray, resultArrayNames, encUsers, searchId); } catch (Exception e) { FileLog.e("tmessages", e); } @@ -261,10 +264,13 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter { }); } - private void updateSearchResults(final ArrayList result, final ArrayList names, final ArrayList encUsers) { + private void updateSearchResults(final ArrayList result, final ArrayList names, final ArrayList encUsers, final int searchId) { AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { + if (searchId != lastSearchId) { + return; + } for (TLObject obj : result) { if (obj instanceof TLRPC.User) { TLRPC.User user = (TLRPC.User) obj; @@ -313,6 +319,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter { queryServerSearch(null); notifyDataSetChanged(); } else { + final int searchId = ++lastSearchId; searchTimer = new Timer(); searchTimer.schedule(new TimerTask() { @Override @@ -323,7 +330,7 @@ public class DialogsSearchAdapter extends BaseContactsSearchAdapter { } catch (Exception e) { FileLog.e("tmessages", e); } - searchDialogsInternal(query, serverOnly); + searchDialogsInternal(query, serverOnly, searchId); AndroidUtilities.runOnUIThread(new Runnable() { @Override public void run() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index a6cf3834..3777d6ba 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -574,7 +574,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not @Override public void didSelectFile(DocumentSelectActivity activity, String path) { activity.finishFragment(); - SendMessagesHelper.prepareSendingDocument(path, path, dialog_id); + SendMessagesHelper.prepareSendingDocument(path, path, null, null, dialog_id); } @Override @@ -854,7 +854,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not addContactItem = headerItem.addSubItem(share_contact, "", 0); } if (currentEncryptedChat != null) { - timeItem2 = headerItem.addSubItem(chat_enc_timer, LocaleController.getString("MessageLifetime", R.string.MessageLifetime), 0); + timeItem2 = headerItem.addSubItem(chat_enc_timer, LocaleController.getString("SetTimer", R.string.SetTimer), 0); } headerItem.addSubItem(clear_history, LocaleController.getString("ClearHistory", R.string.ClearHistory), 0); if (currentChat != null && !isBroadcast) { @@ -957,14 +957,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } else { chatListView.setCacheColorHint(0); try { - if (selectedBackground == 1000001) { - ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(R.drawable.background_hd); + if (ApplicationLoader.cachedWallpaper != null) { + isCustomTheme = selectedBackground != 1000001; + ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(ApplicationLoader.cachedWallpaper); } else { - File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); - if (toFile.exists()) { - if (ApplicationLoader.cachedWallpaper != null) { - ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(ApplicationLoader.cachedWallpaper); - } else { + if (selectedBackground == 1000001) { + ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(R.drawable.background_hd); + ApplicationLoader.cachedWallpaper = ((SizeNotifierRelativeLayout) contentView).getBackgroundImage(); + } else { + File toFile = new File(ApplicationLoader.applicationContext.getFilesDir(), "wallpaper.jpg"); + if (toFile.exists()) { Drawable drawable = Drawable.createFromPath(toFile.getAbsolutePath()); if (drawable != null) { ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(drawable); @@ -973,10 +975,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not contentView.setBackgroundColor(-2693905); chatListView.setCacheColorHint(-2693905); } + isCustomTheme = true; + } else { + ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(R.drawable.background_hd); + ApplicationLoader.cachedWallpaper = ((SizeNotifierRelativeLayout) contentView).getBackgroundImage(); + isCustomTheme = false; } - isCustomTheme = true; - } else { - ((SizeNotifierRelativeLayout) contentView).setBackgroundImage(R.drawable.background_hd); } } } catch (Throwable e) { @@ -1792,7 +1796,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not showAttachmentError(); return; } - SendMessagesHelper.prepareSendingDocument(tempPath, originalPath, dialog_id); + SendMessagesHelper.prepareSendingDocument(tempPath, originalPath, null, null, dialog_id); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 3ee44ff8..384ebb61 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -65,6 +65,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa private String sendingText; private ArrayList photoPathsArray; private ArrayList documentsPathsArray; + private ArrayList documentsUrisArray; + private String documentsMimeType; private ArrayList documentsOriginalPathsArray; private ArrayList contactsToSend; private int currentConnectionState; @@ -375,6 +377,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa sendingText = null; documentsPathsArray = null; documentsOriginalPathsArray = null; + documentsMimeType = null; + documentsUrisArray = null; contactsToSend = null; if ((intent.getFlags() & Intent.FLAG_ACTIVITY_LAUNCHED_FROM_HISTORY) == 0) { @@ -501,7 +505,11 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa documentsOriginalPathsArray.add(uri.toString()); } } else { - error = true; + if (documentsUrisArray == null) { + documentsUrisArray = new ArrayList(); + } + documentsUrisArray.add(uri); + documentsMimeType = type; } } if (error) { @@ -628,7 +636,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa pushOpened = false; isNew = false; } - if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null) { + if (videoPath != null || photoPathsArray != null || sendingText != null || documentsPathsArray != null || contactsToSend != null || documentsUrisArray != null) { if (!AndroidUtilities.isTablet()) { NotificationCenter.getInstance().postNotificationName(NotificationCenter.closeChats); } @@ -753,8 +761,8 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa if (photoPathsArray != null) { SendMessagesHelper.prepareSendingPhotos(null, photoPathsArray, dialog_id); } - if (documentsPathsArray != null) { - SendMessagesHelper.prepareSendingDocuments(documentsPathsArray, documentsOriginalPathsArray, dialog_id); + if (documentsPathsArray != null || documentsUrisArray != null) { + SendMessagesHelper.prepareSendingDocuments(documentsPathsArray, documentsOriginalPathsArray, documentsUrisArray, documentsMimeType, dialog_id); } if (contactsToSend != null && !contactsToSend.isEmpty()) { for (TLRPC.User user : contactsToSend) { @@ -1095,16 +1103,26 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa @Override public boolean onKeyUp(int keyCode, KeyEvent event) { - if (AndroidUtilities.isTablet()) { - if (layersActionBarLayout.getVisibility() == View.VISIBLE && !layersActionBarLayout.fragmentsStack.isEmpty()) { - layersActionBarLayout.onKeyUp(keyCode, event); - } else if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) { - rightActionBarLayout.onKeyUp(keyCode, event); + if (keyCode == KeyEvent.KEYCODE_MENU) { + if (AndroidUtilities.isTablet()) { + if (layersActionBarLayout.getVisibility() == View.VISIBLE && !layersActionBarLayout.fragmentsStack.isEmpty()) { + layersActionBarLayout.onKeyUp(keyCode, event); + } else if (rightActionBarLayout.getVisibility() == View.VISIBLE && !rightActionBarLayout.fragmentsStack.isEmpty()) { + rightActionBarLayout.onKeyUp(keyCode, event); + } else { + actionBarLayout.onKeyUp(keyCode, event); + } } else { - actionBarLayout.onKeyUp(keyCode, event); + if (actionBarLayout.fragmentsStack.size() == 1) { + if (!drawerLayoutContainer.isDrawerOpened()) { + drawerLayoutContainer.openDrawer(false); + } else { + drawerLayoutContainer.closeDrawer(false); + } + } else { + actionBarLayout.onKeyUp(keyCode, event); + } } - } else { - actionBarLayout.onKeyUp(keyCode, event); } return super.onKeyUp(keyCode, event); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java index 53f473bc..cfdeee9b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/NotificationsSettingsActivity.java @@ -17,6 +17,7 @@ import android.content.SharedPreferences; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; +import android.os.Build; import android.provider.Settings; import android.view.LayoutInflater; import android.view.View; @@ -60,6 +61,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif private int messageSoundRow; private int messageLedRow; private int messagePopupNotificationRow; + private int messagePriorityRow; private int groupSectionRow2; private int groupSectionRow; private int groupAlertRow; @@ -68,11 +70,13 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif private int groupSoundRow; private int groupLedRow; private int groupPopupNotificationRow; + private int groupPriorityRow; private int inappSectionRow2; private int inappSectionRow; private int inappSoundRow; private int inappVibrateRow; private int inappPreviewRow; + private int inappPriorityRow; private int eventsSectionRow2; private int eventsSectionRow; private int contactJoinedRow; @@ -80,6 +84,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif private int otherSectionRow; private int badgeNumberRow; private int pebbleAlertRow; + private int repeatRow; private int resetSectionRow2; private int resetSectionRow; private int resetNotificationsRow; @@ -96,6 +101,11 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif messageVibrateRow = rowCount++; messagePopupNotificationRow = rowCount++; messageSoundRow = rowCount++; + if (Build.VERSION.SDK_INT >= 21) { + messagePriorityRow = rowCount++; + } else { + messagePriorityRow = -1; + } groupSectionRow2 = rowCount++; groupSectionRow = rowCount++; groupAlertRow = rowCount++; @@ -104,11 +114,21 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif groupVibrateRow = rowCount++; groupPopupNotificationRow = rowCount++; groupSoundRow = rowCount++; + if (Build.VERSION.SDK_INT >= 21) { + groupPriorityRow = rowCount++; + } else { + groupPriorityRow = -1; + } inappSectionRow2 = rowCount++; inappSectionRow = rowCount++; inappSoundRow = rowCount++; inappVibrateRow = rowCount++; inappPreviewRow = rowCount++; + if (Build.VERSION.SDK_INT >= 21) { + inappPriorityRow = rowCount++; + } else { + inappPriorityRow = -1; + } eventsSectionRow2 = rowCount++; eventsSectionRow = rowCount++; contactJoinedRow = rowCount++; @@ -116,6 +136,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif otherSectionRow = rowCount++; badgeNumberRow = rowCount++; pebbleAlertRow = rowCount++; + repeatRow = rowCount++; resetSectionRow2 = rowCount++; resetSectionRow = rowCount++; resetNotificationsRow = rowCount++; @@ -273,6 +294,12 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif enabled = preferences.getBoolean("EnableInAppPreview", true); editor.putBoolean("EnableInAppPreview", !enabled); editor.commit(); + } else if (i == inappPriorityRow) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + enabled = preferences.getBoolean("EnableInAppPriority", false); + editor.putBoolean("EnableInAppPriority", !enabled); + editor.commit(); } else if (i == contactJoinedRow) { SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); @@ -429,6 +456,66 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif }); builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); showAlertDialog(builder); + } else if (i == messagePriorityRow || i == groupPriorityRow) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority)); + builder.setItems(new CharSequence[] { + LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), + LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), + LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax) + }, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + if (i == messagePriorityRow) { + preferences.edit().putInt("priority_messages", which).commit(); + } else if (i == groupPriorityRow) { + preferences.edit().putInt("priority_group", which).commit(); + } + if (listView != null) { + listView.invalidateViews(); + } + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); + } else if (i == repeatRow) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications)); + builder.setItems(new CharSequence[] { + LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever), + LocaleController.formatPluralString("Minutes", 5), + LocaleController.formatPluralString("Minutes", 10), + LocaleController.formatPluralString("Minutes", 30), + LocaleController.formatPluralString("Hours", 1), + LocaleController.formatPluralString("Hours", 2), + LocaleController.formatPluralString("Hours", 4) + }, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + int minutes = 0; + if (which == 1) { + minutes = 5; + } else if (which == 2) { + minutes = 10; + } else if (which == 3) { + minutes = 30; + } else if (which == 4) { + minutes = 60; + } else if (which == 5) { + minutes = 60 * 2; + } else if (which == 6) { + minutes = 60 * 4; + } + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + preferences.edit().putInt("repeat_messages", minutes).commit(); + if (listView != null) { + listView.invalidateViews(); + } + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); } if (view instanceof TextCheckCell) { ((TextCheckCell) view).setChecked(!enabled); @@ -597,11 +684,13 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif } else if (i == inappVibrateRow) { checkCell.setTextAndCheck(LocaleController.getString("InAppVibrate", R.string.InAppVibrate), preferences.getBoolean("EnableInAppVibrate", true), true); } else if (i == inappPreviewRow) { - checkCell.setTextAndCheck(LocaleController.getString("InAppPreview", R.string.InAppPreview), preferences.getBoolean("EnableInAppPreview", true), false); + checkCell.setTextAndCheck(LocaleController.getString("InAppPreview", R.string.InAppPreview), preferences.getBoolean("EnableInAppPreview", true), true); + } else if (i == inappPriorityRow) { + checkCell.setTextAndCheck(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), preferences.getBoolean("EnableInAppPriority", false), false); } else if (i == contactJoinedRow) { checkCell.setTextAndCheck(LocaleController.getString("ContactJoined", R.string.ContactJoined), preferences.getBoolean("EnableContactJoined", true), false); } else if (i == pebbleAlertRow) { - checkCell.setTextAndCheck(LocaleController.getString("Pebble", R.string.Pebble), preferences.getBoolean("EnablePebbleNotifications", false), false); + checkCell.setTextAndCheck(LocaleController.getString("Pebble", R.string.Pebble), preferences.getBoolean("EnablePebbleNotifications", false), true); } else if (i == notificationsServiceRow) { checkCell.setTextAndCheck(LocaleController.getString("NotificationsService", R.string.NotificationsService), preferences.getBoolean("pushService", true), false); } else if (i == badgeNumberRow) { @@ -627,7 +716,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif if (value.equals("NoSound")) { value = LocaleController.getString("NoSound", R.string.NoSound); } - textCell.setTextAndValue(LocaleController.getString("Sound", R.string.Sound), value, false); + textCell.setTextAndValue(LocaleController.getString("Sound", R.string.Sound), value, true); } else if (i == resetNotificationsRow) { textCell.setMultilineDetail(true); textCell.setTextAndValue(LocaleController.getString("ResetAllNotifications", R.string.ResetAllNotifications), LocaleController.getString("UndoAllCustom", R.string.UndoAllCustom), false); @@ -667,6 +756,33 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif } else if (value == 3) { textCell.setTextAndValue(LocaleController.getString("Vibrate", R.string.Vibrate), LocaleController.getString("Long", R.string.Long), true); } + } else if (i == repeatRow) { + textCell.setMultilineDetail(false); + int minutes = preferences.getInt("repeat_messages", 60); + String value; + if (minutes == 0) { + value = LocaleController.getString("ShortMessageLifetimeForever", R.string.ShortMessageLifetimeForever); + } else if (minutes < 60) { + value = LocaleController.formatPluralString("Minutes", minutes); + } else { + value = LocaleController.formatPluralString("Hours", minutes / 60); + } + textCell.setTextAndValue(LocaleController.getString("RepeatNotifications", R.string.RepeatNotifications), value, false); + } else if (i == messagePriorityRow || i == groupPriorityRow) { + textCell.setMultilineDetail(false); + int value = 0; + if (i == messagePriorityRow) { + value = preferences.getInt("priority_messages", 1); + } else if (i == groupPriorityRow) { + value = preferences.getInt("priority_group", 1); + } + if (value == 0) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), false); + } else if (value == 1) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), false); + } else if (value == 2) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax), false); + } } } else if (type == 3) { if (view == null) { @@ -697,7 +813,7 @@ public class NotificationsSettingsActivity extends BaseFragment implements Notif } else if (i == messageAlertRow || i == messagePreviewRow || i == groupAlertRow || i == groupPreviewRow || i == inappSoundRow || i == inappVibrateRow || i == inappPreviewRow || i == contactJoinedRow || i == pebbleAlertRow || - i == notificationsServiceRow || i == badgeNumberRow) { + i == notificationsServiceRow || i == badgeNumberRow || i == inappPriorityRow) { return 1; } else if (i == messageLedRow || i == groupLedRow) { return 3; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 82fb2410..634d6052 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -1125,11 +1125,12 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. } } else if (chat_id != 0) { ActionBarMenuItem item = menu.addItem(0, R.drawable.ic_ab_other); - item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0); if (chat_id > 0) { item.addSubItem(add_member, LocaleController.getString("AddMember", R.string.AddMember), 0); + item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0); item.addSubItem(leave_group, LocaleController.getString("DeleteAndExit", R.string.DeleteAndExit), 0); } else { + item.addSubItem(edit_name, LocaleController.getString("EditName", R.string.EditName), 0); item.addSubItem(add_member, LocaleController.getString("AddRecipient", R.string.AddRecipient), 0); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java index c6ea5482..a56eab28 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileNotificationsActivity.java @@ -17,6 +17,7 @@ import android.content.SharedPreferences; import android.media.Ringtone; import android.media.RingtoneManager; import android.net.Uri; +import android.os.Build; import android.os.Bundle; import android.provider.Settings; import android.view.LayoutInflater; @@ -53,6 +54,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi private int settingsNotificationsRow; private int settingsVibrateRow; private int settingsSoundRow; + private int settingsPriorityRow; private int settingsLedRow; private int rowCount = 0; @@ -66,6 +68,11 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi settingsNotificationsRow = rowCount++; settingsVibrateRow = rowCount++; settingsSoundRow = rowCount++; + if (Build.VERSION.SDK_INT >= 21) { + settingsPriorityRow = rowCount++; + } else { + settingsPriorityRow = -1; + } settingsLedRow = rowCount++; NotificationCenter.getInstance().addObserver(this, NotificationCenter.notificationsSettingsUpdated); return super.onFragmentCreate(); @@ -253,6 +260,31 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi } }); showAlertDialog(builder); + } else if (i == settingsPriorityRow) { + AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity()); + builder.setTitle(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority)); + builder.setItems(new CharSequence[] { + LocaleController.getString("SettingsDefault", R.string.SettingsDefault), + LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), + LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), + LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax) + }, new DialogInterface.OnClickListener() { + @Override + public void onClick(DialogInterface dialog, int which) { + if (which == 0) { + which = 3; + } else { + which--; + } + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("Notifications", Activity.MODE_PRIVATE); + preferences.edit().putInt("priority_" + dialog_id, which).commit(); + if (listView != null) { + listView.invalidateViews(); + } + } + }); + builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null); + showAlertDialog(builder); } } }); @@ -425,6 +457,17 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi value = LocaleController.getString("NoSound", R.string.NoSound); } textCell.setTextAndValue(LocaleController.getString("Sound", R.string.Sound), value, true); + } else if (i == settingsPriorityRow) { + int value = preferences.getInt("priority_" + dialog_id, 3); + if (value == 0) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("NotificationsPriorityDefault", R.string.NotificationsPriorityDefault), true); + } else if (value == 1) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("NotificationsPriorityHigh", R.string.NotificationsPriorityHigh), true); + } else if (value == 2) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("NotificationsPriorityMax", R.string.NotificationsPriorityMax), true); + } else if (value == 3) { + textCell.setTextAndValue(LocaleController.getString("NotificationsPriority", R.string.NotificationsPriority), LocaleController.getString("SettingsDefault", R.string.SettingsDefault), true); + } } } else if (type == 1) { if (view == null) { @@ -450,7 +493,7 @@ public class ProfileNotificationsActivity extends BaseFragment implements Notifi @Override public int getItemViewType(int i) { - if (i == settingsNotificationsRow || i == settingsVibrateRow || i == settingsSoundRow) { + if (i == settingsNotificationsRow || i == settingsVibrateRow || i == settingsSoundRow || i == settingsPriorityRow) { return 0; } else if (i == settingsLedRow) { return 1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java index d053bd88..b38772f3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/AvatarDrawable.java @@ -44,6 +44,7 @@ public class AvatarDrawable extends Drawable { private StaticLayout textLayout; private float textWidth; private float textHeight; + private float textLeft; private boolean isProfile; private boolean drawBrodcast; private boolean drawPhoto; @@ -168,6 +169,7 @@ public class AvatarDrawable extends Drawable { try { textLayout = new StaticLayout(text, namePaint, AndroidUtilities.dp(100), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (textLayout.getLineCount() > 0) { + textLeft = textLayout.getLineLeft(0); textWidth = textLayout.getLineWidth(0); textHeight = textLayout.getLineBottom(0); } @@ -205,7 +207,7 @@ public class AvatarDrawable extends Drawable { broadcastDrawable.draw(canvas); } else { if (textLayout != null) { - canvas.translate((size - textWidth) / 2, (size - textHeight) / 2); + canvas.translate((size - textWidth) / 2 - textLeft, (size - textHeight) / 2); textLayout.draw(canvas); } else if (drawPhoto && photoDrawable != null) { int x = (size - photoDrawable.getIntrinsicWidth()) / 2; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java index bdb7efdc..1dcc1493 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/ChatActivityEnterView.java @@ -145,6 +145,9 @@ public class ChatActivityEnterView implements NotificationCenter.NotificationCen sendButton = (ImageButton) containerView.findViewById(R.id.chat_send_button); sendButton.setVisibility(View.INVISIBLE); + ViewProxy.setScaleX(sendButton, 0.1f); + ViewProxy.setScaleY(sendButton, 0.1f); + ViewProxy.setAlpha(sendButton, 0.0f); emojiButton = (ImageView) containerView.findViewById(R.id.chat_smile_button); audioSendButton = (ImageButton) containerView.findViewById(R.id.chat_audio_send_button); recordPanel = containerView.findViewById(R.id.record_panel); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java index b34b3117..f74e2a4c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Views/SizeNotifierRelativeLayout.java @@ -52,6 +52,10 @@ public class SizeNotifierRelativeLayout extends RelativeLayout { backgroundDrawable = bitmap; } + public Drawable getBackgroundImage() { + return backgroundDrawable; + } + @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { super.onLayout(changed, l, t, r, b); diff --git a/TMessagesProj/src/main/res/layout/chat_layout.xml b/TMessagesProj/src/main/res/layout/chat_layout.xml index 3f1af3dd..6e4d6975 100644 --- a/TMessagesProj/src/main/res/layout/chat_layout.xml +++ b/TMessagesProj/src/main/res/layout/chat_layout.xml @@ -118,7 +118,7 @@ android:layout_marginLeft="52dp" android:layout_marginRight="2dp" android:background="@null" - android:layout_marginBottom="12dp" + android:paddingBottom="12dp" android:paddingTop="11dp" android:textCursorDrawable="@null" android:textColor="#000000"/> diff --git a/TMessagesProj/src/main/res/layout/popup_notification_layout.xml b/TMessagesProj/src/main/res/layout/popup_notification_layout.xml index 664c5af3..12ade2ad 100644 --- a/TMessagesProj/src/main/res/layout/popup_notification_layout.xml +++ b/TMessagesProj/src/main/res/layout/popup_notification_layout.xml @@ -60,7 +60,7 @@ android:layout_marginLeft="52dp" android:layout_marginRight="2dp" android:background="@null" - android:layout_marginBottom="12dp" + android:paddingBottom="12dp" android:paddingTop="11dp" android:textCursorDrawable="@null" android:textColor="#000000"/> diff --git a/TMessagesProj/src/main/res/values-ar/strings.xml b/TMessagesProj/src/main/res/values-ar/strings.xml index 16e52016..b42a1204 100644 --- a/TMessagesProj/src/main/res/values-ar/strings.xml +++ b/TMessagesProj/src/main/res/values-ar/strings.xml @@ -106,6 +106,7 @@ حفظ في الجهاز تطبيق ملف التعريب المرفق غير مدعوم + عداد التدمير الذاتي %1$s قام بتعيين عداد التدمير الذاتي إلى to %2$s لقد قمت بتعيين التدمير الذاتي إلى %1$s @@ -143,7 +144,6 @@ الرد على %1$s %1$s %2$s - رسالة جديدة اختر جهة اتصال لا توجد جهات اتصال بعد http://telegram.org/dl2 مرحبا! هيا نستخدم تيليجرام: @@ -158,6 +158,7 @@ آخر ظهور خلال أسبوع آخر ظهور خلال شهر آخر ظهور خلال فترة طويلة + رسالة جديدة إرسال الرسالة إلى... أدخل اسم للمجموعة @@ -271,6 +272,12 @@ لا يوجد وسائط حفظ في الجهاز تعديل الاسم + Priority + Default + Low + High + Max + Repeat Notifications لا توجد وسائط بعد diff --git a/TMessagesProj/src/main/res/values-de/strings.xml b/TMessagesProj/src/main/res/values-de/strings.xml index f61035af..04aa57a8 100644 --- a/TMessagesProj/src/main/res/values-de/strings.xml +++ b/TMessagesProj/src/main/res/values-de/strings.xml @@ -46,7 +46,7 @@ Du bist dem geheimen Chat beigetreten. Verlauf löschen Löschen und beenden - Lösche Chat + Chat löschen Gelöschtes Konto Chat auswählen Tippen und Halten @@ -106,6 +106,7 @@ In Downloads speichern Sprachdatei benutzen Nicht unterstützte Datei + Wähle einen Selbstzerstörungs-Timer %1$s hat den Selbstzerstörungs-Timer auf %2$s gesetzt Du hast den Selbstzerstörungs-Timer auf %1$s gesetzt @@ -143,7 +144,6 @@ %1$s antworten %1$s %2$s - Neue Nachricht Kontakt auswählen Noch keine Kontakte Hey, lass uns zu Telegram wechseln: http://telegram.org/dl2 @@ -158,6 +158,7 @@ diese Woche gesehen diesen Monat gesehen vor langer Zeit gesehen + Neue Nachricht Sende Nachricht an… Gruppenname @@ -271,6 +272,12 @@ kein automatischer Download In der Galerie speichern Name bearbeiten + Priorität + Standard + Niedrig + Hoch + Max + Wiederholen Benachrichtigungen Noch keine geteilten Medien vorhanden diff --git a/TMessagesProj/src/main/res/values-es/strings.xml b/TMessagesProj/src/main/res/values-es/strings.xml index 5845f168..2f4b1ca5 100644 --- a/TMessagesProj/src/main/res/values-es/strings.xml +++ b/TMessagesProj/src/main/res/values-es/strings.xml @@ -106,6 +106,7 @@ Guardar en descargas Aplicar traducción Adjunto no soportado + Establecer autodestrucción %1$s activó la autodestrucción en %2$s Activaste la autodestrucción en %1$s @@ -143,7 +144,6 @@ Responder a %1$s %1$s %2$s - Nuevo mensaje Elegir contacto Aún sin contactos Oye, cambiémonos a Telegram: http://telegram.org/dl2 @@ -158,6 +158,7 @@ últ. vez hace unos días últ. vez hace unas semanas últ. vez hace mucho tiempo + Nuevo mensaje Enviar mensaje a... Nombre del grupo @@ -271,6 +272,12 @@ Ningún contenido multimedia Guardar en galería Editar nombre + Prioridad + Por defecto + Baja + Alta + Máxima + Repetir notificaciones Aún no hay fotos ni vídeos diff --git a/TMessagesProj/src/main/res/values-it/strings.xml b/TMessagesProj/src/main/res/values-it/strings.xml index ec2540a2..421a1c6f 100644 --- a/TMessagesProj/src/main/res/values-it/strings.xml +++ b/TMessagesProj/src/main/res/values-it/strings.xml @@ -106,6 +106,7 @@ Salva in download Applica file di localizzazione Allegato non supportato + Timer di autodistruzione %1$s ha impostato il timer di autodistruzione a %2$s Hai impostato il timer di autodistruzione a %1$s @@ -143,7 +144,6 @@ Rispondi a %1$s %1$s %2$s - Nuovo messaggio Seleziona contatto Ancora nessun contatto Ehi, è il momento di passare a Telegram: http://telegram.org/dl2 @@ -158,6 +158,7 @@ ultimo accesso entro una settimana ultimo accesso entro un mese ultimo accesso molto tempo fa + Nuovo messaggio Invia messaggio a... Immetti il nome del gruppo @@ -271,6 +272,12 @@ Nessun media Salva nella galleria Modifica nome + Priorità + Default + Bassa + Alta + Massima + Ripeti Notifiche Nessun media condiviso diff --git a/TMessagesProj/src/main/res/values-ko/strings.xml b/TMessagesProj/src/main/res/values-ko/strings.xml index 4d0c865c..f5dc781d 100644 --- a/TMessagesProj/src/main/res/values-ko/strings.xml +++ b/TMessagesProj/src/main/res/values-ko/strings.xml @@ -106,6 +106,7 @@ 다운로드 폴더에 저장 언어 파일 적용 지원하지 않는 형식입니다 + 자동삭제 타이머 설정 %1$s님이 자동삭제를 %2$s 후로 설정했습니다 자동삭제를 %1$s 후로 설정했습니다 @@ -143,7 +144,6 @@ %1$s님에게 답장하기 %2$s %1$s - 새 메시지 대화상대 선택 대화상대가 없습니다 텔레그램으로 초대합니다! http://telegram.org/dl2 @@ -158,6 +158,7 @@ 일주일 이내 마지막으로 접속 한 달 이내 마지막으로 접속 마지막으로 접속한 지 오래됨 + 새 메시지 메시지 보내기... 그룹 이름 입력 @@ -271,6 +272,12 @@ 다운로드 안함 앨범에 자동 저장 이름 편집 + 우선순위 + 기본 + 낮음 + 높음 + 최우선 + Repeat Notifications 공유한 미디어가 없습니다 diff --git a/TMessagesProj/src/main/res/values-nl/strings.xml b/TMessagesProj/src/main/res/values-nl/strings.xml index ca7444d5..37a238a2 100644 --- a/TMessagesProj/src/main/res/values-nl/strings.xml +++ b/TMessagesProj/src/main/res/values-nl/strings.xml @@ -106,6 +106,7 @@ Opslaan in Downloads Vertaling toepassen Bestandstype niet ondersteund + Zelfvernietigingstimer instellen %1$s heeft de zelfvernietigingstimer ingesteld op %2$s Je hebt de zelfvernietigingstimer ingesteld op %1$s @@ -143,7 +144,6 @@ Antwoord op %1$s %1$s %2$s - Nieuw bericht Kies een contact Nog geen contacten Hey! Zullen we overstappen op Telegram? http://telegram.org/dl2 @@ -158,6 +158,7 @@ afgelopen week gezien afgelopen maand gezien lang geleden gezien + Nieuw bericht Bericht verzenden naar… Groepsnaam... @@ -271,6 +272,12 @@ Geen media Opslaan in galerij Naam bewerken + Prioriteit + Standaard + Laag + Hoog + Max + Meldingen herhalen Nog geen media gedeeld @@ -392,11 +399,11 @@ Weet je zeker dat je wilt uitloggen?\n\nTelegram kun je naadloos op al je apparaten tegelijkertijd gebruiken.\n\nLet op! Als je uitlogt worden al je geheime chats verwijderd. Alle apparaten behalve het huidige apparaat uitloggen? Echt alles verwijderen en de groep verlaten? - Weet je zeker dat je dit gesprek wilt verwijderen? + Gesprek echt verwijderen? Weet je zeker dat je je contactinformatie wilt delen? Weet je zeker dat je deze persoon wilt blokkeren? Weet je zeker dat je deze persoon wilt deblokkeren? - Weet je zeker dat je deze contactpersoon wilt verwijderen? + Contactpersoon echt verwijderen? Weet je zeker dat je een geheime chat wilt starten? Weet je zeker dat je de registratie wilt annuleren? Geschiedenis echt wissen? diff --git a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml index 3811da6a..3804be3b 100644 --- a/TMessagesProj/src/main/res/values-pt-rBR/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rBR/strings.xml @@ -106,6 +106,7 @@ Salvar em downloads Aplicar arquivo de localização Anexo não suportado + Tempo de autodestruição %1$s estabeleceu o tempo de autodestruição para %2$s Você estabeleceu o tempo de autodestruição para %1$s @@ -143,7 +144,6 @@ Responder para %1$s %1$s %2$s - Nova Mensagem Selecionar Contato Ainda não há contatos Ei, vamos mudar para o Telegram: http://telegram.org/dl2 @@ -158,6 +158,7 @@ visto na última semana visto no último mês visto há muito tempo atrás + Nova Mensagem Enviar mensagem para... Digite o nome do grupo @@ -271,6 +272,12 @@ Sem mídia Salvar na galeria Editar nome + Priority + Default + Low + High + Max + Repeat Notifications Ainda não há mídia compartilhada diff --git a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml index 9d43ec23..3aa9c825 100644 --- a/TMessagesProj/src/main/res/values-pt-rPT/strings.xml +++ b/TMessagesProj/src/main/res/values-pt-rPT/strings.xml @@ -106,6 +106,7 @@ Salvar em downloads Aplicar arquivo de localização Anexo não suportado + Tempo de autodestruição %1$s estabeleceu o tempo de autodestruição para %2$s Você estabeleceu o tempo de autodestruição para %1$s @@ -143,7 +144,6 @@ Responder para %1$s %1$s %2$s - Nova Mensagem Selecionar Contato Ainda não há contatos Ei, vamos mudar para o Telegram: http://telegram.org/dl2 @@ -158,6 +158,7 @@ visto na última semana visto no último mês visto há muito tempo atrás + Nova Mensagem Enviar mensagem para... Digite o nome do grupo @@ -271,6 +272,12 @@ Sem mídia Salvar na galeria Editar nome + Priority + Default + Low + High + Max + Repeat Notifications Ainda não há mídia compartilhada diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 2af918f1..6006908e 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -106,7 +106,7 @@ Save to downloads Apply localization file Unsupported attachment - Set timer + Set self-destruct timer %1$s set the self-destruct timer to %2$s You set the self-destruct timer to %1$s @@ -147,7 +147,7 @@ Select Contact No contacts yet Hey, let\'s switch to Telegram: http://telegram.org/dl2 - at + today at yesterday at online last seen @@ -277,6 +277,7 @@ Low High Max + Repeat Notifications No shared media yet