Update to 7.1.2 (2098)

This commit is contained in:
DrKLO 2020-10-03 00:48:16 +03:00
parent 99f5637dda
commit 75d0903666
32 changed files with 549 additions and 374 deletions

View File

@ -284,7 +284,7 @@ android {
}
}
defaultConfig.versionCode = 2096
defaultConfig.versionCode = 2098
applicationVariants.all { variant ->
variant.outputs.all { output ->
@ -319,7 +319,7 @@ android {
defaultConfig {
minSdkVersion 16
targetSdkVersion 28
versionName "7.1.1"
versionName "7.1.2"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View File

@ -18,7 +18,7 @@
#define USE_DEBUG_SESSION false
#define READ_BUFFER_SIZE 1024 * 128
#define DEBUG_VERSION
//#define DEBUG_VERSION
#define USE_OLD_KEYS
#define PFS_ENABLED 1
#define DEFAULT_DATACENTER_ID INT_MAX

View File

@ -328,7 +328,11 @@ public class AndroidUtilities {
SpannableStringBuilder spannableStringBuilder = SpannableStringBuilder.valueOf(str);
int i = s.indexOf(query);
while (i >= 0) {
spannableStringBuilder.setSpan(new ForegroundColorSpanThemable(Theme.key_windowBackgroundWhiteBlueText4), i, i + query.length(), 0);
try {
spannableStringBuilder.setSpan(new ForegroundColorSpanThemable(Theme.key_windowBackgroundWhiteBlueText4), i, i + query.length(), 0);
} catch (Exception e) {
FileLog.e(e);
}
i = s.indexOf(query, i + 1);
}
return spannableStringBuilder;

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 = 2096;
public static int BUILD_VERSION = 2098;
public static String BUILD_VERSION_STRING = "7.1.0";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View File

@ -3213,7 +3213,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener,
if (messageObject1 == null) {
return;
}
if (waveform != null) {
if (waveform != null && messageObject1.getDocument() != null) {
for (int a = 0; a < messageObject1.getDocument().attributes.size(); a++) {
TLRPC.DocumentAttribute attribute = messageObject1.getDocument().attributes.get(a);
if (attribute instanceof TLRPC.TL_documentAttributeAudio) {

View File

@ -2179,60 +2179,75 @@ public class MediaDataController extends BaseController {
final int currentReqId = ++lastReqId;
lastSearchQuery = query;
final long queryWithDialogFinal = queryWithDialog;
reqId = getConnectionsManager().sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
if (currentReqId == lastReqId) {
reqId = 0;
if (!jumpToMessage) {
loadingMoreSearchMessages = false;
}
if (response != null) {
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
for (int a = 0; a < res.messages.size(); a++) {
TLRPC.Message message = res.messages.get(a);
if (message instanceof TLRPC.TL_messageEmpty || message.action instanceof TLRPC.TL_messageActionHistoryClear) {
res.messages.remove(a);
a--;
}
}
getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true);
getMessagesController().putUsers(res.users, false);
getMessagesController().putChats(res.chats, false);
if (req.offset_id == 0 && queryWithDialogFinal == dialogId) {
lastReturnedNum = 0;
searchResultMessages.clear();
searchResultMessagesMap[0].clear();
searchResultMessagesMap[1].clear();
messagesSearchCount[0] = 0;
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsLoading, guid);
}
boolean added = false;
int N = Math.min(res.messages.size(), 20);
for (int a = 0; a < N; a++) {
TLRPC.Message message = res.messages.get(a);
added = true;
MessageObject messageObject = new MessageObject(currentAccount, message, false, false);
searchResultMessages.add(messageObject);
searchResultMessagesMap[queryWithDialogFinal == dialogId ? 0 : 1].put(messageObject.getId(), messageObject);
}
messagesSearchEndReached[queryWithDialogFinal == dialogId ? 0 : 1] = res.messages.size() < 21;
messagesSearchCount[queryWithDialogFinal == dialogId ? 0 : 1] = res instanceof TLRPC.TL_messages_messagesSlice || res instanceof TLRPC.TL_messages_channelMessages ? res.count : res.messages.size();
if (searchResultMessages.isEmpty()) {
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsAvailable, guid, 0, getMask(), (long) 0, 0, 0, jumpToMessage);
} else {
if (added) {
if (lastReturnedNum >= searchResultMessages.size()) {
lastReturnedNum = searchResultMessages.size() - 1;
}
MessageObject messageObject = searchResultMessages.get(lastReturnedNum);
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsAvailable, guid, messageObject.getId(), getMask(), messageObject.getDialogId(), lastReturnedNum, messagesSearchCount[0] + messagesSearchCount[1], jumpToMessage);
}
}
if (queryWithDialogFinal == dialogId && messagesSearchEndReached[0] && mergeDialogId != 0 && !messagesSearchEndReached[1]) {
searchMessagesInChat(lastSearchQuery, dialogId, mergeDialogId, guid, 0, replyMessageId, true, user, jumpToMessage);
}
String finalQuery = query;
reqId = getConnectionsManager().sendRequest(req, (response, error) -> {
ArrayList<MessageObject> messageObjects = new ArrayList<>();
if (error == null) {
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
int N = Math.min(res.messages.size(), 20);
for (int a = 0; a < N; a++) {
TLRPC.Message message = res.messages.get(a);
MessageObject messageObject = new MessageObject(currentAccount, message, false, false);
messageObject.setQuery(finalQuery);
messageObjects.add(messageObject);
}
}
}), ConnectionsManager.RequestFlagFailOnServerErrors);
AndroidUtilities.runOnUIThread(() -> {
if (currentReqId == lastReqId) {
reqId = 0;
if (!jumpToMessage) {
loadingMoreSearchMessages = false;
}
if (response != null) {
TLRPC.messages_Messages res = (TLRPC.messages_Messages) response;
for (int a = 0; a < res.messages.size(); a++) {
TLRPC.Message message = res.messages.get(a);
if (message instanceof TLRPC.TL_messageEmpty || message.action instanceof TLRPC.TL_messageActionHistoryClear) {
res.messages.remove(a);
a--;
}
}
getMessagesStorage().putUsersAndChats(res.users, res.chats, true, true);
getMessagesController().putUsers(res.users, false);
getMessagesController().putChats(res.chats, false);
if (req.offset_id == 0 && queryWithDialogFinal == dialogId) {
lastReturnedNum = 0;
searchResultMessages.clear();
searchResultMessagesMap[0].clear();
searchResultMessagesMap[1].clear();
messagesSearchCount[0] = 0;
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsLoading, guid);
}
boolean added = false;
int N = Math.min(res.messages.size(), 20);
for (int a = 0; a < N; a++) {
TLRPC.Message message = res.messages.get(a);
added = true;
MessageObject messageObject = messageObjects.get(a);
searchResultMessages.add(messageObject);
searchResultMessagesMap[queryWithDialogFinal == dialogId ? 0 : 1].put(messageObject.getId(), messageObject);
}
messagesSearchEndReached[queryWithDialogFinal == dialogId ? 0 : 1] = res.messages.size() < 21;
messagesSearchCount[queryWithDialogFinal == dialogId ? 0 : 1] = res instanceof TLRPC.TL_messages_messagesSlice || res instanceof TLRPC.TL_messages_channelMessages ? res.count : res.messages.size();
if (searchResultMessages.isEmpty()) {
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsAvailable, guid, 0, getMask(), (long) 0, 0, 0, jumpToMessage);
} else {
if (added) {
if (lastReturnedNum >= searchResultMessages.size()) {
lastReturnedNum = searchResultMessages.size() - 1;
}
MessageObject messageObject = searchResultMessages.get(lastReturnedNum);
getNotificationCenter().postNotificationName(NotificationCenter.chatSearchResultsAvailable, guid, messageObject.getId(), getMask(), messageObject.getDialogId(), lastReturnedNum, messagesSearchCount[0] + messagesSearchCount[1], jumpToMessage);
}
}
if (queryWithDialogFinal == dialogId && messagesSearchEndReached[0] && mergeDialogId != 0 && !messagesSearchEndReached[1]) {
searchMessagesInChat(lastSearchQuery, dialogId, mergeDialogId, guid, 0, replyMessageId, true, user, jumpToMessage);
}
}
}
});
}, ConnectionsManager.RequestFlagFailOnServerErrors);
}
public String getLastSearchQuery() {

View File

@ -5560,7 +5560,7 @@ public class MessagesController extends BaseController implements NotificationCe
boolean isMegagroup = false;
if (messagesRes instanceof TLRPC.TL_messages_channelMessages) {
int channelId = -(int) dialogId;
if (!scheduled) {
if (!scheduled && threadMessageId == 0) {
int channelPts = channelsPts.get(channelId);
if (channelPts == 0) {
channelPts = getMessagesStorage().getChannelPtsSync(channelId);

View File

@ -7569,6 +7569,9 @@ public class MessagesStorage extends BaseController {
}
replies = currentReplies;
}
if (currentReplies != null && currentReplies.read_max_id > replies.read_max_id) {
replies.read_max_id = currentReplies.read_max_id;
}
state.requery();
NativeByteBuffer data = new NativeByteBuffer(replies.getObjectSize());
replies.serializeToStream(data);

View File

@ -608,206 +608,43 @@ public class NotificationsController extends BaseController {
}
public void processEditedMessages(final LongSparseArray<ArrayList<MessageObject>> editedMessages) {
/*if (editedMessages.size() == 0) {
if (editedMessages.size() == 0) {
return;
}
final ArrayList<MessageObject> popupArrayAdd = new ArrayList<>(0);
notificationsQueue.postRunnable(() -> {
boolean added = false;
boolean edited = false;
LongSparseArray<Boolean> settingsCache = new LongSparseArray<>();
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
boolean allowPinned = preferences.getBoolean("PinnedMessages", true);
int popup = 0;
boolean hasScheduled = false;
for (int a = 0; a < messageObjects.size(); a++) {
MessageObject messageObject = messageObjects.get(a);
if (messageObject.messageOwner != null && messageObject.messageOwner.silent && (messageObject.messageOwner.action instanceof TLRPC.TL_messageActionContactSignUp || messageObject.messageOwner.action instanceof TLRPC.TL_messageActionUserJoined)) {
boolean updated = false;
for (int a = 0, N = editedMessages.size(); a < N; a++) {
long did = editedMessages.keyAt(a);
if (pushDialogs.indexOfKey(did) < 0) {
continue;
}
long mid = messageObject.getId();
long random_id = messageObject.isFcmMessage() ? messageObject.messageOwner.random_id : 0;
long dialog_id = messageObject.getDialogId();
int lower_id = (int) dialog_id;
boolean isChannel;
if (messageObject.isFcmMessage()) {
isChannel = messageObject.localChannel;
} else if (lower_id < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lower_id);
isChannel = ChatObject.isChannel(chat) && !chat.megagroup;
} else {
isChannel = false;
}
if (messageObject.messageOwner.to_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.to_id.channel_id) << 32;
}
MessageObject oldMessageObject = pushMessagesDict.get(mid);
if (oldMessageObject == null && messageObject.messageOwner.random_id != 0) {
oldMessageObject = fcmRandomMessagesDict.get(messageObject.messageOwner.random_id);
if (oldMessageObject != null) {
fcmRandomMessagesDict.remove(messageObject.messageOwner.random_id);
ArrayList<MessageObject> messages = editedMessages.valueAt(a);
for (int b = 0, N2 = messages.size(); b < N2; b++) {
MessageObject messageObject = messages.get(b);
long mid = messageObject.getId();
if (messageObject.messageOwner.peer_id.channel_id != 0) {
mid |= ((long) messageObject.messageOwner.peer_id.channel_id) << 32;
}
}
if (oldMessageObject != null) {
if (oldMessageObject.isFcmMessage()) {
MessageObject oldMessage = pushMessagesDict.get(mid);
if (oldMessage != null) {
updated = true;
pushMessagesDict.put(mid, messageObject);
int idxOld = pushMessages.indexOf(oldMessageObject);
if (idxOld >= 0) {
pushMessages.set(idxOld, messageObject);
popup = addToPopupMessages(popupArrayAdd, messageObject, lower_id, dialog_id, isChannel, preferences);
int idx = pushMessages.indexOf(oldMessage);
if (idx >= 0) {
pushMessages.set(idx, messageObject);
}
if (isFcm && (edited = messageObject.localEdit)) {
getMessagesStorage().putPushMessage(messageObject);
idx = delayedPushMessages.indexOf(oldMessage);
if (idx >= 0) {
delayedPushMessages.set(idx, messageObject);
}
}
continue;
}
if (edited) {
continue;
}
if (isFcm) {
getMessagesStorage().putPushMessage(messageObject);
}
long original_dialog_id = dialog_id;
if (dialog_id == opened_dialog_id && ApplicationLoader.isScreenOn) {
if (!isFcm) {
playInChatSound();
}
continue;
}
if (messageObject.messageOwner.mentioned) {
if (!allowPinned && messageObject.messageOwner.action instanceof TLRPC.TL_messageActionPinMessage) {
continue;
}
dialog_id = messageObject.messageOwner.from_id;
}
if (isPersonalMessage(messageObject)) {
personal_count++;
}
added = true;
boolean isChat = lower_id < 0;
int index = settingsCache.indexOfKey(dialog_id);
boolean value;
if (index >= 0) {
value = settingsCache.valueAt(index);
} else {
int notifyOverride = getNotifyOverride(preferences, dialog_id);
if (notifyOverride == -1) {
value = isGlobalNotificationsEnabled(dialog_id, isChannel);
} else {
value = notifyOverride != 2;
}
settingsCache.put(dialog_id, value);
}
if (value) {
if (!isFcm) {
popup = addToPopupMessages(popupArrayAdd, messageObject, lower_id, dialog_id, isChannel, preferences);
}
if (!hasScheduled) {
hasScheduled = messageObject.messageOwner.from_scheduled;
}
delayedPushMessages.add(messageObject);
pushMessages.add(0, messageObject);
if (mid != 0) {
pushMessagesDict.put(mid, messageObject);
} else if (random_id != 0) {
fcmRandomMessagesDict.put(random_id, messageObject);
}
if (original_dialog_id != dialog_id) {
Integer current = pushDialogsOverrideMention.get(original_dialog_id);
pushDialogsOverrideMention.put(original_dialog_id, current == null ? 1 : current + 1);
}
}
}
if (added) {
notifyCheck = isLast;
if (updated) {
showOrUpdateNotification(false);
}
if (!popupArrayAdd.isEmpty() && !AndroidUtilities.needShowPasscode() && !SharedConfig.isWaitingForPasscodeEnter) {
final int popupFinal = popup;
AndroidUtilities.runOnUIThread(() -> {
popupMessages.addAll(0, popupArrayAdd);
if (ApplicationLoader.mainInterfacePaused || !ApplicationLoader.isScreenOn) {
if (popupFinal == 3 || popupFinal == 1 && ApplicationLoader.isScreenOn || popupFinal == 2 && !ApplicationLoader.isScreenOn) {
Intent popupIntent = new Intent(ApplicationLoader.applicationContext, PopupNotificationActivity.class);
popupIntent.setFlags(Intent.FLAG_ACTIVITY_NEW_TASK | Intent.FLAG_ACTIVITY_NO_ANIMATION | Intent.FLAG_ACTIVITY_NO_USER_ACTION | Intent.FLAG_FROM_BACKGROUND);
try {
ApplicationLoader.applicationContext.startActivity(popupIntent);
} catch (Throwable ignore) {
}
}
}
});
}
if (isFcm || hasScheduled) {
if (edited) {
delayedPushMessages.clear();
showOrUpdateNotification(notifyCheck);
} else if (added) {
MessageObject messageObject = messageObjects.get(0);
long dialog_id = messageObject.getDialogId();
Boolean isChannel;
if (messageObject.isFcmMessage()) {
isChannel = messageObject.localChannel;
} else {
isChannel = null;
}
int old_unread_count = total_unread_count;
int notifyOverride = getNotifyOverride(preferences, dialog_id);
boolean canAddValue;
if (notifyOverride == -1) {
canAddValue = isGlobalNotificationsEnabled(dialog_id, isChannel);
} else {
canAddValue = notifyOverride != 2;
}
Integer currentCount = pushDialogs.get(dialog_id);
int newCount = currentCount != null ? currentCount + 1 : 1;
if (notifyCheck && !canAddValue) {
Integer override = pushDialogsOverrideMention.get(dialog_id);
if (override != null && override != 0) {
canAddValue = true;
newCount = override;
}
}
if (canAddValue) {
if (currentCount != null) {
total_unread_count -= currentCount;
}
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
}
if (old_unread_count != total_unread_count) {
delayedPushMessages.clear();
showOrUpdateNotification(notifyCheck);
final int pushDialogsCount = pushDialogs.size();
AndroidUtilities.runOnUIThread(() -> {
NotificationCenter.getGlobalInstance().postNotificationName(NotificationCenter.notificationsCountUpdated, currentAccount);
getNotificationCenter().postNotificationName(NotificationCenter.dialogsUnreadCounterChanged, pushDialogsCount);
});
}
notifyCheck = false;
if (showBadgeNumber) {
setBadge(getTotalAllUnreadCount());
}
}
}
if (countDownLatch != null) {
countDownLatch.countDown();
}
});*/
});
}
public void processNewMessages(final ArrayList<MessageObject> messageObjects, final boolean isLast, final boolean isFcm, CountDownLatch countDownLatch) {
@ -1032,20 +869,28 @@ public class NotificationsController extends BaseController {
int old_unread_count = total_unread_count;
SharedPreferences preferences = getAccountInstance().getNotificationsSettings();
for (int b = 0; b < dialogsToUpdate.size(); b++) {
long dialog_id = dialogsToUpdate.keyAt(b);
long dialogId = dialogsToUpdate.keyAt(b);
Integer currentCount = pushDialogs.get(dialogId);
Integer newCount = dialogsToUpdate.get(dialogId);
int notifyOverride = getNotifyOverride(preferences, dialog_id);
int lowerId = (int) dialogId;
if (lowerId < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lowerId);
if (chat == null || chat.min || ChatObject.isNotInChat(chat)) {
newCount = 0;
}
}
int notifyOverride = getNotifyOverride(preferences, dialogId);
boolean canAddValue;
if (notifyOverride == -1) {
canAddValue = isGlobalNotificationsEnabled(dialog_id);
canAddValue = isGlobalNotificationsEnabled(dialogId);
} else {
canAddValue = notifyOverride != 2;
}
Integer currentCount = pushDialogs.get(dialog_id);
Integer newCount = dialogsToUpdate.get(dialog_id);
if (notifyCheck && !canAddValue) {
Integer override = pushDialogsOverrideMention.get(dialog_id);
Integer override = pushDialogsOverrideMention.get(dialogId);
if (override != null && override != 0) {
canAddValue = true;
newCount = override;
@ -1053,7 +898,7 @@ public class NotificationsController extends BaseController {
}
if (newCount == 0) {
smartNotificationsDialogs.remove(dialog_id);
smartNotificationsDialogs.remove(dialogId);
}
if (newCount < 0) {
@ -1068,11 +913,11 @@ public class NotificationsController extends BaseController {
}
}
if (newCount == 0) {
pushDialogs.remove(dialog_id);
pushDialogsOverrideMention.remove(dialog_id);
pushDialogs.remove(dialogId);
pushDialogsOverrideMention.remove(dialogId);
for (int a = 0; a < pushMessages.size(); a++) {
MessageObject messageObject = pushMessages.get(a);
if (!messageObject.messageOwner.from_scheduled && messageObject.getDialogId() == dialog_id) {
if (!messageObject.messageOwner.from_scheduled && messageObject.getDialogId() == dialogId) {
if (isPersonalMessage(messageObject)) {
personal_count--;
}
@ -1089,7 +934,7 @@ public class NotificationsController extends BaseController {
}
} else if (canAddValue) {
total_unread_count += newCount;
pushDialogs.put(dialog_id, newCount);
pushDialogs.put(dialogId, newCount);
}
}
if (!popupArrayToRemove.isEmpty()) {
@ -1297,6 +1142,13 @@ public class NotificationsController extends BaseController {
try {
for (int i = 0, N = MessagesController.getInstance(a).allDialogs.size(); i < N; i++) {
TLRPC.Dialog dialog = MessagesController.getInstance(a).allDialogs.get(i);
int lowerId = (int) dialog.id;
if (lowerId < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lowerId);
if (ChatObject.isNotInChat(chat)) {
continue;
}
}
if (dialog.unread_count != 0) {
count += dialog.unread_count;
}
@ -1312,6 +1164,13 @@ public class NotificationsController extends BaseController {
try {
for (int i = 0, N = MessagesController.getInstance(a).allDialogs.size(); i < N; i++) {
TLRPC.Dialog dialog = MessagesController.getInstance(a).allDialogs.get(i);
int lowerId = (int) dialog.id;
if (lowerId < 0) {
TLRPC.Chat chat = getMessagesController().getChat(-lowerId);
if (ChatObject.isNotInChat(chat)) {
continue;
}
}
if (dialog.unread_count != 0) {
count++;
}

View File

@ -43253,7 +43253,6 @@ public class TLRPC {
public int views;
public int forwards;
public TL_messageReplies replies;
public ArrayList<Integer> recent_repliers = new ArrayList<>();
public int edit_date;
public boolean silent;
public boolean post;

View File

@ -276,6 +276,7 @@ public class ActionBarLayout extends FrameLayout {
protected Activity parentActivity;
public ArrayList<BaseFragment> fragmentsStack;
private Rect rect = new Rect();
public ActionBarLayout(Context context) {
super(context);
@ -636,7 +637,7 @@ public class ActionBarLayout extends FrameLayout {
velocityTracker.addMovement(ev);
if (!transitionAnimationInProgress && !inPreviewMode && maybeStartTracking && !startedTracking && dx >= AndroidUtilities.getPixelsInCM(0.4f, true) && Math.abs(dx) / 3 > dy) {
BaseFragment currentFragment = fragmentsStack.get(fragmentsStack.size() - 1);
if (currentFragment.canBeginSlide()) {
if (currentFragment.canBeginSlide() && findScrollingChild(this, ev.getX(), ev.getY()) == null) {
prepareForMoving(ev);
} else {
maybeStartTracking = false;
@ -1832,4 +1833,26 @@ public class ActionBarLayout extends FrameLayout {
containerView.setFragmentPanTranslationOffset(offset);
}
}
private View findScrollingChild(ViewGroup parent, float x, float y) {
int n = parent.getChildCount();
for (int i = 0; i < n; i++) {
View child = parent.getChildAt(i);
if (child.getVisibility() != View.VISIBLE) {
continue;
}
child.getHitRect(rect);
if (rect.contains((int) x, (int) y)) {
if (child.canScrollHorizontally(-1)) {
return child;
} else if (child instanceof ViewGroup) {
View v = findScrollingChild((ViewGroup) child, x - rect.left, y - rect.top);
if (v != null) {
return v;
}
}
}
}
return null;
}
}

View File

@ -604,7 +604,9 @@ public class ActionBarMenuItem extends FrameLayout {
if (!currentSearchFilters.isEmpty()) {
if (listener != null) {
for (int i = 0; i < currentSearchFilters.size(); i++) {
listener.onSearchFilterCleared(currentSearchFilters.get(i));
if ( currentSearchFilters.get(i).removable) {
listener.onSearchFilterCleared(currentSearchFilters.get(i));
}
}
}
clearSearchFilters();
@ -636,6 +638,9 @@ public class ActionBarMenuItem extends FrameLayout {
}
public void removeSearchFilter(FiltersView.MediaFilterData filter) {
if (!filter.removable) {
return;
}
currentSearchFilters.remove(filter);
if (selectedFilterIndex < 0 || selectedFilterIndex > currentSearchFilters.size() - 1) {
selectedFilterIndex = currentSearchFilters.size() - 1;
@ -650,7 +655,12 @@ public class ActionBarMenuItem extends FrameLayout {
}
public void clearSearchFilters() {
currentSearchFilters.clear();
for (int i = 0; i < currentSearchFilters.size(); i++) {
if (currentSearchFilters.get(i).removable) {
currentSearchFilters.remove(i);
i--;
}
}
onFiltersChanged();
}
@ -739,16 +749,19 @@ public class ActionBarMenuItem extends FrameLayout {
if (selectedFilterIndex != index) {
selectedFilterIndex = index;
onFiltersChanged();
} else if (!searchFilterView.selectedForDelete) {
searchFilterView.setSelectedForDelete(true);
} else {
FiltersView.MediaFilterData filterToRemove = searchFilterView.getFilter();
removeSearchFilter(filterToRemove);
if (listener != null) {
listener.onSearchFilterCleared(filterToRemove);
listener.onTextChanged(searchField);
return;
}
if (searchFilterView.getFilter().removable) {
if (!searchFilterView.selectedForDelete) {
searchFilterView.setSelectedForDelete(true);
} else {
FiltersView.MediaFilterData filterToRemove = searchFilterView.getFilter();
removeSearchFilter(filterToRemove);
if (listener != null) {
listener.onSearchFilterCleared(filterToRemove);
listener.onTextChanged(searchField);
}
}
}
});
searchFilterLayout.addView(searchFilterView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.MATCH_PARENT, 0, 0, 0, 6, 0));
@ -1013,8 +1026,8 @@ public class ActionBarMenuItem extends FrameLayout {
@Override
public boolean onKeyDown(int keyCode, KeyEvent event) {
if (keyCode == KeyEvent.KEYCODE_DEL && searchField.length() == 0 && ((searchFieldCaption.getVisibility() == VISIBLE && searchFieldCaption.length() > 0) || !currentSearchFilters.isEmpty())) {
if (!currentSearchFilters.isEmpty()) {
if (keyCode == KeyEvent.KEYCODE_DEL && searchField.length() == 0 && ((searchFieldCaption.getVisibility() == VISIBLE && searchFieldCaption.length() > 0) || hasRemovableFilters())) {
if (hasRemovableFilters()) {
FiltersView.MediaFilterData filterToRemove = currentSearchFilters.get(currentSearchFilters.size() - 1);
if (listener != null) {
listener.onSearchFilterCleared(filterToRemove);
@ -1143,10 +1156,10 @@ public class ActionBarMenuItem extends FrameLayout {
clearButton.setOnClickListener(v -> {
if (searchField.length() != 0) {
searchField.setText("");
} else if (!currentSearchFilters.isEmpty()) {
} else if (hasRemovableFilters()) {
searchField.hideActionMode();
for (int i = 0; i < currentSearchFilters.size(); i++) {
if (listener != null) {
if (listener != null && currentSearchFilters.get(i).removable) {
listener.onSearchFilterCleared(currentSearchFilters.get(i));
}
}
@ -1173,7 +1186,7 @@ public class ActionBarMenuItem extends FrameLayout {
private void checkClearButton() {
if (clearButton != null) {
if (currentSearchFilters.isEmpty() && TextUtils.isEmpty(searchField.getText()) &&
if (!hasRemovableFilters() && TextUtils.isEmpty(searchField.getText()) &&
(listener == null || !listener.forceShowClear()) &&
(searchFieldCaption == null || searchFieldCaption.getVisibility() != VISIBLE)) {
if (clearButton.getTag() != null) {
@ -1209,6 +1222,18 @@ public class ActionBarMenuItem extends FrameLayout {
}
}
private boolean hasRemovableFilters() {
if (currentSearchFilters.isEmpty()) {
return false;
}
for (int i = 0; i < currentSearchFilters.size(); i++) {
if (currentSearchFilters.get(i).removable) {
return true;
}
}
return false;
}
public void setShowSearchProgress(boolean show) {
if (progressDrawable == null) {
return;
@ -1417,6 +1442,11 @@ public class ActionBarMenuItem extends FrameLayout {
}
}
public void collapseSearchFilters() {
selectedFilterIndex = -1;
onFiltersChanged();
}
private static class SearchFilterView extends FrameLayout {
Drawable thumbDrawable;
@ -1474,6 +1504,10 @@ public class ActionBarMenuItem extends FrameLayout {
Theme.setCombinedDrawableColor(thumbDrawable, Theme.getColor(Theme.key_avatar_actionBarIconBlue), true);
}
avatarImageView.setAlpha(1f - selectedProgress);
if (data != null && (data.filterType == FiltersView.FILTER_TYPE_ARCHIVE)) {
setData(data);
}
invalidate();
}
@ -1501,6 +1535,12 @@ public class ActionBarMenuItem extends FrameLayout {
avatarImageView.getImageReceiver().setRoundRadius(AndroidUtilities.dp(16));
avatarImageView.getImageReceiver().setImage(ImageLocation.getForChat(chat, false), "50_50",thumbDrawable, null, chat, 0);
}
} else if (data.filterType == FiltersView.FILTER_TYPE_ARCHIVE) {
CombinedDrawable combinedDrawable = Theme.createCircleDrawableWithIcon(AndroidUtilities.dp(32), R.drawable.chats_archive);
combinedDrawable.setIconSize(AndroidUtilities.dp(16), AndroidUtilities.dp(16));
Theme.setCombinedDrawableColor(combinedDrawable, Theme.getColor(Theme.key_avatar_backgroundArchived), false);
Theme.setCombinedDrawableColor(combinedDrawable, Theme.getColor(Theme.key_avatar_actionBarIconBlue), true);
avatarImageView.setImageDrawable(combinedDrawable);
} else {
avatarImageView.setImageDrawable(thumbDrawable);
}

View File

@ -15,6 +15,7 @@ import android.widget.FrameLayout;
import com.google.android.exoplayer2.util.Log;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.SharedConfig;
import org.telegram.messenger.UserConfig;
@ -65,7 +66,7 @@ public class AdjustPanLayoutHelper {
return true;
}
if (!heightAnimationEnabled()) {
if (!heightAnimationEnabled() || Math.abs(previousHeight - contentHeight) < AndroidUtilities.dp(20)) {
previousHeight = contentHeight;
previousContentHeight = contentView.getHeight();
previousStartOffset = startOffset();

View File

@ -63,6 +63,7 @@ public class FiltersView extends RecyclerListView {
public final static int FILTER_TYPE_CHAT = 4;
public final static int FILTER_TYPE_VOICE = 5;
public final static int FILTER_TYPE_DATE = 6;
public final static int FILTER_TYPE_ARCHIVE = 7;
public final static MediaFilterData[] filters = new MediaFilterData[]{
new MediaFilterData(R.drawable.search_media, R.drawable.search_media_filled, LocaleController.getString("SharedMediaTab2", R.string.SharedMediaTab2), new TLRPC.TL_inputMessagesFilterPhotoVideo(), FILTER_TYPE_MEDIA),
@ -260,9 +261,8 @@ public class FiltersView extends RecyclerListView {
private final static Pattern monthYearOrDayPatter = Pattern.compile("(\\w{3,}) ([0-9]{0,4})");
private final static Pattern yearOrDayAndMonthPatter = Pattern.compile("([0-9]{0,4}) (\\w{2,})");
private final static Pattern shortDate = Pattern.compile("^([0-9]{1,4})(\\.| |\\\\)([0-9]{1,4})$");
private final static Pattern longDate = Pattern.compile("^([0-9]{1,2})(\\.| |\\\\)([0-9]{1,2})(\\.| |\\\\)([0-9]{1,4})$");
private final static Pattern shortDate = Pattern.compile("^([0-9]{1,4})(\\.| |/|\\-)([0-9]{1,4})$");
private final static Pattern longDate = Pattern.compile("^([0-9]{1,2})(\\.| |/|\\-)([0-9]{1,2})(\\.| |/|\\-)([0-9]{1,4})$");
private final static int[] numberOfDaysEachMonth = new int[]{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
@ -356,6 +356,9 @@ public class FiltersView extends RecyclerListView {
int day = Integer.parseInt(g1);
int month = Integer.parseInt(g2) - 1;
int year = Integer.parseInt(g3);
if (year >= 10 && year <= 99) {
year += 2000;
}
int currentYear = Calendar.getInstance().get(Calendar.YEAR);
if (validDateForMont(day - 1, month) && year >= minYear && year <= currentYear) {
Calendar calendar = Calendar.getInstance();
@ -751,6 +754,7 @@ public class FiltersView extends RecyclerListView {
public final TLRPC.MessagesFilter filter;
public TLObject chat;
public DateData dateData;
public boolean removable = true;
public MediaFilterData(int iconRes, int iconResFilled, String title, TLRPC.MessagesFilter filter, int filterType) {
this.iconRes = iconRes;

View File

@ -653,9 +653,11 @@ public class ArticleViewer implements NotificationCenter.NotificationCenterDeleg
WindowInsets oldInsets = (WindowInsets) lastInsets;
lastInsets = insets;
if (oldInsets == null || !oldInsets.toString().equals(insets.toString())) {
windowView.requestLayout();
if (windowView != null) {
windowView.requestLayout();
}
}
if (Build.VERSION.SDK_INT >= 28) {
if (Build.VERSION.SDK_INT >= 28 && parentActivity != null) {
DisplayCutout cutout = parentActivity.getWindow().getDecorView().getRootWindowInsets().getDisplayCutout();
if (cutout != null) {
List<Rect> rects = cutout.getBoundingRects();

View File

@ -2550,6 +2550,27 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
return false;
}
private int getRepliesCount() {
if (currentMessagesGroup != null && !currentMessagesGroup.messages.isEmpty()) {
MessageObject messageObject = currentMessagesGroup.messages.get(0);
return messageObject.getRepliesCount();
}
return currentMessageObject.getRepliesCount();
}
private ArrayList<TLRPC.Peer> getRecentRepliers() {
if (currentMessagesGroup != null && !currentMessagesGroup.messages.isEmpty()) {
MessageObject messageObject = currentMessagesGroup.messages.get(0);
if (messageObject.messageOwner.replies != null) {
return messageObject.messageOwner.replies.recent_repliers;
}
}
if (currentMessageObject.messageOwner.replies != null) {
return currentMessageObject.messageOwner.replies.recent_repliers;
}
return null;
}
private boolean isUserDataChanged() {
if (currentMessageObject != null && (!hasLinkPreview && currentMessageObject.messageOwner.media != null && currentMessageObject.messageOwner.media.webpage instanceof TLRPC.TL_webPage)) {
return true;
@ -2566,7 +2587,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
if (lastViewsCount != currentMessageObject.messageOwner.views) {
return true;
}
if (lastRepliesCount != currentMessageObject.getRepliesCount()) {
if (lastRepliesCount != getRepliesCount()) {
return true;
}
if (lastReactions != currentMessageObject.messageOwner.reactions) {
@ -2848,7 +2869,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
lastSendState = messageObject.messageOwner.send_state;
lastDeleteDate = messageObject.messageOwner.destroyTime;
lastViewsCount = messageObject.messageOwner.views;
lastRepliesCount = messageObject.getRepliesCount();
lastRepliesCount = getRepliesCount();
isPressed = false;
gamePreviewPressed = false;
sideButtonPressed = false;
@ -3002,7 +3023,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
linked = messageObject.isLinkedToChat(linkedChatId);
}
if ((hasDiscussion && linked || isRepliesChat && !messageObject.isOutOwner()) && (currentPosition == null || (currentPosition.flags & MessageObject.POSITION_FLAG_BOTTOM) != 0)) {
int commentCount = messageObject.getRepliesCount();
int commentCount = getRepliesCount();
if (!messageObject.shouldDrawWithoutBackground() && !messageObject.isAnimatedEmoji()) {
drawCommentButton = true;
int avatarsOffset = 0;
@ -3014,13 +3035,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
comment = LocaleController.getString("ViewInChat", R.string.ViewInChat);
} else {
comment = commentCount == 0 ? LocaleController.getString("LeaveAComment", R.string.LeaveAComment) : LocaleController.formatPluralString("CommentsCount", commentCount);
if (commentCount != 0 && !messageObject.messageOwner.replies.recent_repliers.isEmpty()) {
ArrayList<TLRPC.Peer> recentRepliers = getRecentRepliers();
if (commentCount != 0 && recentRepliers != null && !recentRepliers.isEmpty()) {
createCommentUI();
int size = messageObject.messageOwner.replies.recent_repliers.size();
int size = recentRepliers.size();
for (int a = 0; a < commentAvatarImages.length; a++) {
if (a < size) {
commentAvatarImages[a].setImageCoords(0, 0, AndroidUtilities.dp(24), AndroidUtilities.dp(24));
int id = MessageObject.getPeerId(messageObject.messageOwner.replies.recent_repliers.get(a));
int id = MessageObject.getPeerId(recentRepliers.get(a));
TLRPC.User user = null;
TLRPC.Chat chat = null;
if (id > 0) {
@ -8676,7 +8698,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
timeWidth += viewsTextWidth + Theme.chat_msgInViewsDrawable.getIntrinsicWidth() + AndroidUtilities.dp(10);
}
if (hasLinkedChat && isChat && isMegagroup && !isThreadChat && messageObject.hasReplies()) {
currentRepliesString = String.format("%s", LocaleController.formatShortNumber(messageObject.getRepliesCount(), null));
currentRepliesString = String.format("%s", LocaleController.formatShortNumber(getRepliesCount(), null));
repliesTextWidth = (int) Math.ceil(Theme.chat_timePaint.measureText(currentRepliesString));
timeWidth += repliesTextWidth + Theme.chat_msgInRepliesDrawable.getIntrinsicWidth() + AndroidUtilities.dp(10);
} else {
@ -10314,7 +10336,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
private void drawCaptionLayout(Canvas canvas, StaticLayout captionLayout, boolean selectionOnly, float alpha) {
if (currentBackgroundDrawable != null && drawCommentButton) {
if (currentBackgroundDrawable != null && drawCommentButton && timeLayout != null) {
int x;
float y = layoutHeight - AndroidUtilities.dp(18) - timeLayout.getHeight();
if (mediaBackground) {
@ -12569,7 +12591,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
if (commentLayout != null) {
lastCommentsCount = currentMessageObject.getRepliesCount();
lastCommentsCount = getRepliesCount();
lastTotalCommentWidth = totalCommentWidth;
lastCommentLayout = commentLayout;
lastCommentArrowX = commentArrowX;
@ -12577,7 +12599,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
lastCommentDrawUnread = commentDrawUnread;
}
if (repliesLayout != null) {
lastRepliesCount = currentMessageObject.getRepliesCount();
lastRepliesCount = getRepliesCount();
lastRepliesLayout = repliesLayout;
}
@ -12646,13 +12668,13 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
}
}
if (repliesLayout != null && lastRepliesCount != currentMessageObject.getRepliesCount()) {
if (repliesLayout != null && lastRepliesCount != getRepliesCount()) {
animateRepliesLayout = lastRepliesLayout;
animateReplies = true;
changed = true;
}
if (commentLayout != null && lastCommentsCount != currentMessageObject.getRepliesCount()) {
if (commentLayout != null && lastCommentsCount != getRepliesCount()) {
animateCommentsLayout = lastCommentLayout;
animateTotalCommentWidth = lastTotalCommentWidth;
animateCommentArrowX = lastCommentArrowX;

View File

@ -950,7 +950,7 @@ public class DialogCell extends BaseCell {
} else if (message.messageOwner.message != null) {
String mess = message.messageOwner.message;
if (message.hasHighlightedWords()) {
mess = mess.replace('\n', ' ').trim();
mess = mess.replace('\n', ' ').replaceAll(" +", " ").trim();
int w = getMeasuredWidth() - AndroidUtilities.dp(72 + 23 + 10);
if (hasNameInMessage) {
if (!TextUtils.isEmpty(messageNameString)) {
@ -1016,8 +1016,8 @@ public class DialogCell extends BaseCell {
} else {
emoji = "\uD83D\uDCCE ";
}
if (message.hasHighlightedWords()) {
String str = message.messageOwner.message.replace('\n', ' ').trim();
if (message.hasHighlightedWords() && !TextUtils.isEmpty(message.messageOwner.message)) {
String str = message.messageOwner.message.replace('\n', ' ').replaceAll(" +", " ").trim();
int w = getMeasuredWidth() - AndroidUtilities.dp(72 + 23 + 24);
if (hasNameInMessage) {
if (!TextUtils.isEmpty(messageNameString)) {
@ -1041,22 +1041,22 @@ public class DialogCell extends BaseCell {
} else if (message.type == 14) {
messageString = String.format("\uD83C\uDFA7 %s - %s", message.getMusicAuthor(), message.getMusicTitle());
} else {
if (message.hasHighlightedWords()){
if (message.hasHighlightedWords() && !TextUtils.isEmpty(message.messageOwner.message)){
messageString = message.messageOwner.message.replace('\n', ' ').trim();
int w = getMeasuredWidth() - AndroidUtilities.dp(72 + 23 );
messageString = AndroidUtilities.ellipsizeCenterEnd(messageString, message.highlightedWords.get(0), w, currentMessagePaint).toString();
AndroidUtilities.highlightText(messageString, message.highlightedWords);
} else {
messageString = message.messageText;
}
AndroidUtilities.highlightText(messageString, message.highlightedWords);
}
if (message.messageOwner.media != null && !message.isMediaEmpty()) {
currentMessagePaint = Theme.dialogs_messagePrintingPaint[paintIndex];
}
}
if (hasMessageThumb) {
if (message.hasHighlightedWords()) {
messageString = message.messageOwner.message.replace('\n', ' ').trim();
if (message.hasHighlightedWords() && !TextUtils.isEmpty(message.messageOwner.message)) {
messageString = message.messageOwner.message.replace('\n', ' ').replaceAll(" +", " ").trim();
int w = getMeasuredWidth() - AndroidUtilities.dp(72 + 23 + thumbSize + 6);
messageString = AndroidUtilities.ellipsizeCenterEnd(messageString, message.highlightedWords.get(0), w, currentMessagePaint).toString();
} else {

View File

@ -172,7 +172,7 @@ public class SharedAudioCell extends FrameLayout implements DownloadController.F
}
if (currentMessageObject.hasHighlightedWords()) {
CharSequence caption = Emoji.replaceEmoji(currentMessageObject.messageOwner.message.replace("\n", " ").trim(), Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
CharSequence caption = Emoji.replaceEmoji(currentMessageObject.messageOwner.message.replace("\n", " ").replaceAll(" +", " ").trim(), Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
CharSequence sequence = AndroidUtilities.highlightText(caption, currentMessageObject.highlightedWords);
if (sequence != null) {
sequence = TextUtils.ellipsize(AndroidUtilities.ellipsizeCenterEnd(sequence, currentMessageObject.highlightedWords.get(0), maxWidth, captionTextPaint), captionTextPaint, maxWidth, TextUtils.TruncateAt.END);

View File

@ -435,7 +435,7 @@ public class SharedDocumentCell extends FrameLayout implements DownloadControlle
}
if (messageObject.hasHighlightedWords() && !TextUtils.isEmpty(message.messageOwner.message)) {
String str = message.messageOwner.message.replace("\n", " ").trim();
String str = message.messageOwner.message.replace("\n", " ").replaceAll(" +", " ").trim();
caption = AndroidUtilities.highlightText(str, message.highlightedWords);
if (captionTextView != null) {
captionTextView.setVisibility(caption == null ? View.GONE : View.VISIBLE);

View File

@ -349,7 +349,7 @@ public class SharedLinkCell extends FrameLayout {
}
if (message != null && !TextUtils.isEmpty(message.messageOwner.message)) {
CharSequence caption = Emoji.replaceEmoji(message.messageOwner.message.replace("\n", " ").trim(), Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
CharSequence caption = Emoji.replaceEmoji(message.messageOwner.message.replace("\n", " ").replaceAll(" +", " ").trim(), Theme.chat_msgTextPaint.getFontMetricsInt(), AndroidUtilities.dp(20), false);
CharSequence sequence = AndroidUtilities.highlightText(caption, message.highlightedWords);
if (sequence != null) {
sequence = TextUtils.ellipsize(AndroidUtilities.ellipsizeCenterEnd(sequence, message.highlightedWords.get(0), maxWidth, captionTextPaint), captionTextPaint, maxWidth, TextUtils.TruncateAt.END);

View File

@ -378,6 +378,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private int threadMaxInboxReadId;
private int threadMaxOutboxReadId;
private int replyMaxReadId = 0;
private Runnable delayedReadRunnable;
private ArrayList<MessageObject> animatingMessageObjects = new ArrayList<>();
private HashMap<TLRPC.Document, Integer> animatingDocuments = new HashMap<>();
@ -1209,10 +1210,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
getNotificationCenter().addObserver(this, NotificationCenter.pinnedMessageDidLoad);
getNotificationCenter().addObserver(this, NotificationCenter.commentsRead);
getNotificationCenter().addObserver(this, NotificationCenter.changeRepliesCounter);
getNotificationCenter().addObserver(this, NotificationCenter.messagesRead);
} else {
getNotificationCenter().addObserver(this, NotificationCenter.threadMessagesRead);
}
getNotificationCenter().addObserver(this, NotificationCenter.messagesRead);
getNotificationCenter().addObserver(this, NotificationCenter.removeAllMessagesFromDialog);
getNotificationCenter().addObserver(this, NotificationCenter.messagesReadContent);
getNotificationCenter().addObserver(this, NotificationCenter.chatSearchResultsAvailable);
@ -3972,11 +3973,15 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
@Override
public void onLayoutChildren(RecyclerView.Recycler recycler, RecyclerView.State state) {
try {
if (BuildVars.DEBUG_PRIVATE_VERSION) {
super.onLayoutChildren(recycler, state);
} catch (Exception e) {
FileLog.e(e);
AndroidUtilities.runOnUIThread(() -> chatAdapter.notifyDataSetChanged(false));
} else {
try {
super.onLayoutChildren(recycler, state);
} catch (Exception e) {
FileLog.e(e);
AndroidUtilities.runOnUIThread(() -> chatAdapter.notifyDataSetChanged(false));
}
}
}
};
@ -11968,9 +11973,16 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (obj != null && obj.hasReplies()) {
int maxReadId = (Integer) args[2];
if (paused) {
if (delayedReadRunnable != null) {
AndroidUtilities.cancelRunOnUIThread(delayedReadRunnable);
delayedReadRunnable = null;
}
obj.messageOwner.replies.read_max_id = maxReadId;
} else {
AndroidUtilities.runOnUIThread(() -> obj.messageOwner.replies.read_max_id = maxReadId, 1000);
AndroidUtilities.runOnUIThread(delayedReadRunnable = () -> {
delayedReadRunnable = null;
obj.messageOwner.replies.read_max_id = maxReadId;
}, 500);
}
}
}
@ -13314,6 +13326,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
} else {
if (messageObject.messageOwner.replies != null && messageObject.messageOwner.replies.read_max_id > newValue.read_max_id) {
newValue.read_max_id = messageObject.messageOwner.replies.read_max_id;
}
messageObject.messageOwner.replies = newValue;
}
if (messageObject.hasValidGroupId()) {
@ -14001,10 +14016,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public void onTransitionAnimationStart(boolean isOpen, boolean backward) {
int[] alowedNotifications = null;
if (isOpen) {
alowedNotifications = new int[]{
NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats,
NotificationCenter.botKeyboardDidLoad, NotificationCenter.needDeleteDialog
};
if (threadMessageId != 0) {
alowedNotifications = new int[]{
NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats,
NotificationCenter.botKeyboardDidLoad, NotificationCenter.needDeleteDialog,
NotificationCenter.messagesDidLoad
};
} else {
alowedNotifications = new int[]{
NotificationCenter.dialogsNeedReload, NotificationCenter.closeChats,
NotificationCenter.botKeyboardDidLoad, NotificationCenter.needDeleteDialog
};
}
openAnimationEnded = false;
if (!backward) {
openAnimationStartTime = SystemClock.elapsedRealtime();
@ -17456,6 +17479,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
if (!noDiscussion && discussionMessage == null || noDiscussion || !noHistory && history == null) {
return;
}
if (history != null && maxReadId != 1 && maxReadId != 0 && maxReadId != discussionMessage.read_inbox_max_id) {
history = null;
}
@ -17498,7 +17522,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
}
getMessagesController().processLoadedMessages(history, dialogId, 0, 30, maxReadId, 0, false, chatActivity.getClassGuid(), fnid, 0, 0, 0, 2, true, false, false, arrayList.get(arrayList.size() - 1).getId(), 1, false, 0);
TLRPC.messages_Messages historyFinal = history;
int fnidFinal = fnid;
Utilities.stageQueue.postRunnable(() -> getMessagesController().processLoadedMessages(historyFinal, dialogId, 0, 30, maxReadId, 0, false, chatActivity.getClassGuid(), fnidFinal, 0, 0, 0, 2, true, false, false, arrayList.get(arrayList.size() - 1).getId(), 1, false, 0));
}
}

View File

@ -1944,7 +1944,9 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
} else {
if (searchingType != 0) {
searchingType = 0;
emojiView.closeSearch(false);
if (emojiView != null) {
emojiView.closeSearch(false);
}
messageEditText.requestFocus();
}
if (stickersExpanded) {
@ -5988,7 +5990,7 @@ public class ChatActivityEnterView extends FrameLayout implements NotificationCe
if (replyingMessageObject != null) {
openKeyboardInternal();
setButtons(botMessageObject, false);
} else if (botButtonsMessageObject.messageOwner.reply_markup.single_use) {
} else if (botButtonsMessageObject != null && botButtonsMessageObject.messageOwner.reply_markup.single_use) {
if (open) {
openKeyboardInternal();
} else {

View File

@ -2,14 +2,10 @@ package org.telegram.ui.Components;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.AnimatorSet;
import android.animation.ObjectAnimator;
import android.animation.ValueAnimator;
import android.content.Context;
import android.graphics.Canvas;
import android.os.Bundle;
import android.util.SparseArray;
import android.util.SparseIntArray;
import android.view.View;
import android.view.ViewTreeObserver;
import android.widget.FrameLayout;
@ -61,7 +57,7 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
private NumberTextView selectedMessagesCountTextView;
private boolean isActionModeShowed;
private HashMap<FilteredSearchView.MessageHashId, MessageObject> selectedFiles = new HashMap();
private HashMap<FilteredSearchView.MessageHashId, MessageObject> selectedFiles = new HashMap<>();
private ArrayList<FiltersView.MediaFilterData> currentSearchFilters = new ArrayList<>();
@ -253,8 +249,10 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
dialogsSearchAdapter.setFiltersDelegate(filteredSearchViewDelegate, false);
noMediaFiltersSearchView.animate().setListener(null).cancel();
noMediaFiltersSearchView.setDelegate(null, false);
emptyView.showProgress(!dialogsSearchAdapter.isSearching(), false);
emptyView.showProgress(dialogsSearchAdapter.isSearching(), false);
if (reset) {
emptyView.showProgress(!dialogsSearchAdapter.isSearching(), false);
emptyView.showProgress(dialogsSearchAdapter.isSearching(), false);
}
if (reset) {
noMediaFiltersSearchView.setVisibility(View.GONE);
} else {
@ -378,11 +376,9 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
DialogsActivity fragment = new DialogsActivity(args);
fragment.setDelegate((fragment1, dids, message, param) -> {
ArrayList<MessageObject> fmessages = new ArrayList<>();
ArrayList<Integer> ids = new ArrayList<>();
Iterator<FilteredSearchView.MessageHashId> idIterator = selectedFiles.keySet().iterator();
while (idIterator.hasNext()) {
FilteredSearchView.MessageHashId hashId = idIterator.next();
ids.add(hashId.messageId);
fmessages.add(selectedFiles.get(hashId));
}
selectedFiles.clear();
@ -495,7 +491,6 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
} else if (view instanceof DialogCell) {
((DialogCell) view).setChecked(selectedFiles.containsKey(hashId), true);
}
return;
}
@Override
@ -637,6 +632,7 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
}
noMediaFiltersSearchView.messagesDeleted(channelId, markAsDeletedMessages);
if (!selectedFiles.isEmpty()) {
ArrayList<FilteredSearchView.MessageHashId> toRemove = null;
Iterator<FilteredSearchView.MessageHashId> iterator = selectedFiles.keySet().iterator();
while (iterator.hasNext()) {
FilteredSearchView.MessageHashId hashId = iterator.next();
@ -646,14 +642,20 @@ public class SearchViewPager extends ViewPagerFixed implements FilteredSearchVie
if (currentChannelId == channelId) {
for (int i = 0; i < markAsDeletedMessages.size(); i++) {
if (messageObject.getId() == markAsDeletedMessages.get(i)) {
selectedFiles.remove(hashId);
selectedMessagesCountTextView.setNumber(selectedFiles.size(), true);
if (gotoItem != null) {
gotoItem.setVisibility(selectedFiles.size() == 1 ? View.VISIBLE : View.GONE);
}
toRemove = new ArrayList<>();
toRemove.add(hashId);
}
}
}
if (toRemove != null) {
for (int a = 0, N = toRemove.size(); a < N; a++) {
selectedFiles.remove(toRemove.get(a));
}
selectedMessagesCountTextView.setNumber(selectedFiles.size(), true);
if (gotoItem != null) {
gotoItem.setVisibility(selectedFiles.size() == 1 ? View.VISIBLE : View.GONE);
}
}
}
}
}

View File

@ -62,6 +62,7 @@ import org.telegram.ui.ActionBar.BaseFragment;
import org.telegram.ui.ActionBar.BottomSheet;
import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ActionBar.ThemeDescription;
import org.telegram.ui.Adapters.FiltersView;
import org.telegram.ui.Adapters.SearchAdapterHelper;
import org.telegram.ui.ArticleViewer;
import org.telegram.ui.Cells.ChatActionCell;
@ -78,6 +79,7 @@ import org.telegram.ui.Cells.SharedPhotoVideoCell;
import org.telegram.ui.Cells.UserCell;
import org.telegram.ui.ChatActivity;
import org.telegram.ui.DialogsActivity;
import org.telegram.ui.FilteredSearchView;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.ProfileActivity;
@ -94,12 +96,11 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
private static class MediaPage extends FrameLayout {
private RecyclerListView listView;
private LinearLayout progressView;
private FilteredSearchView.LoadingView progressView;
private TextView emptyTextView;
private ExtendedGridLayoutManager layoutManager;
private ImageView emptyImageView;
private LinearLayout emptyView;
private RadialProgressView progressBar;
private ClippingImageView animatingImageView;
private RecyclerAnimationScrollHelper scrollHelper;
private int selectedType;
@ -1208,21 +1209,36 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
mediaPages[a].emptyTextView.setPadding(AndroidUtilities.dp(40), 0, AndroidUtilities.dp(40), AndroidUtilities.dp(128));
mediaPages[a].emptyView.addView(mediaPages[a].emptyTextView, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER, 0, 24, 0, 0));
mediaPages[a].progressView = new LinearLayout(context) {
mediaPages[a].progressView = new FilteredSearchView.LoadingView(context) {
@Override
public int getColumnsCount() {
return columnsCount;
}
@Override
public int getType() {
if (mediaPage.selectedType == 0 || mediaPage.selectedType == 5) {
return 2;
} else if (mediaPage.selectedType == 1) {
return 3;
} else if (mediaPage.selectedType == 2 || mediaPage.selectedType == 4) {
return 4;
} else if (mediaPage.selectedType == 3) {
return 5;
}
return super.getType();
}
@Override
protected void onDraw(Canvas canvas) {
backgroundPaint.setColor(Theme.getColor(Theme.key_windowBackgroundWhite));
canvas.drawRect(0, 0, getMeasuredWidth(), getMeasuredHeight(), backgroundPaint);
super.onDraw(canvas);
}
};
mediaPages[a].progressView.setWillNotDraw(false);
mediaPages[a].progressView.setGravity(Gravity.CENTER);
mediaPages[a].progressView.setOrientation(LinearLayout.VERTICAL);
mediaPages[a].progressView.setVisibility(View.GONE);
mediaPages[a].addView(mediaPages[a].progressView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT));
mediaPages[a].progressBar = new RadialProgressView(context);
mediaPages[a].progressView.addView(mediaPages[a].progressBar, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT));
if (a != 0) {
mediaPages[a].setVisibility(View.GONE);
}
@ -1928,7 +1944,6 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
height = Math.max(height, AndroidUtilities.dp(120));
for (int a = 0; a < mediaPages.length; a++) {
mediaPages[a].emptyView.setTranslationY(-(getMeasuredHeight() - height) / 2);
mediaPages[a].progressView.setTranslationY(-(getMeasuredHeight() - height) / 2);
}
}
@ -2014,8 +2029,10 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
profileActivity.getMediaDataController().loadMedia(mergeDialogId, 50, sharedMediaData[type].max_id[1], type, 1, profileActivity.getClassGuid());
}
if (adapter != null) {
RecyclerListView listView = null;
for (int a = 0; a < mediaPages.length; a++) {
if (mediaPages[a].listView.getAdapter() == adapter) {
listView = mediaPages[a].listView;
mediaPages[a].listView.stopScroll();
}
}
@ -2034,13 +2051,43 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} else if (newItemCount < oldItemCount) {
adapter.notifyItemRangeRemoved(newItemCount, (oldItemCount - newItemCount));
}
if (listView != null && oldItemCount == 0 && newItemCount > 0) {
RecyclerListView finalListView = listView;
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
int n = finalListView.getChildCount();
AnimatorSet animatorSet = new AnimatorSet();
for (int i = 0; i < n; i++) {
View child = finalListView.getChildAt(i);
child.setAlpha(0);
int s = Math.min(finalListView.getMeasuredHeight(), Math.max(0, child.getTop()));
int delay = (int) ((s / (float) finalListView.getMeasuredHeight()) * 100);
ObjectAnimator a = ObjectAnimator.ofFloat(child, View.ALPHA, 0, 1f);
a.setStartDelay(delay);
a.setDuration(200);
animatorSet.playTogether(a);
}
animatorSet.start();
return true;
}
});
}
}
scrolling = true;
for (int a = 0; a < mediaPages.length; a++) {
if (mediaPages[a].selectedType == type) {
if (!sharedMediaData[type].loading) {
if (mediaPages[a].progressView != null) {
mediaPages[a].progressView.setVisibility(View.GONE);
View v = mediaPages[a].progressView;
v.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
v.setAlpha(1f);
v.setVisibility(View.GONE);
}
});
}
if (mediaPages[a].listView != null) {
if (mediaPages[a].listView.getEmptyView() == null) {
@ -3774,20 +3821,53 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
} else {
endReached = true;
}
loading = false;
firstLoaded = true;
for (int a = 0; a < mediaPages.length; a++) {
if (mediaPages[a].selectedType == 6) {
if (mediaPages[a].progressView != null) {
mediaPages[a].progressView.setVisibility(View.GONE);
View v = mediaPages[a].progressView;
v.animate().alpha(0).setListener(new AnimatorListenerAdapter() {
@Override
public void onAnimationEnd(Animator animation) {
v.setAlpha(1f);
v.setVisibility(View.GONE);
}
});
}
if (mediaPages[a].listView != null) {
if (mediaPages[a].listView.getEmptyView() == null) {
mediaPages[a].listView.setEmptyView(mediaPages[a].emptyView);
}
final RecyclerListView listView = mediaPages[a].listView;
if (firstLoaded) {
if (listView != null) {
getViewTreeObserver().addOnPreDrawListener(new ViewTreeObserver.OnPreDrawListener() {
@Override
public boolean onPreDraw() {
getViewTreeObserver().removeOnPreDrawListener(this);
int n = listView.getChildCount();
AnimatorSet animatorSet = new AnimatorSet();
for (int i = 0; i < n; i++) {
View child = listView.getChildAt(i);
child.setAlpha(0);
int s = Math.min(listView.getMeasuredHeight(), Math.max(0, child.getTop()));
int delay = (int) ((s / (float) listView.getMeasuredHeight()) * 100);
ObjectAnimator a = ObjectAnimator.ofFloat(child, View.ALPHA, 0, 1f);
a.setStartDelay(delay);
a.setDuration(200);
animatorSet.playTogether(a);
}
animatorSet.start();
return true;
}
});
}
}
}
}
}
loading = false;
firstLoaded = true;
notifyDataSetChanged();
}));
profileActivity.getConnectionsManager().bindRequestToGuid(reqId, profileActivity.getClassGuid());
@ -4207,9 +4287,6 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_LISTGLOWCOLOR, null, null, null, null, Theme.key_actionBarDefault));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_SELECTOR, null, null, null, null, Theme.key_listSelector));
arrayList.add(new ThemeDescription(mediaPages[a].emptyView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_emptyListPlaceholder));
arrayList.add(new ThemeDescription(mediaPages[a].progressBar, ThemeDescription.FLAG_PROGRESSBAR, null, null, null, null, Theme.key_progressCircle));
arrayList.add(new ThemeDescription(mediaPages[a].emptyTextView, ThemeDescription.FLAG_TEXTCOLOR, null, null, null, null, Theme.key_windowBackgroundWhiteGrayText2));
arrayList.add(new ThemeDescription(mediaPages[a].listView, ThemeDescription.FLAG_SECTIONS, new Class[]{GraySectionCell.class}, new String[]{"textView"}, null, null, null, Theme.key_graySectionText));

View File

@ -410,7 +410,7 @@ public class ContactsActivity extends BaseFragment implements NotificationCenter
String str = (String) object;
if (!str.equals("section")) {
NewContactActivity activity = new NewContactActivity();
activity.setInitialPhoneNumber(str);
activity.setInitialPhoneNumber(str, true);
presentFragment(activity);
}
}

View File

@ -3012,6 +3012,13 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
updateFilterTabs(false);
if (folderId != 0) {
FiltersView.MediaFilterData filterData = new FiltersView.MediaFilterData(R.drawable.chats_archive, R.drawable.chats_archive, LocaleController.getString("Archive", R.string.Archive), null, FiltersView.FILTER_TYPE_ARCHIVE);
filterData.removable = false;
actionBar.setSearchFilter(filterData);
searchItem.collapseSearchFilters();
}
return fragmentView;
}
@ -3025,10 +3032,18 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
searchTabsHeight = searchTabsView.getMeasuredHeight();
}
if (fragmentContextView != null) {
fragmentContextView.setTranslationY(topPadding + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress);
float from = 0;
if (fragmentLocationContextView != null && fragmentLocationContextView.getVisibility() == View.VISIBLE) {
from += AndroidUtilities.dp(36);
}
fragmentContextView.setTranslationY(from + fragmentContextView.getTopPadding() + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress);
}
if (fragmentLocationContextView != null) {
fragmentLocationContextView.setTranslationY(topPadding + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress);
float from = 0;
if (fragmentContextView != null) {
from += fragmentContextView.getTopPadding();
}
fragmentLocationContextView.setTranslationY(from + fragmentLocationContextView.getTopPadding() + actionBar.getTranslationY() + filtersTabsHeight * (1f - searchAnimationProgress) + searchTabsHeight * searchAnimationProgress);
}
}
@ -3709,6 +3724,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
searchTabsView.hide(false, false);
searchTabsView.setVisibility(View.VISIBLE);
}
searchItem.getSearchContainer().setAlpha(0f);
} else {
viewPages[0].listView.setVisibility(View.VISIBLE);
viewPages[0].setVisibility(View.VISIBLE);
@ -3768,6 +3784,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid);
searchItem.setVisibility(View.GONE);
} else {
searchItem.collapseSearchFilters();
whiteActionBar = false;
searchViewPager.setVisibility(View.GONE);
if (searchTabsView != null) {
@ -4022,7 +4039,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
actionBar.openSearchField(str, false);
} else if (!str.equals("section")) {
NewContactActivity activity = new NewContactActivity();
activity.setInitialPhoneNumber(str);
activity.setInitialPhoneNumber(str, true);
presentFragment(activity);
}
}

View File

@ -326,7 +326,7 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
recyclerListView.setLayoutManager(layoutManager);
addView(loadingView = new LoadingView(context) {
@Override
int getType() {
public int getType() {
if (currentSearchFilter == null) {
return 1;
} else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_MEDIA) {
@ -346,7 +346,7 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
}
@Override
int getColumnsCount() {
public int getColumnsCount() {
return columnsCount;
}
});
@ -488,11 +488,7 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
}
if (!filterAndQueryIsSame) {
//if (!filterAndQueryIsSame || TextUtils.isEmpty(query)) {
clearCurrentResultsRunnable.run();
// } else {
// AndroidUtilities.runOnUIThread(clearCurrentResultsRunnable, 1000);
// }
emptyView.showProgress(true, !clearOldResults);
}
@ -713,10 +709,10 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
boolean found = false;
for (int i = 0; i < localTipChats.size(); i++) {
if (localTipChats.get(i) instanceof TLRPC.User)
if (UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser().id == ((TLRPC.User)localTipChats.get(i)).id) {
found = true;
break;
}
if (UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser().id == ((TLRPC.User) localTipChats.get(i)).id) {
found = true;
break;
}
}
if (!found) {
localTipChats.add(0, UserConfig.getInstance(UserConfig.selectedAccount).getCurrentUser());
@ -831,7 +827,7 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
View view;
switch (viewType) {
case 0:
view = new SharedPhotoVideoCell(mContext, SharedPhotoVideoCell.VIEW_TYPE_GLOBAL_SEARCH) ;
view = new SharedPhotoVideoCell(mContext, SharedPhotoVideoCell.VIEW_TYPE_GLOBAL_SEARCH);
SharedPhotoVideoCell cell = (SharedPhotoVideoCell) view;
cell.setDelegate(new SharedPhotoVideoCell.SharedPhotoVideoCellDelegate() {
@Override
@ -1542,10 +1538,15 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
public interface UiCallback {
void goToMessage(MessageObject messageObject);
boolean actionModeShowing();
void toggleItemSelection(MessageObject item, View view, int a);
boolean isSelected(MessageHashId messageHashId);
void showActionMode();
int getFolderId();
}
@ -1561,11 +1562,11 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
int color0;
int color1;
int getType() {
public int getType() {
return 1;
}
int getColumnsCount() {
public int getColumnsCount() {
return 2;
}
@ -1588,15 +1589,18 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
int h = 0;
while (h < getMeasuredHeight()) {
int r = AndroidUtilities.dp(25);
canvas.drawCircle(AndroidUtilities.dp(9) + r, h + (AndroidUtilities.dp(78) >> 1), r, paint);
canvas.drawCircle(checkRtl(AndroidUtilities.dp(9) + r), h + (AndroidUtilities.dp(78) >> 1), r, paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(20), AndroidUtilities.dp(140), h + AndroidUtilities.dp(28));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(42), AndroidUtilities.dp(260), h + AndroidUtilities.dp(50));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(getMeasuredWidth() - AndroidUtilities.dp(50), h + AndroidUtilities.dp(20), getMeasuredWidth() - AndroidUtilities.dp(12), h + AndroidUtilities.dp(28));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
h += AndroidUtilities.dp(78) + 1;
@ -1615,15 +1619,19 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
int h = 0;
while (h < getMeasuredHeight()) {
rectF.set(AndroidUtilities.dp(12), h + AndroidUtilities.dp(8), AndroidUtilities.dp(52), h + AndroidUtilities.dp(48));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(12), AndroidUtilities.dp(140), h + AndroidUtilities.dp(20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(34), AndroidUtilities.dp(260), h + AndroidUtilities.dp(42));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(getMeasuredWidth() - AndroidUtilities.dp(50), h + AndroidUtilities.dp(12), getMeasuredWidth() - AndroidUtilities.dp(12), h + AndroidUtilities.dp(20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
h += AndroidUtilities.dp(56) + 1;
@ -1632,15 +1640,18 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
int h = 0;
while (h < getMeasuredHeight()) {
int radius = AndroidUtilities.dp(44) >> 1;
canvas.drawCircle(AndroidUtilities.dp(12) + radius, h + AndroidUtilities.dp(6) + radius, radius, paint);
canvas.drawCircle(checkRtl(AndroidUtilities.dp(12) + radius), h + AndroidUtilities.dp(6) + radius, radius, paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(12), AndroidUtilities.dp(140), h + AndroidUtilities.dp(20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(34), AndroidUtilities.dp(260), h + AndroidUtilities.dp(42));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(getMeasuredWidth() - AndroidUtilities.dp(50), h + AndroidUtilities.dp(12), getMeasuredWidth() - AndroidUtilities.dp(12), h + AndroidUtilities.dp(20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
h += AndroidUtilities.dp(56) + 1;
@ -1649,18 +1660,23 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
int h = 0;
while (h < getMeasuredHeight()) {
rectF.set(AndroidUtilities.dp(10), h + AndroidUtilities.dp(11), AndroidUtilities.dp(62), h + AndroidUtilities.dp(11 + 52));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(12), AndroidUtilities.dp(140), h + AndroidUtilities.dp(20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(34), AndroidUtilities.dp(268), h + AndroidUtilities.dp(42));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(AndroidUtilities.dp(68), h + AndroidUtilities.dp(34 + 20), AndroidUtilities.dp(120 + 68), h + AndroidUtilities.dp(42 + 20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
rectF.set(getMeasuredWidth() - AndroidUtilities.dp(50), h + AndroidUtilities.dp(12), getMeasuredWidth() - AndroidUtilities.dp(12), h + AndroidUtilities.dp(20));
checkRtl(rectF);
canvas.drawRoundRect(rectF, AndroidUtilities.dp(4), AndroidUtilities.dp(4), paint);
h += AndroidUtilities.dp(80);
@ -1681,6 +1697,20 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente
gradient.setLocalMatrix(matrix);
invalidate();
}
private float checkRtl(float x) {
if (LocaleController.isRTL) {
return getMeasuredWidth() - x;
}
return x;
}
private void checkRtl(RectF rectF) {
if (LocaleController.isRTL) {
rectF.left = getMeasuredWidth() - rectF.left;
rectF.right = getMeasuredWidth() - rectF.right;
}
}
}
private void showFloatingDateView() {

View File

@ -2140,7 +2140,7 @@ public class LaunchActivity extends Activity implements ActionBarLayout.ActionBa
fragment.setInitialName(names[0], names.length > 1 ? names[1] : null);
}
if (newContactPhone != null) {
fragment.setInitialPhoneNumber(PhoneFormat.stripExceptNumbers(newContactPhone));
fragment.setInitialPhoneNumber(PhoneFormat.stripExceptNumbers(newContactPhone, true), false);
}
actionBarLayout.presentFragment(fragment, false, true, true, false);
if (AndroidUtilities.isTablet()) {

View File

@ -92,6 +92,7 @@ public class NewContactActivity extends BaseFragment implements AdapterView.OnIt
private boolean ignoreSelection;
private boolean donePressed;
private String initialPhoneNumber;
private boolean initialPhoneNumberWithCountryCode;
private String initialFirstName;
private String initialLastName;
@ -568,7 +569,23 @@ public class NewContactActivity extends BaseFragment implements AdapterView.OnIt
Collections.sort(countriesArray, String::compareTo);
if (!TextUtils.isEmpty(initialPhoneNumber)) {
codeField.setText(initialPhoneNumber);
TLRPC.User user = getUserConfig().getCurrentUser();
if (initialPhoneNumber.startsWith("+")) {
codeField.setText(initialPhoneNumber.substring(1));
} else if (initialPhoneNumberWithCountryCode || user == null || TextUtils.isEmpty(user.phone)) {
codeField.setText(initialPhoneNumber);
} else {
String phone = user.phone;
for (int a = 4; a >= 1; a--) {
String sub = phone.substring(0, a);
String country = codesMap.get(sub);
if (country != null) {
codeField.setText(sub);
break;
}
}
phoneField.setText(initialPhoneNumber);
}
initialPhoneNumber = null;
} else {
String country = null;
@ -618,8 +635,9 @@ public class NewContactActivity extends BaseFragment implements AdapterView.OnIt
}
}
public void setInitialPhoneNumber(String value) {
public void setInitialPhoneNumber(String value, boolean withCoutryCode) {
initialPhoneNumber = value;
initialPhoneNumberWithCountryCode = withCoutryCode;
}
public void setInitialName(String firstName, String lastName) {

View File

@ -5910,7 +5910,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
}
private void closeCaptionEnter(boolean apply) {
if (currentIndex < 0 || currentIndex >= imagesArrLocals.size()) {
if (currentIndex < 0 || currentIndex >= imagesArrLocals.size() || captionEditText.getTag() == null) {
return;
}
Object object = imagesArrLocals.get(currentIndex);
@ -9051,7 +9051,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
setItemVisible(masksItem, shouldMasksItemBeVisible, !pipItemVisible);
}
final boolean shouldAutoPlayed = shouldMessageObjectAutoPlayed(newMessageObject);
if (!shouldAutoPlayed) {
if (!shouldAutoPlayed && TextUtils.isEmpty(placeProvider.getTitleFor(switchingToIndex))) {
final boolean animated = !playerWasPlaying;
if (nameOverride != null) {
nameTextView.setText(nameOverride);
@ -9117,7 +9117,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
loadingMoreImages = true;
}
}
CharSequence title = placeProvider.getTitleFor( switchingToIndex);
CharSequence title = placeProvider.getTitleFor(switchingToIndex);
if (title != null) {
actionBar.setTitle(title);
CharSequence subtitle = placeProvider.getSubtitleFor(switchingToIndex);

View File

@ -2790,6 +2790,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
frameLayout.addView(writeButton, LayoutHelper.createFrame(Build.VERSION.SDK_INT >= 21 ? 56 : 60, Build.VERSION.SDK_INT >= 21 ? 56 : 60, Gravity.RIGHT | Gravity.TOP, 0, 0, 16, 0));
writeButton.setOnClickListener(v -> {
if (writeButton.getTag() != null) {
return;
}
if (user_id != 0) {
if (imageUpdater != null) {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(UserConfig.getInstance(currentAccount).getClientUserId());
@ -4862,7 +4865,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter.
}
} else if (chat_id != 0) {
if (chatInfo != null && (!TextUtils.isEmpty(chatInfo.about) || chatInfo.location instanceof TLRPC.TL_channelLocation) || !TextUtils.isEmpty(currentChat.username)) {
if (LocaleController.isRTL && ChatObject.isChannel(currentChat) && !currentChat.megagroup && chatInfo.linked_chat_id != 0) {
if (LocaleController.isRTL && ChatObject.isChannel(currentChat) && chatInfo != null && !currentChat.megagroup && chatInfo.linked_chat_id != 0) {
emptyRow = rowCount++;
}
infoHeaderRow = rowCount++;

View File

@ -10,6 +10,7 @@ import android.content.Context;
import android.graphics.Bitmap;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Rect;
import android.graphics.RectF;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.GradientDrawable;
@ -93,6 +94,7 @@ public class ViewPagerFixed extends FrameLayout {
}
}
};
private Rect rect = new Rect();
public ViewPagerFixed(@NonNull Context context) {
super(context);
@ -270,6 +272,10 @@ public class ViewPagerFixed extends FrameLayout {
velocityTracker.addMovement(ev);
}
if (ev != null && ev.getAction() == MotionEvent.ACTION_DOWN && checkTabsAnimationInProgress()) {
View child = findScrollingChild(this, ev.getX(), ev.getY());
if (child != null && (child.canScrollHorizontally(1) || child.canScrollHorizontally(-1))) {
return false;
}
startedTracking = true;
startedTrackingPointerId = ev.getPointerId(0);
startedTrackingX = (int) ev.getX();
@ -548,7 +554,7 @@ public class ViewPagerFixed extends FrameLayout {
if (direction == 0) {
return false;
}
if (tabsAnimationInProgress) {
if (tabsAnimationInProgress || startedTracking) {
return true;
}
boolean forward = direction > 0;
@ -1389,5 +1395,27 @@ public class ViewPagerFixed extends FrameLayout {
}
}
private View findScrollingChild(ViewGroup parent, float x, float y) {
int n = parent.getChildCount();
for (int i = 0; i < n; i++) {
View child = parent.getChildAt(i);
if (child.getVisibility() != View.VISIBLE) {
continue;
}
child.getHitRect(rect);
if (rect.contains((int) x, (int) y)) {
if (child.canScrollHorizontally(-1)) {
return child;
} else if (child instanceof ViewGroup) {
View v = findScrollingChild((ViewGroup) child, x - rect.left, y - rect.top);
if (v != null) {
return v;
}
}
}
}
return null;
}
}