diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index f252fe6f3..e84ea04d3 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -284,7 +284,7 @@ android { } } - defaultConfig.versionCode = 2090 + defaultConfig.versionCode = 2092 applicationVariants.all { variant -> variant.outputs.all { output -> diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java index 1da1d9470..7cc23e966 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/AndroidUtilities.java @@ -288,7 +288,7 @@ public class AndroidUtilities { x = staticLayout.getPrimaryHorizontal(startHighlightedIndex + 1) - availableWidth * 0.3f; sub = str.subSequence(staticLayout.getOffsetForHorizontal(0, x), str.length()); } else { - if (Character.isWhitespace(str.charAt(charOf))) { + if (charOf > 0 && charOf < str.length() - 1 && Character.isWhitespace(str.charAt(charOf))) { charOf--; } sub = str.subSequence(charOf, str.length()); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index 09f7c3b30..b7bd37ef0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -18,7 +18,7 @@ public class BuildVars { public static boolean LOGS_ENABLED = false; public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; - public static int BUILD_VERSION = 2090; + public static int BUILD_VERSION = 2092; public static String BUILD_VERSION_STRING = "7.1.0"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index 1a5c51368..8dad9fffb 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -1951,7 +1951,7 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, loadingPlaylist = true; ConnectionsManager.getInstance(currentAccount).sendRequest(request, (response, error) -> { AndroidUtilities.runOnUIThread(() -> { - if (playlistClassGuid != finalPlaylistGuid || playlistGlobalSearchParams == null) { + if (playlistClassGuid != finalPlaylistGuid || playlistGlobalSearchParams == null || playingMessageObject == null) { return; } if (error != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 6bfa26319..a8efc3187 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -5580,10 +5580,10 @@ public class MessageObject { if (startIndex < 0) { continue; } + int l = Math.max(currentQuery.length(), word.length()); if (startIndex != 0) { word = word.substring(startIndex); } - int l = Math.max(currentQuery.length(), word.length()); int min = Math.min(currentQuery.length(), word.length()); int count = 0; for (int j = 0; j < min; j++) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 3b263d59d..6cafc4104 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -10771,7 +10771,7 @@ public class MessagesStorage extends BaseController { } - public void localSearch(int dialogsType, String query, ArrayList resultArray, ArrayList resultArrayNames, ArrayList encUsers) { + public void localSearch(int dialogsType, String query, ArrayList resultArray, ArrayList resultArrayNames, ArrayList encUsers, int folderId) { int selfUserId = UserConfig.getInstance(currentAccount).getClientUserId(); try { String savedMessages = LocaleController.getString("SavedMessages", R.string.SavedMessages).toLowerCase(); @@ -10792,7 +10792,12 @@ public class MessagesStorage extends BaseController { int resultCount = 0; LongSparseArray dialogsResult = new LongSparseArray<>(); - SQLiteCursor cursor = getDatabase().queryFinalized("SELECT did, date FROM dialogs ORDER BY date DESC LIMIT 600"); + SQLiteCursor cursor = null; + if (folderId >= 0) { + cursor = getDatabase().queryFinalized("SELECT did, date FROM dialogs WHERE folder_id = ? ORDER BY date DESC LIMIT 600", folderId); + } else { + cursor = getDatabase().queryFinalized("SELECT did, date FROM dialogs ORDER BY date DESC LIMIT 600"); + } while (cursor.next()) { long id = cursor.longValue(0); DialogsSearchAdapter.DialogSearchResult dialogSearchResult = new DialogsSearchAdapter.DialogSearchResult(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java index 1510c0e6e..96a0336a0 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/NotificationsController.java @@ -1384,9 +1384,8 @@ public class NotificationsController extends BaseController { return messageObject.messageOwner.message; } if (fromId == 0) { - if (messageObject.isFromUser() || messageObject.getId() < 0) { - fromId = messageObject.getFromChatId(); - } else { + fromId = messageObject.getFromChatId(); + if (fromId == 0) { fromId = -chat_id; } } else if (fromId == getUserConfig().getClientUserId()) { @@ -1823,9 +1822,8 @@ public class NotificationsController extends BaseController { } int selfUsedId = getUserConfig().getClientUserId(); if (from_id == 0) { - if (messageObject.isFromUser() || messageObject.getId() < 0) { - from_id = messageObject.getFromChatId(); - } else { + from_id = messageObject.getFromChatId(); + if (from_id == 0) { from_id = -chat_id; } } else if (from_id == selfUsedId) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java index 1550cfab1..7215e1000 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBar.java @@ -102,7 +102,7 @@ public class ActionBar extends FrameLayout { protected BaseFragment parentFragment; public ActionBarMenuOnItemClick actionBarMenuOnItemClick; private int titleColorToSet = 0; - private boolean ovelayTitleAnimation = true; + private boolean overlayTitleAnimation; private boolean titleAnimationRunning; private boolean fromBottom; @@ -285,6 +285,7 @@ public class ActionBar extends FrameLayout { } if (subtitleTextView != null) { subtitleTextView.setVisibility(!TextUtils.isEmpty(value) && !isSearchFieldVisible ? VISIBLE : GONE); + subtitleTextView.setAlpha(1f); subtitleTextView.setText(value); } } @@ -317,6 +318,7 @@ public class ActionBar extends FrameLayout { titleTextView[0].setVisibility(value != null && !isSearchFieldVisible ? VISIBLE : INVISIBLE); titleTextView[0].setText(value); } + fromBottom = false; } public void setTitleColor(int color) { @@ -779,7 +781,7 @@ public class ActionBar extends FrameLayout { if (titleTextView[0] != null && titleTextView[0].getVisibility() != GONE || subtitleTextView != null && subtitleTextView.getVisibility() != GONE) { int availableWidth = width - (menu != null ? menu.getMeasuredWidth() : 0) - AndroidUtilities.dp(16) - textLeft - titleRightMargin; - if (((fromBottom && i == 0) || (!fromBottom && i == 1)) && ovelayTitleAnimation && titleAnimationRunning) { + if (((fromBottom && i == 0) || (!fromBottom && i == 1)) && overlayTitleAnimation && titleAnimationRunning) { titleTextView[i].setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20); } else { if (titleTextView[0] != null && titleTextView[0].getVisibility() != GONE && subtitleTextView != null && subtitleTextView.getVisibility() != GONE) { @@ -839,7 +841,7 @@ public class ActionBar extends FrameLayout { for (int i = 0; i < 2; i++) { if (titleTextView[i] != null && titleTextView[i].getVisibility() != GONE) { int textTop; - if (((fromBottom && i == 0) || (!fromBottom && i == 1)) && ovelayTitleAnimation && titleAnimationRunning) { + if (((fromBottom && i == 0) || (!fromBottom && i == 1)) && overlayTitleAnimation && titleAnimationRunning) { textTop = (getCurrentActionBarHeight() - titleTextView[i].getTextHeight()) / 2; } else { if ((subtitleTextView != null && subtitleTextView.getVisibility() != GONE)) { @@ -1107,12 +1109,11 @@ public class ActionBar extends FrameLayout { } public void setTitleAnimated(CharSequence title, boolean fromBottom, long duration) { - if (titleTextView[0] == null) { + if (titleTextView[0] == null || title == null) { setTitle(title); return; } - this.fromBottom = fromBottom; - boolean crossfade = ovelayTitleAnimation && !TextUtils.isEmpty(subtitleTextView.getText()); + boolean crossfade = overlayTitleAnimation && !TextUtils.isEmpty(subtitleTextView.getText()); if (crossfade) { if (subtitleTextView.getVisibility() != View.VISIBLE) { subtitleTextView.setVisibility(View.VISIBLE); @@ -1130,6 +1131,7 @@ public class ActionBar extends FrameLayout { titleTextView[1] = titleTextView[0]; titleTextView[0] = null; setTitle(title); + this.fromBottom = fromBottom; titleTextView[0].setAlpha(0); if (!crossfade) { titleTextView[0].setTranslationY(fromBottom ? AndroidUtilities.dp(20) : -AndroidUtilities.dp(20)); @@ -1181,4 +1183,8 @@ public class ActionBar extends FrameLayout { public ActionBarMenu getActionMode() { return actionMode; } + + public void setOverlayTitleAnimation(boolean ovelayTitleAnimation) { + this.overlayTitleAnimation = ovelayTitleAnimation; + } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java index ec924f59a..6f5736665 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -621,6 +621,7 @@ public class ActionBarMenuItem extends FrameLayout { return false; } else { searchContainer.setVisibility(VISIBLE); + searchContainer.setAlpha(1f); setVisibility(GONE); searchField.setText(""); searchField.requestFocus(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java index 98f84c8ea..07a83dcaf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/DialogsSearchAdapter.java @@ -541,7 +541,7 @@ public class DialogsSearchAdapter extends RecyclerListView.SelectionAdapter { ArrayList resultArray = new ArrayList<>(); ArrayList resultArrayNames = new ArrayList<>(); ArrayList encUsers = new ArrayList<>(); - MessagesStorage.getInstance(currentAccount).localSearch(dialogsType, q, resultArray, resultArrayNames, encUsers); + MessagesStorage.getInstance(currentAccount).localSearch(dialogsType, q, resultArray, resultArrayNames, encUsers, -1); updateSearchResults(resultArray, resultArrayNames, encUsers, searchId); FiltersView.fillTipDates(q, localTipDates); AndroidUtilities.runOnUIThread(() -> { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java index c3df71ff2..1e27eed70 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Adapters/FiltersView.java @@ -264,14 +264,8 @@ public class FiltersView extends RecyclerListView { 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 String formatter[] = new String[]{ - "dd.MM.yyyy", - "dd/MM/yyyy", - "dd MM yyyy", - }; - - private final static int[] numberOfDaysEachMonth = new int[]{31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; + private final static int[] numberOfDaysEachMonth = new int[]{31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31}; public static void fillTipDates(String query, ArrayList dates) { dates.clear(); @@ -282,7 +276,7 @@ public class FiltersView extends RecyclerListView { if (q.length() < 3) { return; } - if (LocaleController.getString("SearchTipToday", R.string.SearchTipToday).toLowerCase().startsWith(q)) { + if (LocaleController.getString("SearchTipToday", R.string.SearchTipToday).toLowerCase().startsWith(q) || "today".startsWith(q)) { Calendar calendar = Calendar.getInstance(); int year = calendar.get(Calendar.YEAR); int month = calendar.get(Calendar.MONTH); @@ -294,6 +288,19 @@ public class FiltersView extends RecyclerListView { dates.add(new DateData(LocaleController.getString("SearchTipToday", R.string.SearchTipToday), minDate, maxDate)); return; } + + if (LocaleController.getString("SearchTipYesterday", R.string.SearchTipYesterday).toLowerCase().startsWith(q) || "yesterday".startsWith(q)) { + Calendar calendar = Calendar.getInstance(); + int year = calendar.get(Calendar.YEAR); + int month = calendar.get(Calendar.MONTH); + int day = calendar.get(Calendar.DAY_OF_MONTH); + calendar.set(year, month, day, 0, 0, 0); + long minDate = calendar.getTimeInMillis() - 86400000L; + calendar.set(year, month, day + 1, 0, 0, 0); + long maxDate = calendar.getTimeInMillis() - 86400001L; + dates.add(new DateData(LocaleController.getString("SearchTipYesterday", R.string.SearchTipYesterday), minDate, maxDate)); + return; + } Matcher matcher; int dayOfWeek = getDayOfWeek(q); @@ -346,17 +353,17 @@ public class FiltersView extends RecyclerListView { if (!matcher.group(2).equals(matcher.group(4))) { return; } - int day = Integer.parseInt(g1) - 1; + int day = Integer.parseInt(g1); int month = Integer.parseInt(g2) - 1; int year = Integer.parseInt(g3); int currentYear = Calendar.getInstance().get(Calendar.YEAR); - if (validDateForMont(day, month + 1) && year >= minYear && year <= currentYear) { + if (validDateForMont(day - 1, month) && year >= minYear && year <= currentYear) { Calendar calendar = Calendar.getInstance(); calendar.set(year, month, day, 0, 0, 0); long minDate = calendar.getTimeInMillis(); calendar.set(year, month, day + 1, 0, 0, 0); long maxDate = calendar.getTimeInMillis() - 1; - dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(calendar.getTime()), minDate, maxDate)); + dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(minDate), minDate, maxDate)); return; } @@ -369,17 +376,17 @@ public class FiltersView extends RecyclerListView { selectedYear = minYear; for (int i = currentYear; i >= selectedYear; i--) { Calendar calendar = Calendar.getInstance(); - calendar.set(i, 0, 0, 0, 0, 0); + calendar.set(i, 0, 1, 0, 0, 0); long minDate = calendar.getTimeInMillis(); - calendar.set(i + 1, 0, 0, 0, 0, 0); + calendar.set(i + 1, 0, 1, 0, 0, 0); long maxDate = calendar.getTimeInMillis() - 1; dates.add(new DateData(Integer.toString(i), minDate, maxDate)); } } else if (selectedYear <= currentYear) { Calendar calendar = Calendar.getInstance(); - calendar.set(selectedYear, 0, 0, 0, 0, 0); + calendar.set(selectedYear, 0, 1, 0, 0, 0); long minDate = calendar.getTimeInMillis(); - calendar.set(selectedYear + 1, 0, 0, 0, 0, 0); + calendar.set(selectedYear + 1, 0, 1, 0, 0, 0); long maxDate = calendar.getTimeInMillis() - 1; dates.add(new DateData(Integer.toString(selectedYear), minDate, maxDate)); } @@ -421,41 +428,22 @@ public class FiltersView extends RecyclerListView { } } - for (int i = 0; i < formatter.length; i++) { - try { - if (isValidFormat(formatter[i], q, Locale.ENGLISH)) { - Date date = new SimpleDateFormat(formatter[i]).parse(q); - if (date != null) { - Calendar calendar = Calendar.getInstance(); - calendar.setTime(date); - int year = calendar.get(Calendar.YEAR); - if (year < minYear) { - return; - } - long minDate = date.getTime(); - long maxDate = minDate + 86400000L - 1; - dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(date), minDate, maxDate)); - return; - } - } - - } catch (ParseException e) { - e.printStackTrace(); - } - } - if (!TextUtils.isEmpty(q) && q.length() > 2) { int month = getMonth(q); + long today = Calendar.getInstance().getTimeInMillis(); if (month >= 0) { int selectedYear = minYear; int currentYear = Calendar.getInstance().get(Calendar.YEAR); for (int j = currentYear; j >= selectedYear; j--) { Calendar calendar = Calendar.getInstance(); - calendar.set(j, month, 0, 0, 0, 0); + calendar.set(j, month, 1, 0, 0, 0); long minDate = calendar.getTimeInMillis(); - calendar.set(j, month + 1, 0, 0, 0, 0); + if (minDate > today) { + continue; + } + calendar.add(Calendar.MONTH, 1); long maxDate = calendar.getTimeInMillis() - 1; - dates.add(new DateData(LocaleController.getInstance().formatterMonthYear.format(maxDate), minDate, maxDate)); + dates.add(new DateData(LocaleController.getInstance().formatterMonthYear.format(minDate), minDate, maxDate)); } } } @@ -463,33 +451,41 @@ public class FiltersView extends RecyclerListView { private static void createForMonthYear(ArrayList dates, int month, int selectedYear) { int currentYear = Calendar.getInstance().get(Calendar.YEAR); + long today = Calendar.getInstance().getTimeInMillis(); if (selectedYear >= minYear && selectedYear <= currentYear) { Calendar calendar = Calendar.getInstance(); - calendar.set(selectedYear, month, 0, 0, 0, 0); + calendar.set(selectedYear, month, 1, 0, 0, 0); long minDate = calendar.getTimeInMillis(); - calendar.set(selectedYear, month + 1, 0, 0, 0, 0); + if (minDate > today) { + return; + } + calendar.add(Calendar.MONTH, 1); long maxDate = calendar.getTimeInMillis() - 1; - dates.add(new DateData(LocaleController.getInstance().formatterMonthYear.format(maxDate), minDate, maxDate)); + dates.add(new DateData(LocaleController.getInstance().formatterMonthYear.format(minDate), minDate, maxDate)); } } private static void createForDayMonth(ArrayList dates, int day, int month) { if (validDateForMont(day, month)) { int currentYear = Calendar.getInstance().get(Calendar.YEAR); + long today = Calendar.getInstance().getTimeInMillis(); GregorianCalendar georgianCal = (GregorianCalendar) GregorianCalendar.getInstance(); for (int i = currentYear; i >= minYear; i--) { if (month == 1 && day == 28 && !georgianCal.isLeapYear(i)) { continue; } Calendar calendar = Calendar.getInstance(); - calendar.set(i, month, day, 0, 0, 0); - long minDate = calendar.getTimeInMillis(); calendar.set(i, month, day + 1, 0, 0, 0); + long minDate = calendar.getTimeInMillis(); + if (minDate > today) { + continue; + } + calendar.set(i, month, day + 2, 0, 0, 0); long maxDate = calendar.getTimeInMillis() - 1; if (i == currentYear) { - dates.add(new DateData(LocaleController.getInstance().formatterDayMonth.format(maxDate), minDate, maxDate)); + dates.add(new DateData(LocaleController.getInstance().formatterDayMonth.format(minDate), minDate, maxDate)); } else { - dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(maxDate), minDate, maxDate)); + dates.add(new DateData(LocaleController.getInstance().formatterYearMax.format(minDate), minDate, maxDate)); } } } @@ -540,9 +536,10 @@ public class FiltersView extends RecyclerListView { String[] monthsEng = new String[12]; Calendar c = Calendar.getInstance(); - for (int i = 0; i < 12; i++) { + for (int i = 1; i <= 12; i++) { + c.set(0, 0, 0, 0, 0, 0); c.set(Calendar.MONTH, i); - monthsEng[i] = c.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH).toLowerCase(); + monthsEng[i - 1] = c.getDisplayName(Calendar.MONTH, Calendar.LONG, Locale.ENGLISH).toLowerCase(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 66dbe1bf0..519986b4f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -6739,9 +6739,9 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate boolean imageDrawn = false; if (currentMessageObject.type == 0) { if (currentMessageObject.isOutOwner()) { - textX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11) + getExtraTextX(); + textX = getCurrentBackgroundLeft() + AndroidUtilities.dp(11) + getExtraTextX(); } else { - textX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(!mediaBackground && drawPinnedBottom ? 11 : 17) + getExtraTextX(); + textX = getCurrentBackgroundLeft() + AndroidUtilities.dp(!mediaBackground && drawPinnedBottom ? 11 : 17) + getExtraTextX(); } if (hasGamePreview) { textX += AndroidUtilities.dp(11); @@ -7547,7 +7547,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate bottom = (int) (parentHeight - getY()); } rect.set( - currentBackgroundDrawable.getBounds().left, top, + getCurrentBackgroundLeft(), top, currentBackgroundDrawable.getBounds().right, bottom ); } else { @@ -9473,6 +9473,11 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate setDrawableBoundsInner(currentBackgroundShadowDrawable, backgroundDrawableLeft, backgroundDrawableTop, backgroundDrawableRight, backgroundHeight); } + if (!currentMessageObject.isOutOwner() && transitionParams.changePinnedBottomProgress != 1 && (!mediaBackground && !drawPinnedBottom)) { + backgroundDrawableLeft -= AndroidUtilities.dp(6); + backgroundDrawableRight += AndroidUtilities.dp(6); + } + if (hasPsaHint) { int x; if (currentPosition == null || (currentPosition.flags & MessageObject.POSITION_FLAG_RIGHT) != 0) { @@ -9690,7 +9695,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } } if (currentMessageObject.isOutOwner()) { - sideStartX = currentBackgroundDrawable.getBounds().left - AndroidUtilities.dp(8 + 32); + sideStartX = getCurrentBackgroundLeft() - AndroidUtilities.dp(8 + 32); if (currentMessagesGroup != null) { sideStartX += currentMessagesGroup.transitionParams.offsetLeft - animationOffsetX; } @@ -10295,7 +10300,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate h2 = 0; } - int buttonX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(currentMessageObject.isOutOwner() || mediaBackground || drawPinnedBottom ? 2 : 8); + int buttonX = getCurrentBackgroundLeft() + AndroidUtilities.dp(currentMessageObject.isOutOwner() || mediaBackground || drawPinnedBottom ? 2 : 8); float buttonY = layoutHeight - AndroidUtilities.dp(45.1f - h2); if (currentPosition != null && (currentPosition.flags & MessageObject.POSITION_FLAG_LEFT) == 0 && !currentMessagesGroup.hasSibling) { endX += AndroidUtilities.dp(14); @@ -11276,7 +11281,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (docTitleOffsetX < 0 || docTitleOffsetX == 0 && docTitleLayout.getLineLeft(0) == 0) { pollHintX = currentBackgroundDrawable.getBounds().right - drawable.getIntrinsicWidth() - AndroidUtilities.dp(currentMessageObject.isOutOwner() ? 17 : 11); } else { - pollHintX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(11); + pollHintX = getCurrentBackgroundLeft() + AndroidUtilities.dp(11); } pollHintY = y - AndroidUtilities.dp(6); int cx = pollHintX + drawable.getIntrinsicWidth() / 2; @@ -11486,7 +11491,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } } if (drawInstantView) { - int textX = currentBackgroundDrawable.getBounds().left + AndroidUtilities.dp(currentMessageObject.isOutOwner() || mediaBackground || drawPinnedBottom ? 2 : 8); + int textX = getCurrentBackgroundLeft() + AndroidUtilities.dp(currentMessageObject.isOutOwner() || mediaBackground || drawPinnedBottom ? 2 : 8); int instantY = lastVoteY + AndroidUtilities.dp(13); if (currentMessageObject.isOutOwner()) { Theme.chat_instantViewPaint.setColor(Theme.getColor(Theme.key_chat_outPreviewInstantText)); @@ -12370,6 +12375,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } } + public int getCurrentBackgroundLeft() { + int left = currentBackgroundDrawable.getBounds().left; + if (!currentMessageObject.isOutOwner() && transitionParams.changePinnedBottomProgress != 1 && (!mediaBackground && !drawPinnedBottom)) { + left -= AndroidUtilities.dp(6); + } + return left; + } + public TransitionParams getTransitionParams() { return transitionParams; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java index 2028e8007..53704514e 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharedPhotoVideoCell.java @@ -53,6 +53,11 @@ public class SharedPhotoVideoCell extends FrameLayout { private boolean ignoreLayout; private Paint backgroundPaint = new Paint(); + public final static int VIEW_TYPE_DEFAULT = 0; + public final static int VIEW_TYPE_GLOBAL_SEARCH = 1; + + private int type; + private int currentAccount = UserConfig.selectedAccount; public interface SharedPhotoVideoCellDelegate { @@ -235,7 +240,11 @@ public class SharedPhotoVideoCell extends FrameLayout { } public SharedPhotoVideoCell(Context context) { + this(context, VIEW_TYPE_DEFAULT); + } + public SharedPhotoVideoCell(Context context, int type) { super(context); + this.type = type; backgroundPaint.setColor(Theme.getColor(Theme.key_sharedMedia_photoPlaceholder)); messageObjects = new MessageObject[6]; @@ -344,7 +353,12 @@ public class SharedPhotoVideoCell extends FrameLayout { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - final int itemWidth = getItemSize(itemsCount); + int itemWidth; + if (type == VIEW_TYPE_GLOBAL_SEARCH) { + itemWidth = (MeasureSpec.getSize(widthMeasureSpec) - (itemsCount - 1) * AndroidUtilities.dp(2)) / itemsCount; + } else { + itemWidth = getItemSize(itemsCount); + } ignoreLayout = true; for (int a = 0; a < itemsCount; a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharingLiveLocationCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharingLiveLocationCell.java index d2b62db32..b5263d1c4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharingLiveLocationCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/SharingLiveLocationCell.java @@ -148,7 +148,7 @@ public class SharingLiveLocationCell extends FrameLayout { fromId = -messageObject.messageOwner.fwd_from.from_id.channel_id; } else if (messageObject.messageOwner.fwd_from.from_id instanceof TLRPC.TL_peerChat) { fromId = -messageObject.messageOwner.fwd_from.from_id.chat_id; - } else { + } else if (messageObject.messageOwner.fwd_from.from_id instanceof TLRPC.TL_peerUser) { fromId = messageObject.messageOwner.fwd_from.from_id.user_id; } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 9eac0c6c3..a8b9c4790 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -2009,8 +2009,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not actionModeViews.clear(); if (inPreviewMode) { - headerItem.setAlpha(0.0f); - attachItem.setAlpha(0.0f); + if (headerItem != null) { + headerItem.setAlpha(0.0f); + } + if (attachItem != null) { + attachItem.setAlpha(0.0f); + } } final ActionBarMenu actionMode = actionBar.createActionMode(); @@ -2744,6 +2748,13 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } else if (child == instantCameraView || child == overlayView || child == animatingImageView) { childTop = 0; + } else if (child == textSelectionHelper.getOverlayView(context)) { + if (SharedConfig.smoothKeyboard) { + childTop -= paddingBottom; + } + if (keyboardSize > AndroidUtilities.dp(20) && getLayoutParams().height < 0) { + childTop -= keyboardSize; + } } child.layout(childLeft, childTop, childLeft + width, childTop + height); } @@ -12222,7 +12233,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not boolean hasChatInBack = false; boolean updatedReplies = false; - if (threadMessageObject != null) { + if (threadMessageObject != null && parentLayout != null) { for (int a = 0, N = parentLayout.fragmentsStack.size() - 1; a < N; a++) { BaseFragment fragment = parentLayout.fragmentsStack.get(a); if (fragment != this && fragment instanceof ChatActivity) { @@ -13259,7 +13270,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not SparseArray array = channelReplies.get((int) dialog_id); boolean hasChatInBack = false; - if (threadMessageObject != null) { + if (threadMessageObject != null && parentLayout != null) { for (int a = 0, N = parentLayout.fragmentsStack.size() - 1; a < N; a++) { BaseFragment fragment = parentLayout.fragmentsStack.get(a); if (fragment != this && fragment instanceof ChatActivity) { @@ -13306,7 +13317,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } newGroups.put(groupedMessages.groupId, groupedMessages); } - } else { + } else if (chatAdapter != null) { int row = messages.indexOf(messageObject); if (row >= 0) { if (updatedRows == null) { @@ -14605,9 +14616,9 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (fwd_from.from_id instanceof TLRPC.TL_peerUser) { user = messagesController.getUser(fwd_from.from_id.user_id); } else if (fwd_from.from_id instanceof TLRPC.TL_peerChat) { - user = messagesController.getUser(fwd_from.from_id.user_id); + chat = messagesController.getChat(fwd_from.from_id.chat_id); } else if (fwd_from.from_id instanceof TLRPC.TL_peerChannel) { - user = messagesController.getUser(fwd_from.from_id.user_id); + chat = messagesController.getChat(fwd_from.from_id.channel_id); } else { chat = messagesController.getChat(fwd_from.saved_from_peer.chat_id); } @@ -16922,7 +16933,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not MessageObject message = selectedObject; MessageObject.GroupedMessages group = selectedObjectGroup; AlertsCreator.createScheduleDatePickerDialog(getParentActivity(), dialog_id, message.messageOwner.date, (notify, scheduleDate) -> { - if (group != null) { + if (group != null && !group.messages.isEmpty()) { SendMessagesHelper.getInstance(currentAccount).editMessage(group.messages.get(0), null, false, ChatActivity.this, null, scheduleDate, null); } else { SendMessagesHelper.getInstance(currentAccount).editMessage(message, null, false, ChatActivity.this, null, scheduleDate, null); @@ -18159,7 +18170,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public boolean shouldDrawThreadProgress(ChatMessageCell cell) { MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup(); MessageObject message; - if (group != null) { + if (group != null && !group.messages.isEmpty()) { message = group.messages.get(0); } else { message = cell.getMessageObject(); @@ -18658,7 +18669,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not public void didPressCommentButton(ChatMessageCell cell) { MessageObject.GroupedMessages group = cell.getCurrentMessagesGroup(); MessageObject message; - if (group != null) { + if (group != null && !group.messages.isEmpty()) { message = group.messages.get(0); } else { message = cell.getMessageObject(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java index b5039f87b..ea46428ac 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AvatarDrawable.java @@ -47,7 +47,7 @@ public class AvatarDrawable extends Drawable { public static final int AVATAR_TYPE_SAVED = 1; public static final int AVATAR_TYPE_ARCHIVED = 2; public static final int AVATAR_TYPE_SHARES = 3; - public static final int AVATAR_TYPE_REPLIES = 4; + public static final int AVATAR_TYPE_REPLIES = 12; public static final int AVATAR_TYPE_FILTER_CONTACTS = 4; public static final int AVATAR_TYPE_FILTER_NON_CONTACTS = 5; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java index d02ea25a3..fe1177d46 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Bulletin.java @@ -213,7 +213,9 @@ public final class Bulletin { layout.onExitTransitionStart(); layout.onExitTransitionEnd(); layout.onHide(); - containerLayout.removeView(parentLayout); + if (containerLayout != null) { + containerLayout.removeView(parentLayout); + } layout.onDetach(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index 1673b1240..7a7513b90 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -556,12 +556,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } } else if (!inPreviewMode) { if (progressToActionMode > 0) { - int n = actionBar.getChildCount(); - for (int i = 0; i < n; i++) { - if (actionBar.getChildAt(i) != actionBar.getActionMode() && actionBar.getChildAt(i) != actionBar.getBackButton()) { - actionBar.getChildAt(i).setAlpha(1f - progressToActionMode); - } - } actionBarSearchPaint.setColor(ColorUtils.blendARGB(Theme.getColor(folderId == 0 ? Theme.key_actionBarDefault : Theme.key_actionBarDefaultArchived), Theme.getColor(Theme.key_windowBackgroundWhite), progressToActionMode)); canvas.drawRect(0, top, getMeasuredWidth(), top + actionBarHeight, actionBarSearchPaint); } else { @@ -1692,7 +1686,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. if (viewPages[0] != null) { if (searchString != null) { viewPages[0].listView.hide(); - searchViewPager.searchListView.show(); + if (searchViewPager != null) { + searchViewPager.searchListView.show(); + } } if (!onlySelect) { floatingButtonContainer.setVisibility(View.GONE); @@ -3771,6 +3767,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } searchWasFullyShowed = false; fragmentView.requestLayout(); + searchItem.getSearchContainer().setAlpha(1f); + } viewPages[0].listView.setVerticalScrollBarEnabled(true); @@ -3810,6 +3808,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. filtersView.setAlpha(show ? 1.0f : 0.0f); searchViewPager.setScaleX(show ? 1.0f : 1.1f); searchViewPager.setScaleY(show ? 1.0f : 1.1f); + searchItem.getSearchContainer().setAlpha(show ? 1f : 0); if (filterTabsView != null && filterTabsView.getVisibility() == View.VISIBLE) { filterTabsView.setTranslationY(show ? -AndroidUtilities.dp(44) : 0); filterTabsView.getTabsContainer().setAlpha(show ? 0.0f : 1.0f); @@ -4348,6 +4347,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. actionBarColorAnimator = ValueAnimator.ofFloat(progressToActionMode, 0); actionBarColorAnimator.addUpdateListener(valueAnimator -> { progressToActionMode = (float) valueAnimator.getAnimatedValue(); + for (int i = 0; i < actionBar.getChildCount(); i++) { + if (actionBar.getChildAt(i).getVisibility() == View.VISIBLE && actionBar.getChildAt(i) != actionBar.getActionMode() && actionBar.getChildAt(i) != actionBar.getBackButton()) { + actionBar.getChildAt(i).setAlpha(1f - progressToActionMode); + } + } fragmentView.invalidate(); }); actionBarColorAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); @@ -5046,6 +5050,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. actionBarColorAnimator = ValueAnimator.ofFloat(progressToActionMode, 1f); actionBarColorAnimator.addUpdateListener(valueAnimator -> { progressToActionMode = (float) valueAnimator.getAnimatedValue(); + for (int i = 0; i < actionBar.getChildCount(); i++) { + if (actionBar.getChildAt(i).getVisibility() == View.VISIBLE && actionBar.getChildAt(i) != actionBar.getActionMode() && actionBar.getChildAt(i) != actionBar.getBackButton()) { + actionBar.getChildAt(i).setAlpha(1f - progressToActionMode); + } + } fragmentView.invalidate(); }); actionBarColorAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); @@ -5846,6 +5855,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. for (int b = 0; b < 3; b++) { RecyclerListView list; if (b == 2) { + if (searchViewPager == null) { + continue; + } list = searchViewPager.searchListView; } else if (viewPages != null) { list = b < viewPages.length ? viewPages[b].listView : null; @@ -5867,7 +5879,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } } } - if (searchViewPager.dialogsSearchAdapter != null) { + if (searchViewPager != null && searchViewPager.dialogsSearchAdapter != null) { RecyclerListView recyclerListView = searchViewPager.dialogsSearchAdapter.getInnerListView(); if (recyclerListView != null) { int count = recyclerListView.getChildCount(); @@ -5920,21 +5932,25 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. if (filtersView != null) { filtersView.updateColors(); } - searchViewPager.updateColors(); + if (searchViewPager != null) { + searchViewPager.updateColors(); + } if (searchTabsView != null) { searchTabsView.updateColors(); } - EditTextBoldCursor editText = searchItem.getSearchField(); - if (whiteActionBar) { - editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); - editText.setHintTextColor(Theme.getColor(Theme.key_player_time)); - editText.setCursorColor(Theme.getColor(Theme.key_chat_messagePanelCursor)); - } else { - editText.setCursorColor(Theme.getColor(Theme.key_actionBarDefaultSearch)); - editText.setHintTextColor(Theme.getColor(Theme.key_actionBarDefaultSearchPlaceholder)); - editText.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSearch)); + if (searchItem != null) { + EditTextBoldCursor editText = searchItem.getSearchField(); + if (whiteActionBar) { + editText.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText)); + editText.setHintTextColor(Theme.getColor(Theme.key_player_time)); + editText.setCursorColor(Theme.getColor(Theme.key_chat_messagePanelCursor)); + } else { + editText.setCursorColor(Theme.getColor(Theme.key_actionBarDefaultSearch)); + editText.setHintTextColor(Theme.getColor(Theme.key_actionBarDefaultSearchPlaceholder)); + editText.setTextColor(Theme.getColor(Theme.key_actionBarDefaultSearch)); + } + searchItem.updateColor(); } - searchItem.updateColor(); setSearchAnimationProgress(searchAnimationProgress); }; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java b/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java index 55060119d..89b7fa706 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/FilteredSearchView.java @@ -327,10 +327,14 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente addView(loadingView = new LoadingView(context) { @Override int getType() { - if (currentSearchFilter == null || !TextUtils.isEmpty(currentSearchString)) { + if (currentSearchFilter == null) { return 1; } else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_MEDIA) { - return 2; + if (!TextUtils.isEmpty(currentSearchString)) { + return 1; + } else { + return 2; + } } else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_FILES) { return 3; } else if (currentSearchFilter.filterType == FiltersView.FILTER_TYPE_MUSIC || currentSearchFilter.filterType == FiltersView.FILTER_TYPE_VOICE) { @@ -502,6 +506,8 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente requestIndex++; final int requestId = requestIndex; + final int folderId = uiCallback.getFolderId(); + AndroidUtilities.runOnUIThread(searchRunnable = () -> { TLObject request; @@ -530,7 +536,7 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente resultArray = new ArrayList<>(); ArrayList resultArrayNames = new ArrayList<>(); ArrayList encUsers = new ArrayList<>(); - MessagesStorage.getInstance(currentAccount).localSearch(0, query, resultArray, resultArrayNames, encUsers); + MessagesStorage.getInstance(currentAccount).localSearch(0, query, resultArray, resultArrayNames, encUsers, folderId); } final TLRPC.TL_messages_searchGlobal req = new TLRPC.TL_messages_searchGlobal(); @@ -825,7 +831,7 @@ public class FilteredSearchView extends FrameLayout implements NotificationCente View view; switch (viewType) { case 0: - view = new SharedPhotoVideoCell(mContext); + view = new SharedPhotoVideoCell(mContext, SharedPhotoVideoCell.VIEW_TYPE_GLOBAL_SEARCH) ; SharedPhotoVideoCell cell = (SharedPhotoVideoCell) view; cell.setDelegate(new SharedPhotoVideoCell.SharedPhotoVideoCellDelegate() { @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 6218b12b2..b3b981468 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -3293,6 +3293,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat containerView.invalidate(); } }; + actionBar.setOverlayTitleAnimation(true); actionBar.setTitleColor(0xffffffff); actionBar.setSubtitleColor(0xffffffff); actionBar.setBackgroundColor(Theme.ACTION_BAR_PHOTO_VIEWER_COLOR); diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index c2d009203..fa5d58903 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -3766,4 +3766,5 @@ \'Remind on\' MMM d \'at\' HH:mm \'Remind on\' MMM d yyyy \'at\' HH:mm Today + Yesterday