Update to 7.5.0 (2246)

This commit is contained in:
DrKLO 2021-02-25 19:58:14 +03:00
parent c44841a55b
commit e1c101c334
17 changed files with 178 additions and 89 deletions

View file

@ -288,7 +288,7 @@ android {
}
}
defaultConfig.versionCode = 2245
defaultConfig.versionCode = 2246
applicationVariants.all { variant ->
variant.outputs.all { output ->

View file

@ -297,9 +297,17 @@ void Connection::connect() {
if (strategy == USE_IPV6_ONLY) {
ipv6 = TcpAddressFlagIpv6;
} else if (strategy == USE_IPV4_IPV6_RANDOM) {
if (ConnectionsManager::getInstance(currentDatacenter->instanceNum).lastProtocolUsefullData) {
ipv6 = ConnectionsManager::getInstance(currentDatacenter->instanceNum).lastProtocolIsIpv6 ? TcpAddressFlagIpv6 : 0;
} else {
uint8_t value;
RAND_bytes(&value, 1);
ipv6 = value % 2 == 0 ? TcpAddressFlagIpv6 : 0;
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;
}

View file

@ -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;
}
@ -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);

View file

@ -193,6 +193,8 @@ private:
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;

View file

@ -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"/>

View file

@ -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";

View file

@ -12648,10 +12648,12 @@ public class MessagesController extends BaseController implements NotificationCe
}*/
}
if ((update.notify_settings.flags & 4) != 0) {
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) {
editor.putBoolean("EnablePreviewAll", update.notify_settings.show_previews);
@ -12664,10 +12666,12 @@ public class MessagesController extends BaseController implements NotificationCe
}*/
}
if ((update.notify_settings.flags & 4) != 0) {
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) {
editor.putBoolean("EnablePreviewChannel", update.notify_settings.show_previews);
@ -12680,11 +12684,13 @@ public class MessagesController extends BaseController implements NotificationCe
}*/
}
if ((update.notify_settings.flags & 4) != 0) {
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();
}
} else if (baseUpdate instanceof TLRPC.TL_updateChannel) {

View file

@ -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);
@ -3169,6 +3171,7 @@ public class NotificationsController extends BaseController {
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();
}

View file

@ -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_")) {
@ -35,22 +41,59 @@ public class NotificationsDisabledReceiver extends BroadcastReceiver {
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);

View file

@ -43223,6 +43223,23 @@ public class TLRPC {
}
}
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;

View file

@ -720,7 +720,7 @@ public class ChannelCreateActivity extends BaseFragment implements NotificationC
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);

View file

@ -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;
@ -677,6 +679,8 @@ public class InviteLinkBottomSheet extends BottomSheet {
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;
@ -915,4 +919,8 @@ public class InviteLinkBottomSheet extends BottomSheet {
super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(84), MeasureSpec.EXACTLY));
}
}
public void setCanEdit(boolean canEdit) {
this.canEdit = canEdit;
}
}

View file

@ -303,6 +303,7 @@ public class LinkActionView extends LinearLayout {
}
});
actionBarPopupWindow.setOutsideTouchable(true);
actionBarPopupWindow.setFocusable(true);
actionBarPopupWindow.setBackgroundDrawable(new ColorDrawable(Color.TRANSPARENT));
actionBarPopupWindow.setAnimationStyle(R.style.PopupContextAnimation);
actionBarPopupWindow.setInputMethodMode(ActionBarPopupWindow.INPUT_METHOD_NOT_NEEDED);
@ -417,7 +418,7 @@ public class LinkActionView extends LinearLayout {
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);

View file

@ -54,7 +54,7 @@ public class PermanentLinkBottomSheet extends BottomSheet {
linkIcon.setCustomEndFrame(42);
imageView.setAnimation(linkIcon);
linkActionView.setUsers(0, null);
linkActionView.showRevokeOption(true);
linkActionView.hideRevokeOption(true);
linkActionView.setDelegate(() -> generateLink(true));
titleView = new TextView(context);

View file

@ -75,7 +75,7 @@ import java.util.ArrayList;
import java.util.HashMap;
import java.util.Locale;
public class ManageLinksActivity extends BaseFragment implements NotificationCenter.NotificationCenterDelegate {
public class ManageLinksActivity extends BaseFragment {
private ListAdapter listViewAdapter;
private RecyclerListView listView;
@ -142,11 +142,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
long timeDif;
private boolean isPublic;
@Override
public void didReceivedNotification(int id, int account, Object... args) {
}
private boolean canEdit;
Runnable updateTimerRunnable = new Runnable() {
@Override
@ -168,7 +164,6 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
}
};
private static class EmptyView extends LinearLayout implements NotificationCenter.NotificationCenterDelegate {
private BackupImageView stickerView;
@ -237,11 +232,14 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
} else {
this.adminId = adminId;
}
TLRPC.User user = getMessagesController().getUser(this.adminId);
canEdit = (this.adminId == getAccountInstance().getUserConfig().clientUserId) || (user != null && !user.bot);
}
boolean loadRevoked = false;
private void loadLinks() {
private void loadLinks(boolean notify) {
if (loadAdmins && !adminsLoaded) {
linksLoading = true;
TLRPC.TL_messages_getAdminsWithInvites req = new TLRPC.TL_messages_getAdminsWithInvites();
@ -273,16 +271,16 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
recyclerItemsEnterAnimator.showItemsAnimated(oldRowsCount + 1);
}
}
if (!hasMore || (invites.size() + revokedInvites.size() + admins.size()) >= 5) {
resumeDelayedFragmentAnimation();
}
if (!hasMore && !loadRevoked) {
hasMore = true;
loadRevoked = true;
loadLinks();
loadLinks(false);
}
updateRows(true);
if (!hasMore || (invites.size() + revokedInvites.size() + admins.size()) >= 5) {
resumeDelayedFragmentAnimation();
}
});
});
});
@ -407,13 +405,11 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
}
if (loadNext) {
loadLinks();
loadLinks(false);
}
if (updateByDiffUtils && isOpened && listViewAdapter != null && listView.getChildCount() > 0) {
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
if (updateByDiffUtils && listViewAdapter != null && listView.getChildCount() > 0) {
updateRecyclerViewAnimated(callback);
} else {
updateRows(true);
}
@ -422,6 +418,9 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
});
getConnectionsManager().bindRequestToGuid(reqId, getClassGuid());
}
if (notify) {
updateRows(true);
}
}
private void updateRows(boolean notify) {
@ -468,7 +467,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
if (!otherAdmin) {
dividerRow = rowCount++;
createNewLinkRow = rowCount++;
} else if (!invites.isEmpty() || (linksLoading && !loadRevoked)) {
} else if (!invites.isEmpty()) {
dividerRow = rowCount++;
linksHeaderRow = rowCount++;
}
@ -509,7 +508,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
revokeAllRow = rowCount++;
}
if (!loadAdmins && !loadRevoked && (linksLoading || hasMore)) {
if (!loadAdmins && !loadRevoked && (linksLoading || hasMore) && !otherAdmin) {
linksLoadingRow = rowCount++;
}
@ -571,7 +570,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
if (hasMore && !linksLoading) {
int lastPosition = layoutManager.findLastVisibleItemPosition();
if (rowCount - lastPosition < 10) {
loadLinks();
loadLinks(true);
}
}
}
@ -601,6 +600,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
} else if (position >= linksStartRow && position < linksEndRow) {
TLRPC.TL_chatInviteExported invite = invites.get(position - linksStartRow);
inviteLinkBottomSheet = new InviteLinkBottomSheet(context, invite, info, users, this, currentChatId, false, isChannel);
inviteLinkBottomSheet.setCanEdit(canEdit);
inviteLinkBottomSheet.show();
} else if (position >= revokedLinksStartRow && position < revokedLinksEndRow) {
TLRPC.TL_chatInviteExported invite = revokedInvites.get(position - revokedLinksStartRow);
@ -628,9 +628,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
if (error == null) {
DiffCallback callback = saveListState();
revokedInvites.clear();
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
updateRecyclerViewAnimated(callback);
}
}));
});
@ -671,7 +669,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
this.invite = (TLRPC.TL_chatInviteExported) invite;
isPublic = !TextUtils.isEmpty(currentChat.username);
loadLinks();
loadLinks(true);
}
@Override
@ -765,7 +763,6 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
@Override
public void showUsersForPermanentLink() {
boolean canEdit = adminId == getAccountInstance().getUserConfig().clientUserId;
inviteLinkBottomSheet = new InviteLinkBottomSheet(linkActionView.getContext(), invite, info, users, ManageLinksActivity.this, currentChatId, true, isChannel);
inviteLinkBottomSheet.show();
}
@ -828,10 +825,10 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
if (info != null) {
linkActionView.setLink("https://t.me/" + currentChat.username);
linkActionView.setUsers(0, null);
linkActionView.showRevokeOption(true);
linkActionView.hideRevokeOption(true);
}
} else {
linkActionView.showRevokeOption(false);
linkActionView.hideRevokeOption(!canEdit);
if (invite != null) {
TLRPC.TL_chatInviteExported inviteExported = invite;
linkActionView.setLink(inviteExported.link);
@ -971,10 +968,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
oldInvite.revoked = true;
DiffCallback callback = saveListState();
revokedInvites.add(0, oldInvite);
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
updateRecyclerViewAnimated(callback);
BulletinFactory.of(this).createSimpleBulletin(R.raw.linkbroken, LocaleController.getString("InviteRevokedHint", R.string.InviteRevokedHint)).show();
}
@ -1114,10 +1108,12 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
ArrayList<Integer> icons = new ArrayList<>();
final ArrayList<Integer> actions = new ArrayList<>();
boolean redLastItem = false;
if (invite.revoked) {
items.add(LocaleController.getString("Delete", R.string.Delete));
icons.add(R.drawable.msg_delete);
actions.add(4);
redLastItem = true;
} else {
items.add(LocaleController.getString("Copy", R.string.Copy));
icons.add(R.drawable.msg_copy);
@ -1127,15 +1123,18 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
icons.add(R.drawable.msg_share);
actions.add(1);
if (!invite.permanent) {
if (!invite.permanent && canEdit) {
items.add(LocaleController.getString("Edit", R.string.Edit));
icons.add(R.drawable.msg_edit);
actions.add(2);
}
if (canEdit) {
items.add(LocaleController.getString("RevokeLink", R.string.RevokeLink));
icons.add(R.drawable.msg_delete);
actions.add(3);
redLastItem = true;
}
}
AlertDialog.Builder builder = new AlertDialog.Builder(getParentActivity());
@ -1197,9 +1196,9 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
builder.setTitle(LocaleController.getString("InviteLink", R.string.InviteLink));
AlertDialog alert = builder.create();
builder.show();
//if (adminId == getAccountInstance().getUserConfig().getClientUserId()) {
if (redLastItem) {
alert.setItemColor(items.size() - 1, Theme.getColor(Theme.key_dialogTextRed2), Theme.getColor(Theme.key_dialogRedIcon));
// }
}
});
optionsView.setBackground(Theme.createSelectorDrawable(Theme.getColor(Theme.key_listSelector), 1));
addView(optionsView, LayoutHelper.createFrame(40, 48, Gravity.RIGHT | Gravity.CENTER_VERTICAL));
@ -1481,20 +1480,14 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
invite.revoked = true;
DiffCallback callback = saveListState();
if (isPublic) {
if (isPublic && adminId == getAccountInstance().getUserConfig().getClientUserId()) {
invites.remove(invite);
invites.add(0, (TLRPC.TL_chatInviteExported) replaced.new_invite);
} else if (this.invite != null) {
this.invite = (TLRPC.TL_chatInviteExported) replaced.new_invite;
}
revokedInvites.add(0, invite);
updateRows(false);
if (getParentActivity() == null) {
listViewAdapter.notifyDataSetChanged();
return;
}
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
updateRecyclerViewAnimated(callback);
} else {
linkEditActivityCallback.onLinkEdited(invite, response);
if (info != null) {
@ -1517,10 +1510,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
AndroidUtilities.runOnUIThread(() -> {
DiffCallback callback = saveListState();
invites.add(0, (TLRPC.TL_chatInviteExported) response);
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
updateRecyclerViewAnimated(callback);
if (info != null) {
info.invitesCount++;
getMessagesStorage().saveChatLinksCount(currentChatId, info.invitesCount);
@ -1540,13 +1530,10 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
DiffCallback callback = saveListState();
invites.remove(i);
revokedInvites.add(0, edited);
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
updateRecyclerViewAnimated(callback);
} else {
invites.set(i, edited);
listViewAdapter.notifyDataSetChanged();
updateRows(true);
}
return;
}
@ -1560,10 +1547,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
if (revokedInvites.get(i).link.equals(removedInvite.link)) {
DiffCallback callback = saveListState();
revokedInvites.remove(i);
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
updateRecyclerViewAnimated(callback);
return;
}
}
@ -1575,6 +1559,17 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
}
};
private void updateRecyclerViewAnimated(DiffCallback callback) {
if (isPaused || listViewAdapter == null || listView == null) {
updateRows(true);
return;
}
updateRows(false);
callback.fillPositions(callback.newPositionToItem);
DiffUtil.calculateDiff(callback).dispatchUpdatesTo(listViewAdapter);
AndroidUtilities.updateVisibleRows(listView);
}
private class DiffCallback extends DiffUtil.Callback {
@ -1644,15 +1639,15 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
put(++pointer, dividerRow, sparseIntArray);
put(++pointer, createNewLinkRow, sparseIntArray);
put(++pointer, revokedHeader, sparseIntArray);
put(++pointer, revokedDivider, sparseIntArray);
put(++pointer, lastDivider, sparseIntArray);
put(++pointer, revokeAllDivider, sparseIntArray);
// put(++pointer, revokedDivider, sparseIntArray);
// put(++pointer, lastDivider, sparseIntArray);
// put(++pointer, revokeAllDivider, sparseIntArray);
put(++pointer, revokeAllRow, sparseIntArray);
put(++pointer, createLinkHelpRow, sparseIntArray);
put(++pointer, creatorRow, sparseIntArray);
put(++pointer, creatorDividerRow, sparseIntArray);
put(++pointer, adminsHeaderRow, sparseIntArray);
put(++pointer, adminsDividerRow, sparseIntArray);
// put(++pointer, adminsDividerRow, sparseIntArray);
put(++pointer, linksHeaderRow, sparseIntArray);
put(++pointer, linksLoadingRow, sparseIntArray);
}
@ -1766,6 +1761,7 @@ public class ManageLinksActivity extends BaseFragment implements NotificationCen
}
int animationIndex = -1;
@Override
protected void onTransitionAnimationEnd(boolean isOpen, boolean backward) {
super.onTransitionAnimationEnd(isOpen, backward);

View file

@ -43,7 +43,7 @@
android:layout_gravity="center"
android:layout_marginBottom="27dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="2dp"
android:layout_marginRight="4dp"
android:id="@+id/contacts_widget_item_badge_bg1">
<TextView android:id="@+id/contacts_widget_item_badge1"
@ -99,7 +99,7 @@
android:layout_gravity="center"
android:layout_marginBottom="27dp"
android:layout_marginLeft="20dp"
android:layout_marginRight="2dp"
android:layout_marginRight="4dp"
android:id="@+id/contacts_widget_item_badge_bg2">
<TextView android:id="@+id/contacts_widget_item_badge2"

View file

@ -13,6 +13,8 @@
android:paddingRight="10dp"
android:textColor="@color/widget_edit_text"
android:layout_gravity="center"
android:singleLine="true"
android:ellipsize="end"
android:background="@drawable/widget_edit"
android:gravity="center"/>