diff --git a/TMessagesProj/jni/tgnet/ApiScheme.cpp b/TMessagesProj/jni/tgnet/ApiScheme.cpp
index 9093b19c8..923bfbaa7 100644
--- a/TMessagesProj/jni/tgnet/ApiScheme.cpp
+++ b/TMessagesProj/jni/tgnet/ApiScheme.cpp
@@ -1210,21 +1210,30 @@ UserStatus *UserStatus::TLdeserialize(NativeByteBuffer *stream, uint32_t constru
case 0x8c703f:
result = new TL_userStatusOffline();
break;
- case 0x7bf09fc:
- result = new TL_userStatusLastWeek();
- break;
case 0x9d05049:
result = new TL_userStatusEmpty();
break;
- case 0x77ebc742:
- result = new TL_userStatusLastMonth();
- break;
case 0xedb93949:
result = new TL_userStatusOnline();
break;
- case 0xe26f42f1:
+ case 0x7b197dc8:
result = new TL_userStatusRecently();
break;
+ case 0x541a1d1a:
+ result = new TL_userStatusLastWeek();
+ break;
+ case 0x65899777:
+ result = new TL_userStatusLastMonth();
+ break;
+ case 0xe26f42f1:
+ result = new TL_userStatusRecently_layer171();
+ break;
+ case 0x7bf09fc:
+ result = new TL_userStatusLastWeek_layer171();
+ break;
+ case 0x77ebc742:
+ result = new TL_userStatusLastMonth_layer171();
+ break;
default:
error = true;
if (LOGS_ENABLED) DEBUG_FATAL("can't parse magic %x in UserStatus", constructor);
@@ -1243,8 +1252,19 @@ void TL_userStatusOffline::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(expires);
}
+void TL_userStatusLastWeek_layer171::serializeToStream(NativeByteBuffer *stream) {
+ stream->writeInt32(constructor);
+}
+
void TL_userStatusLastWeek::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
+ flags = by_me ? flags | 1 : flags &~ 1;
+ stream->writeInt32(flags);
+}
+
+void TL_userStatusLastWeek::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
+ flags = stream->readInt32(&error);
+ by_me = (flags & 1) != 0;
}
void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) {
@@ -1253,6 +1273,17 @@ void TL_userStatusEmpty::serializeToStream(NativeByteBuffer *stream) {
void TL_userStatusLastMonth::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
+ flags = by_me ? flags | 1 : flags &~ 1;
+ stream->writeInt32(flags);
+}
+
+void TL_userStatusLastMonth::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
+ flags = stream->readInt32(&error);
+ by_me = (flags & 1) != 0;
+}
+
+void TL_userStatusLastMonth_layer171::serializeToStream(NativeByteBuffer *stream) {
+ stream->writeInt32(constructor);
}
void TL_userStatusOnline::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
@@ -1266,6 +1297,21 @@ void TL_userStatusOnline::serializeToStream(NativeByteBuffer *stream) {
void TL_userStatusRecently::serializeToStream(NativeByteBuffer *stream) {
stream->writeInt32(constructor);
+ flags = by_me ? flags | 1 : flags &~ 1;
+ stream->writeInt32(flags);
+}
+
+void TL_userStatusRecently::readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error) {
+ flags = stream->readInt32(&error);
+ by_me = (flags & 1) != 0;
+}
+
+void TL_userStatusRecently_layer171::serializeToStream(NativeByteBuffer *stream) {
+ stream->writeInt32(constructor);
+}
+
+void TL_userStatusHidden::serializeToStream(NativeByteBuffer *stream) {
+ stream->writeInt32(constructor);
}
FileLocation *FileLocation::TLdeserialize(NativeByteBuffer *stream, uint32_t constructor, int32_t instanceNum, bool &error) {
diff --git a/TMessagesProj/jni/tgnet/ApiScheme.h b/TMessagesProj/jni/tgnet/ApiScheme.h
index edee2074f..e2d682076 100644
--- a/TMessagesProj/jni/tgnet/ApiScheme.h
+++ b/TMessagesProj/jni/tgnet/ApiScheme.h
@@ -203,6 +203,18 @@ public:
class TL_userStatusLastWeek : public UserStatus {
+public:
+ static const uint32_t constructor = 0x7bf09fc;
+
+ uint32_t flags;
+ bool by_me;
+
+ void serializeToStream(NativeByteBuffer *stream);
+ void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
+};
+
+class TL_userStatusLastWeek_layer171 : public UserStatus {
+
public:
static const uint32_t constructor = 0x7bf09fc;
@@ -219,6 +231,19 @@ public:
class TL_userStatusLastMonth : public UserStatus {
+public:
+ static const uint32_t constructor = 0x65899777;
+
+ uint32_t flags;
+ bool by_me;
+
+ void serializeToStream(NativeByteBuffer *stream);
+
+ void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
+};
+
+class TL_userStatusLastMonth_layer171 : public UserStatus {
+
public:
static const uint32_t constructor = 0x77ebc742;
@@ -236,12 +261,32 @@ public:
class TL_userStatusRecently : public UserStatus {
+public:
+ static const uint32_t constructor = 0x7b197dc8;
+
+ uint32_t flags;
+ bool by_me;
+
+ void serializeToStream(NativeByteBuffer *stream);
+ void readParams(NativeByteBuffer *stream, int32_t instanceNum, bool &error);
+};
+
+class TL_userStatusRecently_layer171 : public UserStatus {
+
public:
static const uint32_t constructor = 0xe26f42f1;
void serializeToStream(NativeByteBuffer *stream);
};
+class TL_userStatusHidden : public UserStatus {
+
+public:
+ static const uint32_t constructor = 0xcf7d64b1;
+
+ void serializeToStream(NativeByteBuffer *stream);
+};
+
class FileLocation : public TLObject {
public:
diff --git a/TMessagesProj/src/main/AndroidManifest.xml b/TMessagesProj/src/main/AndroidManifest.xml
index fded91118..63066e626 100644
--- a/TMessagesProj/src/main/AndroidManifest.xml
+++ b/TMessagesProj/src/main/AndroidManifest.xml
@@ -569,15 +569,13 @@
-
-
+
+
-
-
diff --git a/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java b/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java
index 66516c7b0..765c7c3cf 100644
--- a/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java
+++ b/TMessagesProj/src/main/java/androidx/recyclerview/widget/ChatListItemAnimator.java
@@ -5,6 +5,7 @@ import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
+import android.util.Log;
import android.util.LongSparseArray;
import android.view.View;
import android.view.ViewPropertyAnimator;
@@ -51,6 +52,7 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
private ArrayList willChangedGroups = new ArrayList<>();
HashMap animators = new HashMap<>();
+ ArrayList thanosViews = new ArrayList<>();
ArrayList runOnAnimationsEnd = new ArrayList<>();
HashMap groupIdToEnterDelay = new HashMap<>();
@@ -925,7 +927,12 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
animator.removeAllListeners();
restoreTransitionParams(holder.itemView);
if (holder.itemView instanceof ChatMessageCell) {
- MessageObject.GroupedMessages group = ((ChatMessageCell) view).getCurrentMessagesGroup();
+ ChatMessageCell cell = (ChatMessageCell) holder.itemView;
+ if (cell.makeVisibleAfterChange) {
+ cell.makeVisibleAfterChange = false;
+ cell.setVisibility(View.VISIBLE);
+ }
+ MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup();
if (group != null) {
group.transitionParams.reset();
}
@@ -1092,6 +1099,12 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
animator.cancel();
}
}
+ if (!thanosViews.isEmpty()) {
+ ThanosEffect thanosEffect = getThanosEffectContainer.run();
+ if (thanosEffect != null) {
+ thanosEffect.kill();
+ }
+ }
}
@Override
@@ -1100,6 +1113,12 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
if (animator != null) {
animator.cancel();
}
+ if (thanosViews.contains(item.itemView)) {
+ ThanosEffect thanosEffect = getThanosEffectContainer.run();
+ if (thanosEffect != null) {
+ thanosEffect.cancel(item.itemView);
+ }
+ }
super.endAnimation(item);
restoreTransitionParams(item.itemView);
}
@@ -1230,6 +1249,12 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
if (a != null) {
a.cancel();
}
+ if (thanosViews.contains(item.itemView)) {
+ ThanosEffect thanosEffect = getThanosEffectContainer.run();
+ if (thanosEffect != null) {
+ thanosEffect.cancel(item.itemView);
+ }
+ }
boolean oldItem = false;
if (changeInfo.newHolder == item) {
@@ -1447,7 +1472,9 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
dispatchRemoveFinished(holder);
dispatchFinishedWhenDone();
}
+ thanosViews.remove(view);
});
+ thanosViews.add(view);
} else {
ObjectAnimator animator = ObjectAnimator.ofFloat(view, View.ALPHA, view.getAlpha(), 0f);
dispatchRemoveStarting(holder);
@@ -1497,7 +1524,9 @@ public class ChatListItemAnimator extends DefaultItemAnimator {
}
dispatchFinishedWhenDone();
}
+ thanosViews.removeAll(views);
});
+ thanosViews.add(views.get(0));
recyclerListView.stopScroll();
}
diff --git a/TMessagesProj/src/main/java/androidx/recyclerview/widget/GridLayoutManagerFixed.java b/TMessagesProj/src/main/java/androidx/recyclerview/widget/GridLayoutManagerFixed.java
index 265c55aad..06b9b0c10 100644
--- a/TMessagesProj/src/main/java/androidx/recyclerview/widget/GridLayoutManagerFixed.java
+++ b/TMessagesProj/src/main/java/androidx/recyclerview/widget/GridLayoutManagerFixed.java
@@ -11,6 +11,10 @@ import android.content.Context;
import android.graphics.Rect;
import android.view.View;
+import com.google.android.exoplayer2.util.Log;
+
+import org.telegram.ui.Cells.ChatMessageCell;
+
import java.util.ArrayList;
import java.util.Arrays;
@@ -68,8 +72,9 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
} else {
for (int i = 0; i < childCount; i++) {
View child = getChildAt(i);
- if (mOrientationHelper.getDecoratedEnd(child) > scrollingOffset
- || mOrientationHelper.getTransformedEndWithDecoration(child) > scrollingOffset) {
+ final RecyclerView.LayoutParams params = (RecyclerView.LayoutParams) child.getLayoutParams();
+ if (child.getBottom() + params.bottomMargin > scrollingOffset
+ || child.getTop() + child.getHeight() > scrollingOffset) {
// stop here
recycleChildren(recycler, 0, i);
return;
@@ -115,12 +120,15 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
final int otherDirSpecMode = mOrientationHelper.getModeInOther();
final boolean layingOutInPrimaryDirection = layoutState.mItemDirection == LayoutState.ITEM_DIRECTION_TAIL;
- boolean working = true;
result.mConsumed = 0;
- int yOffset = 0;
int startPosition = layoutState.mCurrentPosition;
- if (layoutState.mLayoutDirection != LayoutState.LAYOUT_START && hasSiblingChild(layoutState.mCurrentPosition) && findViewByPosition(layoutState.mCurrentPosition + 1) == null) {
+ if (
+ mShouldReverseLayout &&
+ layoutState.mLayoutDirection != LayoutState.LAYOUT_START &&
+ hasSiblingChild(layoutState.mCurrentPosition) &&
+ findViewByPosition(layoutState.mCurrentPosition + 1) == null
+ ) {
if (hasSiblingChild(layoutState.mCurrentPosition + 1)) {
layoutState.mCurrentPosition += 3;
} else {
@@ -144,18 +152,14 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
layoutState.mCurrentPosition = backupPosition;
}
+ boolean working = true;
while (working) {
int count = 0;
- int consumedSpanCount = 0;
int remainingSpan = mSpanCount;
-
working = !additionalViews.isEmpty();
- int firstPositionStart = layoutState.mCurrentPosition;
-
while (count < mSpanCount && layoutState.hasMore(state) && remainingSpan > 0) {
int pos = layoutState.mCurrentPosition;
final int spanSize = getSpanSize(recycler, state, pos);
-
remainingSpan -= spanSize;
if (remainingSpan < 0) {
break;
@@ -171,7 +175,6 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
if (view == null) {
break;
}
- consumedSpanCount += spanSize;
mSet[count] = view;
count++;
if (layoutState.mLayoutDirection == LayoutState.LAYOUT_START && remainingSpan <= 0 && hasSiblingChild(pos)) {
@@ -236,9 +239,11 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
}
int left, right, top, bottom;
-
- boolean fromOpositeSide = shouldLayoutChildFromOpositeSide(mSet[0]);
- if (fromOpositeSide && layoutState.mLayoutDirection == LayoutState.LAYOUT_START || !fromOpositeSide && layoutState.mLayoutDirection == LayoutState.LAYOUT_END) {
+ boolean fromOppositeSide = shouldLayoutChildFromOpositeSide(mSet[0]);
+ if (
+ fromOppositeSide && layoutState.mLayoutDirection == LayoutState.LAYOUT_START ||
+ !fromOppositeSide && layoutState.mLayoutDirection == LayoutState.LAYOUT_END
+ ) {
if (layoutState.mLayoutDirection == LayoutState.LAYOUT_START) {
bottom = layoutState.mOffset - result.mConsumed;
top = bottom - maxSize;
@@ -284,7 +289,7 @@ public class GridLayoutManagerFixed extends GridLayoutManager {
left -= right;
}
layoutDecoratedWithMargins(view, left, top, left + right, bottom);
- if (layoutState.mLayoutDirection != LayoutState.LAYOUT_START) {
+ if (layoutState.mLayoutDirection == LayoutState.LAYOUT_END) {
left += right;
}
if (params.isItemRemoved() || params.isItemChanged()) {
diff --git a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java
index 3ada48885..40b1145a8 100755
--- a/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java
+++ b/TMessagesProj/src/main/java/org/telegram/SQLite/SQLitePreparedStatement.java
@@ -10,6 +10,8 @@ package org.telegram.SQLite;
import android.os.SystemClock;
+import com.google.android.exoplayer2.util.Log;
+
import org.telegram.messenger.BuildVars;
import org.telegram.messenger.FileLog;
import org.telegram.tgnet.NativeByteBuffer;
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
index 1b0801312..a09a3d127 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java
@@ -153,6 +153,8 @@ import org.telegram.ui.Components.HideViewAfterAnimation;
import org.telegram.ui.Components.LayoutHelper;
import org.telegram.ui.Components.MotionBackgroundDrawable;
import org.telegram.ui.Components.PickerBottomLayout;
+import org.telegram.ui.Components.PipRoundVideoView;
+import org.telegram.ui.Components.PipVideoOverlay;
import org.telegram.ui.Components.RecyclerListView;
import org.telegram.ui.Components.ShareAlert;
import org.telegram.ui.Components.TypefaceSpan;
@@ -5225,6 +5227,9 @@ public class AndroidUtilities {
int[] location = new int[2];
for (int i = 0; i < finalViews.size(); ++i) {
View view = finalViews.get(i);
+ if (view instanceof PipRoundVideoView.PipFrameLayout || view instanceof PipRoundVideoView.PipFrameLayout) {
+ continue;
+ }
ViewGroup.LayoutParams layoutParams = view.getLayoutParams();
if (layoutParams instanceof WindowManager.LayoutParams) {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AnimatedFileDrawableStream.java b/TMessagesProj/src/main/java/org/telegram/messenger/AnimatedFileDrawableStream.java
index 8e2b38007..92e45c323 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/AnimatedFileDrawableStream.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/AnimatedFileDrawableStream.java
@@ -27,14 +27,14 @@ public class AnimatedFileDrawableStream implements FileLoadOperationStream {
private int debugCanceledCount;
private boolean debugReportSend;
- public AnimatedFileDrawableStream(TLRPC.Document d, ImageLocation l, Object p, int a, boolean prev, int loadingPriority) {
+ public AnimatedFileDrawableStream(TLRPC.Document d, ImageLocation l, Object p, int a, boolean prev, int loadingPriority, int cacheType) {
document = d;
location = l;
parentObject = p;
currentAccount = a;
preview = prev;
this.loadingPriority = loadingPriority;
- loadOperation = FileLoader.getInstance(currentAccount).loadStreamFile(this, document, location, parentObject, 0, preview, loadingPriority);
+ loadOperation = FileLoader.getInstance(currentAccount).loadStreamFile(this, document, location, parentObject, 0, preview, loadingPriority, cacheType);
}
public boolean isFinishedLoadingFile() {
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChannelBoostsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChannelBoostsController.java
index 3a2d60869..8a4ae4192 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ChannelBoostsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChannelBoostsController.java
@@ -5,12 +5,19 @@ import com.google.android.exoplayer2.util.Consumer;
import org.telegram.tgnet.ConnectionsManager;
import org.telegram.tgnet.TLRPC;
import org.telegram.tgnet.tl.TL_stories;
+import org.telegram.ui.ActionBar.AlertDialog;
+import org.telegram.ui.ActionBar.BaseFragment;
+import org.telegram.ui.ActionBar.Theme;
+import org.telegram.ui.Components.AlertsCreator;
import org.telegram.ui.Components.BulletinFactory;
import org.telegram.ui.Components.Premium.boosts.BoostRepository;
+import org.telegram.ui.LaunchActivity;
import java.util.ArrayList;
import java.util.Arrays;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
public class ChannelBoostsController {
@@ -27,7 +34,6 @@ public class ChannelBoostsController {
connectionsManager = ConnectionsManager.getInstance(currentAccount);
}
-
public void getBoostsStats(long dialogId, Consumer consumer) {
TL_stories.TL_premium_getBoostsStatus req = new TL_stories.TL_premium_getBoostsStatus();
req.peer = messagesController.getInputPeer(dialogId);
@@ -35,7 +41,22 @@ public class ChannelBoostsController {
if (response != null) {
consumer.accept((TL_stories.TL_premium_boostsStatus) response);
} else {
- BulletinFactory.showForError(error);
+ BaseFragment fragment = LaunchActivity.getLastFragment();
+ if (error != null && fragment != null && "CHANNEL_PRIVATE".equals(error.text)) {
+ AlertDialog.Builder builder = new AlertDialog.Builder(fragment.getContext(), fragment.getResourceProvider());
+ builder.setTitle(LocaleController.getString(R.string.AppName));
+ Map colorsReplacement = new HashMap<>();
+ colorsReplacement.put("info1.**", Theme.getColor(Theme.key_dialogTopBackground));
+ colorsReplacement.put("info2.**", Theme.getColor(Theme.key_dialogTopBackground));
+ builder.setTopAnimation(R.raw.not_available, AlertsCreator.NEW_DENY_DIALOG_TOP_ICON_SIZE, false, Theme.getColor(Theme.key_dialogTopBackground), colorsReplacement);
+ builder.setTopAnimationIsNew(true);
+ builder.setTitle(LocaleController.getString(R.string.ChannelPrivate));
+ builder.setMessage(LocaleController.getString("ChannelCantOpenPrivate2", R.string.ChannelCantOpenPrivate2));
+ builder.setPositiveButton(LocaleController.getString(R.string.Close), null);
+ builder.show();
+ } else {
+ BulletinFactory.global().showForError(error);
+ }
consumer.accept(null);
}
}));
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
index d3891b270..1113b1c70 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ChatObject.java
@@ -1826,11 +1826,11 @@ public class ChatObject {
public static boolean canManageTopic(int currentAccount, TLRPC.Chat chat, TLRPC.TL_forumTopic topic) {
return canManageTopics(chat) || isMyTopic(currentAccount, topic);
}
- public static boolean canManageTopic(int currentAccount, TLRPC.Chat chat, int topicId) {
+ public static boolean canManageTopic(int currentAccount, TLRPC.Chat chat, long topicId) {
return canManageTopics(chat) || isMyTopic(currentAccount, chat, topicId);
}
- public static boolean canDeleteTopic(int currentAccount, TLRPC.Chat chat, int topicId) {
+ public static boolean canDeleteTopic(int currentAccount, TLRPC.Chat chat, long topicId) {
if (topicId == 1) {
// general topic can't be deleted
return false;
@@ -1849,11 +1849,11 @@ public class ChatObject {
return topic != null && (topic.my || topic.from_id instanceof TLRPC.TL_peerUser && topic.from_id.user_id == UserConfig.getInstance(currentAccount).clientUserId);
}
- public static boolean isMyTopic(int currentAccount, TLRPC.Chat chat, int topicId) {
+ public static boolean isMyTopic(int currentAccount, TLRPC.Chat chat, long topicId) {
return chat != null && chat.forum && isMyTopic(currentAccount, chat.id, topicId);
}
- public static boolean isMyTopic(int currentAccount, long chatId, int topicId) {
+ public static boolean isMyTopic(int currentAccount, long chatId, long topicId) {
return isMyTopic(currentAccount, MessagesController.getInstance(currentAccount).getTopicsController().findTopic(chatId, topicId));
}
diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
index e9be41659..2c6bfd3eb 100644
--- a/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
+++ b/TMessagesProj/src/main/java/org/telegram/messenger/ContactsController.java
@@ -93,6 +93,7 @@ public class ContactsController extends BaseController {
public final static int PRIVACY_RULES_TYPE_ADDED_BY_PHONE = 7;
public final static int PRIVACY_RULES_TYPE_VOICE_MESSAGES = 8;
public final static int PRIVACY_RULES_TYPE_BIO = 9;
+ public final static int PRIVACY_RULES_TYPE_MESSAGES = 10;
public final static int PRIVACY_RULES_TYPE_COUNT = 10;
@@ -221,6 +222,7 @@ public class ContactsController extends BaseController {
public ArrayList phoneBookContacts = new ArrayList<>();
public HashMap> phoneBookSectionsDict = new HashMap<>();
public ArrayList phoneBookSectionsArray = new ArrayList<>();
+ public HashMap phoneBookByShortPhones = new HashMap<>();
public ArrayList contacts = new ArrayList<>();
public ConcurrentHashMap contactsDict = new ConcurrentHashMap<>(20, 1.0f, 2);
@@ -306,6 +308,7 @@ public class ContactsController extends BaseController {
contactsByShortPhone.clear();
phoneBookSectionsDict.clear();
phoneBookSectionsArray.clear();
+ phoneBookByShortPhones.clear();
loadingContacts = false;
contactsSyncInProgress = false;
@@ -528,6 +531,7 @@ public class ContactsController extends BaseController {
sortedUsersSectionsArray.clear();
phoneBookSectionsDict.clear();
phoneBookSectionsArray.clear();
+ phoneBookByShortPhones.clear();
delayedContactsUpdate.clear();
sortedUsersMutualSectionsArray.clear();
contactsByPhone.clear();
@@ -1717,7 +1721,7 @@ public class ContactsController extends BaseController {
if (from != 1 && !isEmpty) {
saveContactsLoadTime();
} else {
- reloadContactsStatusesMaybe();
+ reloadContactsStatusesMaybe(false);
}
if (finalReloadContacts) {
loadContacts(false, 0);
@@ -1752,11 +1756,11 @@ public class ContactsController extends BaseController {
return contactsDict.get(userId) != null;
}
- public void reloadContactsStatusesMaybe() {
+ public void reloadContactsStatusesMaybe(boolean force) {
try {
SharedPreferences preferences = MessagesController.getMainSettings(currentAccount);
long lastReloadStatusTime = preferences.getLong("lastReloadStatusTime", 0);
- if (lastReloadStatusTime < System.currentTimeMillis() - 1000 * 60 * 60 * 3) {
+ if (lastReloadStatusTime < System.currentTimeMillis() - 1000 * 60 * 60 * 3 || force) {
reloadContactsStatuses();
}
} catch (Exception e) {
@@ -1774,29 +1778,35 @@ public class ContactsController extends BaseController {
}
private void mergePhonebookAndTelegramContacts(final HashMap> phoneBookSectionsDictFinal, final ArrayList phoneBookSectionsArrayFinal, final HashMap phoneBookByShortPhonesFinal) {
+ mergePhonebookAndTelegramContacts(phoneBookSectionsDictFinal, phoneBookSectionsArrayFinal,phoneBookByShortPhonesFinal, true);
+ }
+
+ private void mergePhonebookAndTelegramContacts(final HashMap> phoneBookSectionsDictFinal, final ArrayList phoneBookSectionsArrayFinal, final HashMap phoneBookByShortPhonesFinal, boolean needUpdateLists) {
final ArrayList contactsCopy = new ArrayList<>(contacts);
Utilities.globalQueue.postRunnable(() -> {
- for (int a = 0, size = contactsCopy.size(); a < size; a++) {
- TLRPC.TL_contact value = contactsCopy.get(a);
- TLRPC.User user = getMessagesController().getUser(value.user_id);
- if (user == null || TextUtils.isEmpty(user.phone)) {
- continue;
- }
- String phone = user.phone.substring(Math.max(0, user.phone.length() - 7));
- Contact contact = phoneBookByShortPhonesFinal.get(phone);
- if (contact != null) {
- if (contact.user == null) {
- contact.user = user;
+ if(needUpdateLists) {
+ for (int a = 0, size = contactsCopy.size(); a < size; a++) {
+ TLRPC.TL_contact value = contactsCopy.get(a);
+ TLRPC.User user = getMessagesController().getUser(value.user_id);
+ if (user == null || TextUtils.isEmpty(user.phone)) {
+ continue;
}
- } else {
- String key = Contact.getLetter(user.first_name, user.last_name);
- ArrayList