diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 90afb9c32..47b4ff29e 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -288,7 +288,7 @@ android { } } - defaultConfig.versionCode = 2244 + defaultConfig.versionCode = 2245 applicationVariants.all { variant -> variant.outputs.all { output -> diff --git a/TMessagesProj/jni/CMakeLists.txt b/TMessagesProj/jni/CMakeLists.txt index 9a0d4c89a..ed57f43a0 100644 --- a/TMessagesProj/jni/CMakeLists.txt +++ b/TMessagesProj/jni/CMakeLists.txt @@ -395,7 +395,7 @@ target_compile_definitions(sqlite PUBLIC #voip include(${CMAKE_HOME_DIRECTORY}/voip/CMakeLists.txt) -set(NATIVE_LIB "tmessages.35") +set(NATIVE_LIB "tmessages.36") #tmessages add_library(${NATIVE_LIB} SHARED diff --git a/TMessagesProj/jni/TgNetWrapper.cpp b/TMessagesProj/jni/TgNetWrapper.cpp index e8cba5f18..16c1f0ff0 100644 --- a/TMessagesProj/jni/TgNetWrapper.cpp +++ b/TMessagesProj/jni/TgNetWrapper.cpp @@ -210,8 +210,8 @@ void updateDcSettings(JNIEnv *env, jclass c, jint instanceNum) { ConnectionsManager::getInstance(instanceNum).updateDcSettings(0, false); } -void setUseIpv6(JNIEnv *env, jclass c, jint instanceNum, jboolean value) { - ConnectionsManager::getInstance(instanceNum).setUseIpv6(value); +void setIpStrategy(JNIEnv *env, jclass c, jint instanceNum, jbyte value) { + ConnectionsManager::getInstance(instanceNum).setIpStrategy((uint8_t) value); } void setNetworkAvailable(JNIEnv *env, jclass c, jint instanceNum, jboolean value, jint networkType, jboolean slow) { @@ -448,7 +448,7 @@ static JNINativeMethod ConnectionsManagerMethods[] = { {"native_pauseNetwork", "(I)V", (void *) pauseNetwork}, {"native_resumeNetwork", "(IZ)V", (void *) resumeNetwork}, {"native_updateDcSettings", "(I)V", (void *) updateDcSettings}, - {"native_setUseIpv6", "(IZ)V", (void *) setUseIpv6}, + {"native_setIpStrategy", "(IB)V", (void *) setIpStrategy}, {"native_setNetworkAvailable", "(IZIZ)V", (void *) setNetworkAvailable}, {"native_setPushConnectionEnabled", "(IZ)V", (void *) setPushConnectionEnabled}, {"native_setJava", "(Z)V", (void *) setJava}, diff --git a/TMessagesProj/jni/tgnet/Connection.cpp b/TMessagesProj/jni/tgnet/Connection.cpp index 8a579a99e..8823eda2e 100644 --- a/TMessagesProj/jni/tgnet/Connection.cpp +++ b/TMessagesProj/jni/tgnet/Connection.cpp @@ -292,7 +292,17 @@ void Connection::connect() { connectionInProcess = true; connectionState = TcpConnectionStageConnecting; isMediaConnection = false; - uint32_t ipv6 = ConnectionsManager::getInstance(currentDatacenter->instanceNum).isIpv6Enabled() ? TcpAddressFlagIpv6 : 0; + uint8_t strategy = ConnectionsManager::getInstance(currentDatacenter->instanceNum).getIpStratagy(); + uint32_t ipv6; + if (strategy == USE_IPV6_ONLY) { + ipv6 = TcpAddressFlagIpv6; + } else if (strategy == USE_IPV4_IPV6_RANDOM) { + uint8_t value; + RAND_bytes(&value, 1); + ipv6 = value % 2 == 0 ? TcpAddressFlagIpv6 : 0; + } else { + ipv6 = 0; + } uint32_t isStatic = connectionType == ConnectionTypeProxy || !ConnectionsManager::getInstance(currentDatacenter->instanceNum).proxyAddress.empty() ? TcpAddressFlagStatic : 0; TcpAddress *tcpAddress = nullptr; if (isMediaConnectionType(connectionType)) { diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp index 209ce5814..69e0f6979 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.cpp +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.cpp @@ -1660,8 +1660,8 @@ void ConnectionsManager::sendPing(Datacenter *datacenter, bool usePushConnection connection->sendData(transportData, false, true); } -bool ConnectionsManager::isIpv6Enabled() { - return ipv6Enabled; +uint8_t ConnectionsManager::getIpStratagy() { + return ipStrategy; } void ConnectionsManager::initDatacenters() { @@ -3419,9 +3419,9 @@ void ConnectionsManager::setNetworkAvailable(bool value, int32_t type, bool slow }); } -void ConnectionsManager::setUseIpv6(bool value) { +void ConnectionsManager::setIpStrategy(uint8_t value) { scheduleTask([&, value] { - ipv6Enabled = value; + ipStrategy = value; }); } diff --git a/TMessagesProj/jni/tgnet/ConnectionsManager.h b/TMessagesProj/jni/tgnet/ConnectionsManager.h index 2f16321ba..21e2b6ae2 100644 --- a/TMessagesProj/jni/tgnet/ConnectionsManager.h +++ b/TMessagesProj/jni/tgnet/ConnectionsManager.h @@ -62,7 +62,7 @@ public: void resumeNetwork(bool partial); void pauseNetwork(); void setNetworkAvailable(bool value, int32_t type, bool slow); - void setUseIpv6(bool value); + void setIpStrategy(uint8_t value); void init(uint32_t version, int32_t layer, int32_t apiId, std::string deviceModel, std::string systemVersion, std::string appVersion, std::string langCode, std::string systemLangCode, std::string configPath, std::string logPath, std::string regId, std::string cFingerprint, std::string installerId, int32_t timezoneOffset, int32_t userId, bool isPaused, bool enablePushConnection, bool hasNetwork, int32_t networkType); void setProxySettings(std::string address, uint16_t port, std::string username, std::string password, std::string secret); void setLangCode(std::string langCode); @@ -123,7 +123,7 @@ private: void onDatacenterHandshakeComplete(Datacenter *datacenter, HandshakeType type, int32_t timeDiff); void onDatacenterExportAuthorizationComplete(Datacenter *datacenter); int64_t generateMessageId(); - bool isIpv6Enabled(); + uint8_t getIpStratagy(); bool isNetworkAvailable(); void scheduleCheckProxyInternal(ProxyCheckInfo *proxyCheckInfo); @@ -192,7 +192,7 @@ private: int64_t lastOutgoingMessageId = 0; bool networkAvailable = true; bool networkSlow = false; - bool ipv6Enabled = false; + uint8_t ipStrategy = USE_IPV4_ONLY; std::vector activeConnections; std::vector activeConnectionsCopy; int epolFd; diff --git a/TMessagesProj/jni/tgnet/Datacenter.cpp b/TMessagesProj/jni/tgnet/Datacenter.cpp index 06c201acf..41fbe0b1b 100644 --- a/TMessagesProj/jni/tgnet/Datacenter.cpp +++ b/TMessagesProj/jni/tgnet/Datacenter.cpp @@ -1477,7 +1477,8 @@ bool Datacenter::isExportingAuthorization() { bool Datacenter::hasMediaAddress() { std::vector *addresses; - if (ConnectionsManager::getInstance(instanceNum).isIpv6Enabled()) { + int strategy = ConnectionsManager::getInstance(instanceNum).getIpStratagy(); + if (strategy == USE_IPV6_ONLY) { addresses = &addressesIpv6Download; } else { addresses = &addressesIpv4Download; diff --git a/TMessagesProj/jni/tgnet/Defines.h b/TMessagesProj/jni/tgnet/Defines.h index aebf960ee..5c6e637fa 100644 --- a/TMessagesProj/jni/tgnet/Defines.h +++ b/TMessagesProj/jni/tgnet/Defines.h @@ -31,6 +31,10 @@ #define MAX_ACCOUNT_COUNT 3 #define USE_DELEGATE_HOST_RESOLVE +#define USE_IPV4_ONLY 0 +#define USE_IPV6_ONLY 1 +#define USE_IPV4_IPV6_RANDOM 2 + #define NETWORK_TYPE_MOBILE 0 #define NETWORK_TYPE_WIFI 1 #define NETWORK_TYPE_ROAMING 2 diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 7c40f4aff..b8970d449 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -18,7 +18,7 @@ public class BuildVars { public static boolean LOGS_ENABLED = false; public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; - public static int BUILD_VERSION = 2244; + public static int BUILD_VERSION = 2245; public static String BUILD_VERSION_STRING = "7.5.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java index 8c4ab1646..55a16aa58 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatsWidgetProvider.java @@ -41,6 +41,7 @@ public class ChatsWidgetProvider extends AppWidgetProvider { @Override public void onDeleted(Context context, int[] appWidgetIds) { super.onDeleted(context, appWidgetIds); + ApplicationLoader.postInitApplication(); SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); for (int a = 0; a < appWidgetIds.length; a++) { @@ -58,15 +59,16 @@ public class ChatsWidgetProvider extends AppWidgetProvider { private static int getCellsForSize(int size) { int n = 2; - while (70 * n - 30 < size) { + while (72 * n < size) { ++n; } return n - 1; } public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, boolean edit) { + ApplicationLoader.postInitApplication(); Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); - int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT); + int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT); int rows = getCellsForSize(minHeight); Intent intent2 = new Intent(context, ChatsWidgetService.class); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java index 6f5fd33ef..d64cd3ec9 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetProvider.java @@ -35,6 +35,7 @@ public class ContactsWidgetProvider extends AppWidgetProvider { @Override public void onDeleted(Context context, int[] appWidgetIds) { super.onDeleted(context, appWidgetIds); + ApplicationLoader.postInitApplication(); SharedPreferences preferences = context.getSharedPreferences("shortcut_widget", Activity.MODE_PRIVATE); SharedPreferences.Editor editor = preferences.edit(); for (int a = 0; a < appWidgetIds.length; a++) { @@ -58,16 +59,17 @@ public class ContactsWidgetProvider extends AppWidgetProvider { private static int getCellsForSize(int size) { int n = 2; - while (86 * n - 30 < size) { + while (86 * n < size) { ++n; } return n - 1; } public static void updateWidget(Context context, AppWidgetManager appWidgetManager, int appWidgetId, boolean edit) { + ApplicationLoader.postInitApplication(); Bundle options = appWidgetManager.getAppWidgetOptions(appWidgetId); - int minHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT); - int rows = getCellsForSize(minHeight); + int maxHeight = options.getInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT); + int rows = getCellsForSize(maxHeight); Intent intent2 = new Intent(context, ContactsWidgetService.class); intent2.putExtra(AppWidgetManager.EXTRA_APPWIDGET_ID, appWidgetId); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java index 687b37232..ed7a7a0f2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsWidgetService.java @@ -120,9 +120,13 @@ class ContactsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor } } else { chat = accountInstance.getMessagesController().getChat(-(int) (long) id); - name = chat.title; - if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) { - photoPath = chat.photo.photo_small; + if (chat != null) { + name = chat.title; + if (chat.photo != null && chat.photo.photo_small != null && chat.photo.photo_small.volume_id != 0 && chat.photo.photo_small.local_id != 0) { + photoPath = chat.photo.photo_small; + } + } else { + name = ""; } } rv.setTextViewText(a == 0 ? R.id.contacts_widget_item_text1 : R.id.contacts_widget_item_text2, name); @@ -175,7 +179,13 @@ class ContactsRemoteViewsFactory implements RemoteViewsService.RemoteViewsFactor TLRPC.Dialog dialog = dialogs.get(id); if (dialog != null && dialog.unread_count > 0) { - rv.setTextViewText(a == 0 ? R.id.contacts_widget_item_badge1 : R.id.contacts_widget_item_badge2, String.format("%d", dialog.unread_count)); + String count; + if (dialog.unread_count > 99) { + count = String.format("%d+", 99); + } else { + count = String.format("%d", dialog.unread_count); + } + rv.setTextViewText(a == 0 ? R.id.contacts_widget_item_badge1 : R.id.contacts_widget_item_badge2, count); rv.setViewVisibility(a == 0 ? R.id.contacts_widget_item_badge_bg1 : R.id.contacts_widget_item_badge_bg2, View.VISIBLE); } else { rv.setViewVisibility(a == 0 ? R.id.contacts_widget_item_badge_bg1 : R.id.contacts_widget_item_badge_bg2, View.GONE); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index 70aedb400..4d0c78c1c 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -3486,7 +3486,7 @@ public class MessagesController extends BaseController implements NotificationCe editor.remove("dialog_bar_distance" + dialogId); } } - editor.commit(); + editor.apply(); getNotificationCenter().postNotificationName(NotificationCenter.peerSettingsDidLoad, dialogId); } @@ -9713,6 +9713,9 @@ public class MessagesController extends BaseController implements NotificationCe for (int a = 0; a < res.new_messages.size(); a++) { TLRPC.Message message = res.new_messages.get(a); + if (message instanceof TLRPC.TL_messageEmpty) { + continue; + } message.unread = !(channelFinal != null && channelFinal.left || (message.out ? outboxValue : inboxValue) >= message.id || message.action instanceof TLRPC.TL_messageActionChannelCreate); boolean isDialogCreated = createdDialogIds.contains(dialog_id); @@ -9949,6 +9952,9 @@ public class MessagesController extends BaseController implements NotificationCe int clientUserId = getUserConfig().getClientUserId(); for (int a = 0; a < res.new_messages.size(); a++) { TLRPC.Message message = res.new_messages.get(a); + if (message instanceof TLRPC.TL_messageEmpty) { + continue; + } MessageObject.getDialogId(message); if ((int) message.dialog_id != 0) { @@ -11355,6 +11361,9 @@ public class MessagesController extends BaseController implements NotificationCe message.out = true; } } + if (message instanceof TLRPC.TL_messageEmpty) { + continue; + } TLRPC.Chat chat = null; int chat_id = 0; int user_id = 0; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index a74f04a0e..d196014f9 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -8267,6 +8267,9 @@ public class MessagesStorage extends BaseController { for (int a = 0; a < messages.size(); a++) { TLRPC.Message message = messages.get(a); + if (message instanceof TLRPC.TL_messageEmpty) { + continue; + } fixUnsupportedMedia(message); state_messages.requery(); @@ -10166,6 +10169,9 @@ public class MessagesStorage extends BaseController { int count = messages.messages.size(); for (int a = 0; a < count; a++) { TLRPC.Message message = messages.messages.get(a); + if (message instanceof TLRPC.TL_messageEmpty) { + continue; + } long messageId = message.id; if (channelId == 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java b/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java index 57f6ee050..a31000ec2 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NativeLoader.java @@ -22,7 +22,7 @@ import java.util.zip.ZipFile; public class NativeLoader { - private final static int LIB_VERSION = 35; + private final static int LIB_VERSION = 36; private final static String LIB_NAME = "tmessages." + LIB_VERSION; private final static String LIB_SO_NAME = "lib" + LIB_NAME + ".so"; private final static String LOCALE_LIB_SO_NAME = "lib" + LIB_NAME + "loc.so"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java index 62ce443f5..9e61b7f74 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SendMessagesHelper.java @@ -1598,6 +1598,9 @@ public class SendMessagesHelper extends BaseController implements NotificationCe newMsg.flags |= 8388608; } newMsg.message = msgObj.messageOwner.message; + if (newMsg.message == null) { + newMsg.message = ""; + } newMsg.fwd_msg_id = msgObj.getId(); newMsg.attachPath = msgObj.messageOwner.attachPath; newMsg.entities = msgObj.messageOwner.entities; diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java index 6ae4716bd..b81a7893e 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/ConnectionsManager.java @@ -82,6 +82,10 @@ public class ConnectionsManager extends BaseController { public final static int ConnectionStateConnectingToProxy = 4; public final static int ConnectionStateUpdating = 5; + public final static byte USE_IPV4_ONLY = 0; + public final static byte USE_IPV6_ONLY = 1; + public final static byte USE_IPV4_IPV6_RANDOM = 2; + private static long lastDnsRequestTime; public final static int DEFAULT_DATACENTER_ID = Integer.MAX_VALUE; @@ -333,7 +337,7 @@ public class ConnectionsManager extends BaseController { } public void checkConnection() { - native_setUseIpv6(currentAccount, useIpv6Address()); + native_setIpStrategy(currentAccount, getIpStrategy()); native_setNetworkAvailable(currentAccount, ApplicationLoader.isNetworkOnline(), ApplicationLoader.getCurrentNetworkType(), ApplicationLoader.isConnectionSlow()); } @@ -656,7 +660,7 @@ public class ConnectionsManager extends BaseController { public static native void native_switchBackend(int currentAccount); public static native int native_isTestBackend(int currentAccount); public static native void native_pauseNetwork(int currentAccount); - public static native void native_setUseIpv6(int currentAccount, boolean value); + public static native void native_setIpStrategy(int currentAccount, byte value); public static native void native_updateDcSettings(int currentAccount); public static native void native_setNetworkAvailable(int currentAccount, boolean value, int networkType, boolean slow); public static native void native_resumeNetwork(int currentAccount, boolean partial); @@ -701,9 +705,9 @@ public class ConnectionsManager extends BaseController { } @SuppressLint("NewApi") - protected static boolean useIpv6Address() { + protected static byte getIpStrategy() { if (Build.VERSION.SDK_INT < 19) { - return false; + return USE_IPV4_ONLY; } if (BuildVars.LOGS_ENABLED) { try { @@ -741,6 +745,7 @@ public class ConnectionsManager extends BaseController { Enumeration networkInterfaces = NetworkInterface.getNetworkInterfaces(); boolean hasIpv4 = false; boolean hasIpv6 = false; + boolean hasStrangeIpv4 = false; while (networkInterfaces.hasMoreElements()) { networkInterface = networkInterfaces.nextElement(); if (!networkInterface.isUp() || networkInterface.isLoopback()) { @@ -759,18 +764,25 @@ public class ConnectionsManager extends BaseController { String addrr = inetAddress.getHostAddress(); if (!addrr.startsWith("192.0.0.")) { hasIpv4 = true; + } else { + hasStrangeIpv4 = true; } } } } - if (!hasIpv4 && hasIpv6) { - return true; + if (hasIpv6) { + if (hasStrangeIpv4) { + return USE_IPV4_IPV6_RANDOM; + } + if (!hasIpv4) { + return USE_IPV6_ONLY; + } } } catch (Throwable e) { FileLog.e(e); } - return false; + return USE_IPV4_ONLY; } private static class ResolveHostByNameTask extends AsyncTask { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index f5298047b..f9a5a3f98 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -1998,7 +1998,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (isAvatarVisible && avatarImage.isInsideImage(x, y + getTop())) { avatarPressed = true; result = true; - } else if (psaButtonVisible && psaHelpX != -1 && x >= psaHelpX && x <= psaHelpX + AndroidUtilities.dp(40) && y >= psaHelpY && y <= psaHelpY + AndroidUtilities.dp(40)) { + } else if (psaButtonVisible && hasPsaHint && x >= psaHelpX && x <= psaHelpX + AndroidUtilities.dp(40) && y >= psaHelpY && y <= psaHelpY + AndroidUtilities.dp(40)) { psaHintPressed = true; createSelectorDrawable(0); selectorDrawableMaskType[0] = 3; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index bc0edc575..5293ef947 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -20222,6 +20222,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not AlertDialog alertDialog = builder.create(); showDialog(builder.create()); } + AndroidUtilities.cancelRunOnUIThread(progressRunnable); + commentLoadingMessageId = 0; + chatListView.invalidateViews(); return; } savedNoHistory = true; @@ -20829,7 +20832,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not showPollSolution(cell.getMessageObject(), media.results); } else if (type == 1) { MessageObject messageObject = cell.getMessageObject(); - if (TextUtils.isEmpty(messageObject.messageOwner.fwd_from.psa_type)) { + if (messageObject.messageOwner.fwd_from == null || TextUtils.isEmpty(messageObject.messageOwner.fwd_from.psa_type)) { return; } CharSequence text = LocaleController.getString("PsaMessageInfo_" + messageObject.messageOwner.fwd_from.psa_type); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClearHistoryAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClearHistoryAlert.java index 86e717286..8f24dee67 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ClearHistoryAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ClearHistoryAlert.java @@ -164,7 +164,7 @@ public class ClearHistoryAlert extends BottomSheet { if (autoDeleteOnly || contentHeight - visiblePart < AndroidUtilities.dp(90) || contentHeight < height / 2 + AndroidUtilities.dp(90)) { padding = height - contentHeight; } else { - int minHeight = contentHeight / 2 + AndroidUtilities.dp(40); + int minHeight = contentHeight / 2 + AndroidUtilities.dp(108); if (visiblePart < minHeight) { padding = height - minHeight; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/InviteLinkBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/InviteLinkBottomSheet.java index 1030d0323..495c6ca2d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/InviteLinkBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/InviteLinkBottomSheet.java @@ -293,7 +293,14 @@ public class InviteLinkBottomSheet extends BottomSheet { titleTextView.setGravity(Gravity.CENTER_VERTICAL); titleTextView.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf")); if (!permanent) { - titleTextView.setText(invite.revoked ? LocaleController.getString("RevokedLink", R.string.RevokedLink) : LocaleController.getString("InviteLink", R.string.InviteLink)); + if (invite.expired) { + titleTextView.setText(LocaleController.getString("ExpiredLink", R.string.ExpiredLink)); + } else if (invite.revoked) { + titleTextView.setText(LocaleController.getString("RevokedLink", R.string.RevokedLink)); + } else { + titleTextView.setText(LocaleController.getString("InviteLink", R.string.InviteLink)); + } + titleVisible = true; } else { titleTextView.setText(LocaleController.getString("InviteLink", R.string.InviteLink)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java index 8bf352a3c..892daca52 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkActionView.java @@ -459,6 +459,9 @@ public class LinkActionView extends LinearLayout { } private void revokeLink() { + if (fragment.getParentActivity() == null) { + return; + } AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getParentActivity()); builder.setMessage(LocaleController.getString("RevokeAlert", R.string.RevokeAlert)); builder.setTitle(LocaleController.getString("RevokeLink", R.string.RevokeLink)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReportAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReportAlert.java index 542397be4..4aaf9f04e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReportAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReportAlert.java @@ -75,7 +75,6 @@ public class ReportAlert extends BottomSheet { setCustomView(frameLayout); RLottieImageView imageView = new RLottieImageView(context); - imageView.setAutoRepeat(true); imageView.setAnimation(R.raw.report_police, 120, 120); imageView.playAnimation(); frameLayout.addView(imageView, LayoutHelper.createFrame(160, 160, Gravity.CENTER_HORIZONTAL | Gravity.TOP, 17, 14, 17, 0)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickerSetBulletinLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickerSetBulletinLayout.java index 135ff54ee..fec2fe230 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickerSetBulletinLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickerSetBulletinLayout.java @@ -6,6 +6,7 @@ import android.content.Context; import androidx.annotation.IntDef; import androidx.annotation.NonNull; +import org.telegram.messenger.BuildVars; import org.telegram.messenger.FileLoader; import org.telegram.messenger.ImageLocation; import org.telegram.messenger.LocaleController; @@ -26,7 +27,7 @@ public class StickerSetBulletinLayout extends Bulletin.TwoLineLayout { public static final int TYPE_REMOVED_FROM_FAVORITES = 4; public static final int TYPE_ADDED_TO_FAVORITES = 5; - @IntDef(value = {TYPE_REMOVED, TYPE_ARCHIVED, TYPE_ADDED}) + @IntDef(value = {TYPE_REMOVED, TYPE_ARCHIVED, TYPE_ADDED, TYPE_REMOVED_FROM_RECENT, TYPE_REMOVED_FROM_FAVORITES, TYPE_ADDED_TO_FAVORITES}) public @interface Type {} public StickerSetBulletinLayout(@NonNull Context context, TLObject setObject, @Type int type) { @@ -61,7 +62,7 @@ public class StickerSetBulletinLayout extends Bulletin.TwoLineLayout { stickerSet = null; } - if (sticker == null) { + if (sticker == null && BuildVars.DEBUG_VERSION) { throw new IllegalArgumentException("Invalid type of the given setObject: " + setObject.getClass()); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java index abf162c53..8321b8aea 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UndoView.java @@ -12,10 +12,12 @@ import android.graphics.PorterDuffColorFilter; import android.graphics.RectF; import android.graphics.Typeface; import android.os.SystemClock; +import android.text.Layout; import android.text.Selection; import android.text.Spannable; import android.text.SpannableStringBuilder; import android.text.Spanned; +import android.text.StaticLayout; import android.text.TextPaint; import android.text.TextUtils; import android.text.method.LinkMovementMethod; @@ -1067,6 +1069,12 @@ public class UndoView extends FrameLayout { super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(undoViewHeight, MeasureSpec.EXACTLY)); } + StaticLayout timeLayout; + StaticLayout timeLayoutOut; + int textWidthOut; + + float timeReplaceProgress = 1f; + @Override protected void onDraw(Canvas canvas) { if (currentAction == ACTION_DELETE || currentAction == ACTION_CLEAR) { @@ -1074,9 +1082,50 @@ public class UndoView extends FrameLayout { if (prevSeconds != newSeconds) { prevSeconds = newSeconds; timeLeftString = String.format("%d", Math.max(1, newSeconds)); + if (timeLayout != null) { + timeLayoutOut = timeLayout; + timeReplaceProgress = 0; + textWidthOut = textWidth; + } textWidth = (int) Math.ceil(textPaint.measureText(timeLeftString)); + timeLayout = new StaticLayout(timeLeftString, textPaint, Integer.MAX_VALUE, Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); } - canvas.drawText(timeLeftString, rect.centerX() - textWidth / 2, AndroidUtilities.dp(28.2f), textPaint); + + if (timeReplaceProgress < 1f) { + timeReplaceProgress += 16f / 150f; + if (timeReplaceProgress > 1f) { + timeReplaceProgress = 1f; + } else { + invalidate(); + } + } + + int alpha = textPaint.getAlpha(); + + if (timeLayoutOut != null && timeReplaceProgress < 1f) { + textPaint.setAlpha((int) (alpha * (1f - timeReplaceProgress))); + canvas.save(); + canvas.translate(rect.centerX() - textWidth / 2, AndroidUtilities.dp(17.2f) + AndroidUtilities.dp(10) * timeReplaceProgress); + timeLayoutOut.draw(canvas); + textPaint.setAlpha(alpha); + canvas.restore(); + } + + if (timeLayout != null) { + if (timeReplaceProgress != 1f) { + textPaint.setAlpha((int) (alpha * timeReplaceProgress)); + } + canvas.save(); + canvas.translate(rect.centerX() - textWidth / 2, AndroidUtilities.dp(17.2f) - AndroidUtilities.dp(10) * (1f - timeReplaceProgress)); + timeLayout.draw(canvas); + if (timeReplaceProgress != 1f) { + textPaint.setAlpha(alpha); + } + canvas.restore(); + } + + // canvas.drawText(timeLeftString, rect.centerX() - textWidth / 2, AndroidUtilities.dp(28.2f), textPaint); + // canvas.drawText(timeLeftString, , textPaint); canvas.drawArc(rect, -90, -360 * (timeLeft / 5000.0f), false, progressPaint); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/EditWidgetActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/EditWidgetActivity.java index 85bf4cb61..eb6de50bf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/EditWidgetActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/EditWidgetActivity.java @@ -606,7 +606,13 @@ public class EditWidgetActivity extends BaseFragment { } if (dialog != null && dialog.unread_count > 0) { - ((TextView) cells[position].findViewById(a == 0 ? R.id.contacts_widget_item_badge1 : R.id.contacts_widget_item_badge2)).setText(String.format("%d", dialog.unread_count)); + String count; + if (dialog.unread_count > 99) { + count = String.format("%d+", 99); + } else { + count = String.format("%d", dialog.unread_count); + } + ((TextView) cells[position].findViewById(a == 0 ? R.id.contacts_widget_item_badge1 : R.id.contacts_widget_item_badge2)).setText(count); cells[position].findViewById(a == 0 ? R.id.contacts_widget_item_badge_bg1 : R.id.contacts_widget_item_badge_bg2).setVisibility(VISIBLE); } else { cells[position].findViewById(a == 0 ? R.id.contacts_widget_item_badge_bg1 : R.id.contacts_widget_item_badge_bg2).setVisibility(GONE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java index a253da32f..0be024b2d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ManageLinksActivity.java @@ -848,7 +848,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen if (isPublic && adminId == getAccountInstance().getUserConfig().clientUserId) { headerCell.setText(LocaleController.getString("PublicLink", R.string.PublicLink)); } else if (adminId == getAccountInstance().getUserConfig().clientUserId) { - headerCell.setText(LocaleController.getString("ChannelLinkTitle", R.string.ChannelLinkTitle)); + headerCell.setText(LocaleController.getString("ChannelInviteLinkTitle", R.string.ChannelInviteLinkTitle)); } else { headerCell.setText(LocaleController.getString("PermanentLinkForThisAdmin", R.string.PermanentLinkForThisAdmin)); } @@ -1123,7 +1123,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen icons.add(R.drawable.msg_copy); actions.add(0); - items.add(LocaleController.getString("Share", R.string.ShareLink)); + items.add(LocaleController.getString("ShareLink", R.string.ShareLink)); icons.add(R.drawable.msg_share); actions.add(1); @@ -1765,11 +1765,19 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen return true; } + int animationIndex = -1; @Override protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) { super.onTransitionAnimationEnd(isOpen, backward); if (isOpen) { isOpened = true; } + NotificationCenter.getInstance(currentAccount).onAnimationFinish(animationIndex); + } + + @Override + protected void onTransitionAnimationStart(boolean isOpen, boolean backward) { + super.onTransitionAnimationStart(isOpen, backward); + animationIndex = NotificationCenter.getInstance(currentAccount).setAnimationInProgress(animationIndex, null); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 6cf5ccb18..25770d288 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -3001,7 +3001,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat ArrayList arr = (ArrayList) args[2]; endReached[loadIndex] = (Boolean) args[5]; if (needSearchImageInArr) { - if (arr.isEmpty() && (loadIndex != 0 || mergeDialogId == 0)) { + if (arr.isEmpty() && (loadIndex != 0 || mergeDialogId == 0) || currentIndex < 0 || currentIndex >= imagesArr.size()) { needSearchImageInArr = false; return; } @@ -3181,7 +3181,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat } setImageIndex(index); } else { - closePhoto(false, false); + closePhoto(false, true); } } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index 83de68ce9..b0bcd7747 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -5455,6 +5455,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (user_id != 0) { TLRPC.User user = getMessagesController().getUser(user_id); + if (user == null) { + return; + } TLRPC.FileLocation photoBig = null; if (user.photo != null) { photoBig = user.photo.photo_big; diff --git a/TMessagesProj/src/main/res/layout/contacts_widget_item.xml b/TMessagesProj/src/main/res/layout/contacts_widget_item.xml index 409416593..4c0d4102f 100644 --- a/TMessagesProj/src/main/res/layout/contacts_widget_item.xml +++ b/TMessagesProj/src/main/res/layout/contacts_widget_item.xml @@ -43,6 +43,7 @@ android:layout_gravity="center" android:layout_marginBottom="27dp" android:layout_marginLeft="20dp" + android:layout_marginRight="2dp" android:id="@+id/contacts_widget_item_badge_bg1"> - + android:layout_alignParentStart="true" + android:layout_marginEnd="4dp" + android:layout_toStartOf="@+id/shortcut_widget_item_time"/> + @@ -64,8 +64,8 @@ android:textColor="@color/widget_text" android:autoLink="none" android:textColorLink="@color/widget_text" - android:layout_alignParentLeft="true" - android:layout_toLeftOf="@+id/shortcut_widget_item_badge"/> + android:layout_alignParentStart="true" + android:layout_toStartOf="@+id/shortcut_widget_item_badge"/> @@ -87,6 +88,7 @@ android:layout_marginStart="76dp" android:layout_width="match_parent" android:layout_height="1px" + android:layout_marginEnd="8dp" android:layout_gravity="bottom|start" android:background="@color/widget_divider"/>