Skip to content

Commit

Permalink
Update to 7.5.0 (2246)
Browse files Browse the repository at this point in the history
  • Loading branch information
DrKLO committed Feb 25, 2021
1 parent c44841a commit e1c101c
Show file tree
Hide file tree
Showing 17 changed files with 178 additions and 89 deletions.
2 changes: 1 addition & 1 deletion TMessagesProj/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -288,7 +288,7 @@ android {
}
}

defaultConfig.versionCode = 2245
defaultConfig.versionCode = 2246

applicationVariants.all { variant ->
variant.outputs.all { output ->
Expand Down
14 changes: 11 additions & 3 deletions TMessagesProj/jni/tgnet/Connection.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,9 +297,17 @@ void Connection::connect() {
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;
if (ConnectionsManager::getInstance(currentDatacenter->instanceNum).lastProtocolUsefullData) {
ipv6 = ConnectionsManager::getInstance(currentDatacenter->instanceNum).lastProtocolIsIpv6 ? TcpAddressFlagIpv6 : 0;
} else {
uint8_t value;
RAND_bytes(&value, 1);
ipv6 = value % 3 == 0 ? TcpAddressFlagIpv6 : 0;
ConnectionsManager::getInstance(currentDatacenter->instanceNum).lastProtocolIsIpv6 = ipv6 != 0;
}
if (connectionType == ConnectionTypeGeneric) {
ConnectionsManager::getInstance(currentDatacenter->instanceNum).lastProtocolUsefullData = false;
}
} else {
ipv6 = 0;
}
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/jni/tgnet/ConnectionsManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -887,6 +887,7 @@ void ConnectionsManager::onConnectionDataReceived(Connection *connection, Native
processServerResponse(object, messageId, 0, 0, connection, 0, 0);
connection->addProcessedMessageId(messageId);
}
lastProtocolUsefullData = true;
connection->setHasUsefullData();
delete object;
}
Expand Down Expand Up @@ -940,6 +941,7 @@ void ConnectionsManager::onConnectionDataReceived(Connection *connection, Native
}
if (!processedStatus) {
if (object != nullptr) {
lastProtocolUsefullData = true;
connection->setHasUsefullData();
if (LOGS_ENABLED) DEBUG_D("connection(%p, account%u, dc%u, type %d) received object %s", connection, instanceNum, datacenter->getDatacenterId(), connection->getConnectionType(), typeid(*object).name());
processServerResponse(object, messageId, messageSeqNo, messageServerSalt, connection, 0, 0);
Expand Down
2 changes: 2 additions & 0 deletions TMessagesProj/jni/tgnet/ConnectionsManager.h
Original file line number Diff line number Diff line change
Expand Up @@ -193,6 +193,8 @@ class ConnectionsManager {
bool networkAvailable = true;
bool networkSlow = false;
uint8_t ipStrategy = USE_IPV4_ONLY;
bool lastProtocolIsIpv6 = false;
bool lastProtocolUsefullData = false;
std::vector<ConnectionSocket *> activeConnections;
std::vector<ConnectionSocket *> activeConnectionsCopy;
int epolFd;
Expand Down
1 change: 1 addition & 0 deletions TMessagesProj/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.MANAGE_OWN_CALLS"/>
<uses-permission android:name="android.permission.USE_FULL_SCREEN_INTENT"/>
<uses-permission android:name="android.permission.REQUEST_INSTALL_PACKAGES" />

<uses-permission android:name="com.sec.android.provider.badge.permission.READ"/>
<uses-permission android:name="com.sec.android.provider.badge.permission.WRITE"/>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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 = 2245;
public static int BUILD_VERSION = 2246;
public static String BUILD_VERSION_STRING = "7.5.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -12648,9 +12648,11 @@ public boolean processUpdateArray(ArrayList<TLRPC.Update> updates, final ArrayLi
}*/
}
if ((update.notify_settings.flags & 4) != 0) {
editor.putInt("EnableGroup2", update.notify_settings.mute_until);
editor.putBoolean("overwrite_group", true);
AndroidUtilities.runOnUIThread(() -> getNotificationsController().deleteNotificationChannelGlobal(NotificationsController.TYPE_GROUP));
if (notificationsPreferences.getInt("EnableGroup2", 0) != update.notify_settings.mute_until) {
editor.putInt("EnableGroup2", update.notify_settings.mute_until);
editor.putBoolean("overwrite_group", true);
AndroidUtilities.runOnUIThread(() -> getNotificationsController().deleteNotificationChannelGlobal(NotificationsController.TYPE_GROUP));
}
}
} else if (update.peer instanceof TLRPC.TL_notifyUsers) {
if ((update.notify_settings.flags & 1) != 0) {
Expand All @@ -12664,9 +12666,11 @@ public boolean processUpdateArray(ArrayList<TLRPC.Update> updates, final ArrayLi
}*/
}
if ((update.notify_settings.flags & 4) != 0) {
editor.putInt("EnableAll2", update.notify_settings.mute_until);
editor.putBoolean("overwrite_private", true);
AndroidUtilities.runOnUIThread(() -> getNotificationsController().deleteNotificationChannelGlobal(NotificationsController.TYPE_PRIVATE));
if (notificationsPreferences.getInt("EnableAll2", 0) != update.notify_settings.mute_until) {
editor.putInt("EnableAll2", update.notify_settings.mute_until);
editor.putBoolean("overwrite_private", true);
AndroidUtilities.runOnUIThread(() -> getNotificationsController().deleteNotificationChannelGlobal(NotificationsController.TYPE_PRIVATE));
}
}
} else if (update.peer instanceof TLRPC.TL_notifyBroadcasts) {
if ((update.notify_settings.flags & 1) != 0) {
Expand All @@ -12680,9 +12684,11 @@ public boolean processUpdateArray(ArrayList<TLRPC.Update> updates, final ArrayLi
}*/
}
if ((update.notify_settings.flags & 4) != 0) {
editor.putInt("EnableChannel2", update.notify_settings.mute_until);
editor.putBoolean("overwrite_channel", true);
AndroidUtilities.runOnUIThread(() -> getNotificationsController().deleteNotificationChannelGlobal(NotificationsController.TYPE_CHANNEL));
if (notificationsPreferences.getInt("EnableChannel2", 0) != update.notify_settings.mute_until) {
editor.putInt("EnableChannel2", update.notify_settings.mute_until);
editor.putBoolean("overwrite_channel", true);
AndroidUtilities.runOnUIThread(() -> getNotificationsController().deleteNotificationChannelGlobal(NotificationsController.TYPE_CHANNEL));
}
}
}
getMessagesStorage().updateMutedDialogsFiltersCounters();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -104,6 +104,8 @@ public class NotificationsController extends BaseController {
private int lastBadgeCount = -1;
private String launcherClassName;

public long lastNotificationChannelCreateTime;

private Boolean groupsCreated;

public static long globalSecretChatId = -(1L << 32);
Expand Down Expand Up @@ -3169,6 +3171,7 @@ private String validateChannelId(long dialogId, String name, long[] vibrationPat
if (BuildVars.LOGS_ENABLED) {
FileLog.d("create new channel " + channelId);
}
lastNotificationChannelCreateTime = SystemClock.elapsedRealtime();
systemNotificationManager.createNotificationChannel(notificationChannel);
preferences.edit().putString(key, channelId).putString(key + "_s", newSettingsHash).commit();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,19 +8,25 @@

package org.telegram.messenger;

import android.annotation.TargetApi;
import android.content.BroadcastReceiver;
import android.content.Context;
import android.content.Intent;
import android.content.SharedPreferences;
import android.os.SystemClock;
import android.text.TextUtils;

import static android.app.NotificationManager.EXTRA_BLOCKED_STATE;
import static android.app.NotificationManager.EXTRA_NOTIFICATION_CHANNEL_ID;

@TargetApi(28)
public class NotificationsDisabledReceiver extends BroadcastReceiver {

@Override
public void onReceive(Context context, Intent intent) {
if (!"android.app.action.NOTIFICATION_CHANNEL_BLOCK_STATE_CHANGED".equals(intent.getAction())) {
return;
}
String channelId = intent.getStringExtra(EXTRA_NOTIFICATION_CHANNEL_ID);
boolean state = intent.getBooleanExtra(EXTRA_BLOCKED_STATE, false);
if (TextUtils.isEmpty(channelId) || channelId.contains("_ia_")) {
Expand All @@ -35,22 +41,59 @@ public void onReceive(Context context, Intent intent) {
if (account < 0 || account >= UserConfig.MAX_ACCOUNT_COUNT) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("received disabled notification channel event for " + channelId + " state = " + state);
}
if (SystemClock.elapsedRealtime() - AccountInstance.getInstance(account).getNotificationsController().lastNotificationChannelCreateTime <= 1000) {
if (BuildVars.LOGS_ENABLED) {
FileLog.d("received disable notification event right after creating notification channel, ignoring");
}
return;
}
SharedPreferences preferences = AccountInstance.getInstance(account).getNotificationsSettings();
SharedPreferences.Editor editor = preferences.edit();
if (args[1].startsWith("channel")) {
editor.putInt(NotificationsController.getGlobalNotificationsKey(NotificationsController.TYPE_CHANNEL), state ? Integer.MAX_VALUE : 0).commit();
String currentChannel = preferences.getString("channels", null);
if (!channelId.equals(currentChannel)) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("apply channel " + channelId + " state");
}
preferences.edit().putInt(NotificationsController.getGlobalNotificationsKey(NotificationsController.TYPE_CHANNEL), state ? Integer.MAX_VALUE : 0).commit();
AccountInstance.getInstance(account).getNotificationsController().updateServerNotificationsSettings(NotificationsController.TYPE_CHANNEL);
} else if (args[1].startsWith("groups")) {
editor.putInt(NotificationsController.getGlobalNotificationsKey(NotificationsController.TYPE_GROUP), state ? Integer.MAX_VALUE : 0).commit();
String currentChannel = preferences.getString("groups", null);
if (!channelId.equals(currentChannel)) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("apply channel " + channelId + " state");
}
preferences.edit().putInt(NotificationsController.getGlobalNotificationsKey(NotificationsController.TYPE_GROUP), state ? Integer.MAX_VALUE : 0).commit();
AccountInstance.getInstance(account).getNotificationsController().updateServerNotificationsSettings(NotificationsController.TYPE_GROUP);
} else if (args[1].startsWith("private")) {
editor.putInt(NotificationsController.getGlobalNotificationsKey(NotificationsController.TYPE_PRIVATE), state ? Integer.MAX_VALUE : 0).commit();
String currentChannel = preferences.getString("private", null);
if (!channelId.equals(currentChannel)) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("apply channel " + channelId + " state");
}
preferences.edit().putInt(NotificationsController.getGlobalNotificationsKey(NotificationsController.TYPE_PRIVATE), state ? Integer.MAX_VALUE : 0).commit();
AccountInstance.getInstance(account).getNotificationsController().updateServerNotificationsSettings(NotificationsController.TYPE_PRIVATE);
} else {
long dialogId = Utilities.parseLong(args[1]);
if (dialogId == 0) {
return;
}
String currentChannel = preferences.getString("org.telegram.key" + dialogId, null);
if (!channelId.equals(currentChannel)) {
return;
}
if (BuildVars.LOGS_ENABLED) {
FileLog.d("apply channel " + channelId + " state");
}
SharedPreferences.Editor editor = preferences.edit();
editor.putInt("notify2_" + dialogId, state ? 2 : 0);
if (!state) {
editor.remove("notifyuntil_" + dialogId);
Expand Down
17 changes: 17 additions & 0 deletions TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java
Original file line number Diff line number Diff line change
Expand Up @@ -43223,6 +43223,23 @@ public void serializeToStream(AbstractSerializedData stream) {
}
}

public static class TL_messages_getExportedChatInvite extends TLObject {
public static int constructor = 0x73746f5c;

public InputPeer peer;
public String link;

public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return messages_ExportedChatInvite.TLdeserialize(stream, constructor, exception);
}

public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
peer.serializeToStream(stream);
stream.writeString(link);
}
}

public static class TL_messages_editExportedChatInvite extends TLObject {
public static int constructor = 0x2e4ffbe;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -720,7 +720,7 @@ public void afterTextChanged(Editable editable) {

permanentLinkView = new LinkActionView(context, this, null, chatId, true, ChatObject.isChannel(getMessagesController().getChat(chatId)));
//permanentLinkView.showOptions(false);
permanentLinkView.showRevokeOption(true);
permanentLinkView.hideRevokeOption(true);
permanentLinkView.setUsers(0, null);
privateContainer.addView(permanentLinkView);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ public class InviteLinkBottomSheet extends BottomSheet {
private boolean isChannel;
private final long timeDif;

private boolean canEdit = true;

public InviteLinkBottomSheet(Context context, TLRPC.TL_chatInviteExported invite, TLRPC.ChatFull info, HashMap<Integer, TLRPC.User> users, BaseFragment fragment, int chatId, boolean permanent, boolean isChannel) {
super(context, false);
this.invite = invite;
Expand Down Expand Up @@ -677,6 +679,8 @@ public void onBindViewHolder(@NonNull RecyclerView.ViewHolder holder, int positi
actionView.setLink(invite.link);
actionView.setRevoke(invite.revoked);
actionView.setPermanent(invite.permanent);
actionView.setCanEdit(canEdit);
actionView.hideRevokeOption(!canEdit);
break;
case 4:
TimerPrivacyCell privacyCell = (TimerPrivacyCell) holder.itemView;
Expand Down Expand Up @@ -915,4 +919,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(84), MeasureSpec.EXACTLY));
}
}

public void setCanEdit(boolean canEdit) {
this.canEdit = canEdit;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -303,6 +303,7 @@ public void onAnimationEnd(Animator animation) {
}
});
actionBarPopupWindow.setOutsideTouchable(true);
actionBarPopupWindow.setFocusable(true);
actionBarPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
actionBarPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
actionBarPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
Expand Down Expand Up @@ -417,7 +418,7 @@ public void showOptions(boolean b) {
optionsView.setVisibility(b ? View.VISIBLE : View.GONE);
}

public void showRevokeOption(boolean b) {
public void hideRevokeOption(boolean b) {
if (hideRevokeOption != b) {
hideRevokeOption = b;
optionsView.setVisibility(View.VISIBLE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ public PermanentLinkBottomSheet(Context context, boolean needFocus, BaseFragment
linkIcon.setCustomEndFrame(42);
imageView.setAnimation(linkIcon);
linkActionView.setUsers(0, null);
linkActionView.showRevokeOption(true);
linkActionView.hideRevokeOption(true);
linkActionView.setDelegate(() -> generateLink(true));

titleView = new TextView(context);
Expand Down
Loading

0 comments on commit e1c101c

Please sign in to comment.