From 8283c1236422ea70930be3c9ecb1f031ecaa54c1 Mon Sep 17 00:00:00 2001 From: xaxtix Date: Sat, 23 Apr 2022 12:51:09 +0300 Subject: [PATCH] Update to 8.7.2 --- TMessagesProj/build.gradle | 4 +- .../org_telegram_messenger_voip_Instance.cpp | 2 + .../org/telegram/messenger/BuildVars.java | 6 +- .../telegram/messenger/MessagesStorage.java | 2 +- .../org/telegram/messenger/voip/Instance.java | 2 +- .../org/telegram/ui/CalendarActivity.java | 4 +- .../telegram/ui/Cells/ChatMessageCell.java | 9 +- .../telegram/ui/ChatRightsEditActivity.java | 4 +- .../telegram/ui/Components/AlertsCreator.java | 19 ++- .../ui/Components/BotWebViewContainer.java | 10 +- .../ui/Components/ChatActivityEnterView.java | 4 + .../ui/Components/ChatAttachAlert.java | 20 ++- .../ChatAttachAlertBotWebViewLayout.java | 121 +++++++++++++----- .../ChatScrimPopupContainerLayout.java | 3 + .../java/org/telegram/ui/DialogsActivity.java | 111 +++++++++------- .../org/telegram/ui/DownloadProgressIcon.java | 1 + .../java/org/telegram/ui/LaunchActivity.java | 9 +- 17 files changed, 233 insertions(+), 98 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index 3727bdd77..ba60e5633 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -300,7 +300,7 @@ android { } } - defaultConfig.versionCode = 2629 + defaultConfig.versionCode = 2634 applicationVariants.all { variant -> variant.outputs.all { output -> @@ -319,7 +319,7 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionName "8.7.1" + versionName "8.7.2" vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] diff --git a/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp b/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp index 7f4e9e35d..f1c5783f0 100644 --- a/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp +++ b/TMessagesProj/jni/voip/org_telegram_messenger_voip_Instance.cpp @@ -25,6 +25,7 @@ #include "tgcalls/VideoCaptureInterface.h" #include "tgcalls/v2/InstanceV2Impl.h" #include "tgcalls/v2_4_0_0/InstanceV2_4_0_0Impl.h" +#include "tgcalls/v2/InstanceV2ReferenceImpl.h" using namespace tgcalls; @@ -32,6 +33,7 @@ const auto RegisterTag = Register(); const auto RegisterTagLegacy = Register(); const auto RegisterTagV2_4_0_0 = Register(); const auto RegisterTagV2_4_0_1 = Register(); +const auto RegisterTagV2_4_1_2 = Register(); jclass TrafficStatsClass; jclass FingerprintClass; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index a8e99ecc2..141eae3e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -20,11 +20,11 @@ public class BuildVars { public static boolean USE_CLOUD_STRINGS = true; public static boolean CHECK_UPDATES = true; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; - public static int BUILD_VERSION = 2629; - public static String BUILD_VERSION_STRING = "8.7.1"; + public static int BUILD_VERSION = 2634; + public static String BUILD_VERSION_STRING = "8.7.2"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; - + public static String SMS_HASH = isStandaloneApp() ? "w0lkcmTZkKh" : (DEBUG_VERSION ? "O2P2z+/jBpJ" : "oLeq9AcOZkT"); public static String PLAYSTORE_APP_URL = "https://play.google.com/store/apps/details?id=org.telegram.messenger"; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index 8ce3b2678..3a5959cad 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -12582,7 +12582,7 @@ public class MessagesStorage extends BaseController { state.dispose(); if (count == 0) { - state = database.executeFast("UPDATE reaction_mentions SET state = 0 WHERE dialog_id ?"); + state = database.executeFast("UPDATE reaction_mentions SET state = 0 WHERE dialog_id = ?"); state.bindLong(1, dialogId); state.step(); state.dispose(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java b/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java index 06256befb..cc9b6e11a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/voip/Instance.java @@ -15,7 +15,7 @@ import java.util.List; public final class Instance { - public static final List AVAILABLE_VERSIONS = Build.VERSION.SDK_INT >= 18 ? Arrays.asList("4.0.1", "4.0.0", "3.0.0", "2.7.7", "2.4.4") : Arrays.asList("2.4.4"); + public static final List AVAILABLE_VERSIONS = Build.VERSION.SDK_INT >= 18 ? Arrays.asList("4.1.2", "4.0.2", "4.0.1", "4.0.0", "3.0.0", "2.7.7", "2.4.4") : Arrays.asList("2.4.4"); public static final int AUDIO_STATE_MUTED = 0; public static final int AUDIO_STATE_ACTIVE = 1; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java index 5873ec75d..dc9c3f422 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/CalendarActivity.java @@ -312,9 +312,7 @@ public class CalendarActivity extends BaseFragment { @Override public void run(boolean forAll) { finishFragment(); - if (parentLayout == null) { - return; - } + if (parentLayout.fragmentsStack.size() >= 2) { BaseFragment fragment = parentLayout.fragmentsStack.get(parentLayout.fragmentsStack.size() - 2); if (fragment instanceof ChatActivity) { 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 2220dcafc..967ee1f8b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -10872,12 +10872,19 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate replyTextWidth = AndroidUtilities.dp(4 + (needReplyImage ? 44 : 0)); if (stringFinalText != null) { SpannableStringBuilder sb = new SpannableStringBuilder(stringFinalText); + boolean changed = false; for (TextStyleSpan span : sb.getSpans(0, sb.length(), TextStyleSpan.class)) { if ((span.getTextStyleRun().flags & TextStyleSpan.FLAG_STYLE_MONO) != 0) { + changed = true; sb.removeSpan(span); } } - replyTextLayout = new StaticLayout(sb, Theme.chat_replyTextPaint, maxWidth + AndroidUtilities.dp(10), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); + if (changed) { + stringFinalText = TextUtils.ellipsize(sb, Theme.chat_replyTextPaint, maxWidth, TextUtils.TruncateAt.END); + } else { + stringFinalText = sb; + } + replyTextLayout = new StaticLayout(stringFinalText, Theme.chat_replyTextPaint, maxWidth + AndroidUtilities.dp(10), Layout.Alignment.ALIGN_NORMAL, 1.0f, 0.0f, false); if (replyTextLayout.getLineCount() > 0) { replyTextWidth += (int) Math.ceil(replyTextLayout.getLineWidth(0)) + AndroidUtilities.dp(8); replyTextOffset = (int) replyTextLayout.getLineLeft(0); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java index a882f6789..a6942dceb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java @@ -201,6 +201,7 @@ public class ChatRightsEditActivity extends BaseFragment { adminRights.ban_users = myAdminRights.ban_users; adminRights.invite_users = myAdminRights.invite_users; adminRights.pin_messages = myAdminRights.pin_messages; + adminRights.other = myAdminRights.other; initialIsSet = false; } } else { @@ -216,10 +217,11 @@ public class ChatRightsEditActivity extends BaseFragment { adminRights.pin_messages = rightsAdmin.pin_messages; adminRights.add_admins = rightsAdmin.add_admins; adminRights.anonymous = rightsAdmin.anonymous; + adminRights.other = rightsAdmin.other; initialIsSet = adminRights.change_info || adminRights.post_messages || adminRights.edit_messages || adminRights.delete_messages || adminRights.ban_users || adminRights.invite_users || - adminRights.pin_messages || adminRights.add_admins || adminRights.manage_call || adminRights.anonymous; + adminRights.pin_messages || adminRights.add_admins || adminRights.manage_call || adminRights.anonymous || adminRights.other; if (type == TYPE_ADD_BOT) { asAdmin = isChannel || initialIsSet; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index 0beccebe2..2783a2590 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -3061,6 +3061,11 @@ public class AlertsCreator { int[] values = new int[]{ 0, + 30, + 60, + 60 * 2, + 60 * 3, + 60 * 8, 60 * 24, 2 * 60 * 24, 3 * 60 * 24, @@ -3084,14 +3089,18 @@ public class AlertsCreator { protected CharSequence getContentDescription(int index) { if (values[index] == 0) { return LocaleController.getString("MuteNever", R.string.MuteNever); + } else if (values[index] < 60) { + return LocaleController.formatPluralString("Minutes", values[index]); + } else if (values[index] < 60 * 24) { + return LocaleController.formatPluralString("Hours", values[index] / 60); } else if (values[index] < 7 * 60 * 24) { return LocaleController.formatPluralString("Days", values[index] / (60 * 24)); } else if (values[index] < 31 * 60 * 24) { - return LocaleController.formatPluralString("Weeks", values[index] / (60 * 24)); + return LocaleController.formatPluralString("Weeks", values[index] / (7 * 60 * 24)); } else if (values[index] < 365 * 60 * 24) { - return LocaleController.formatPluralString("Months", values[index] / (7 * 60 * 24)); + return LocaleController.formatPluralString("Months", values[index] / (31 * 60 * 24)); } else { - return LocaleController.formatPluralString("Years", values[index] * 5 / 31 * 60 * 24); + return LocaleController.formatPluralString("Years", values[index] / (365 * 60 * 24)); } } }; @@ -3102,6 +3111,10 @@ public class AlertsCreator { numberPicker.setFormatter(index -> { if (values[index] == 0) { return LocaleController.getString("MuteNever", R.string.MuteNever); + } else if (values[index] < 60) { + return LocaleController.formatPluralString("Minutes", values[index]); + } else if (values[index] < 60 * 24) { + return LocaleController.formatPluralString("Hours", values[index] / 60); } else if (values[index] < 7 * 60 * 24) { return LocaleController.formatPluralString("Days", values[index] / (60 * 24)); } else if (values[index] < 31 * 60 * 24) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewContainer.java index 9d835a017..430eb4781 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewContainer.java @@ -108,6 +108,8 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent private Activity parentActivity; + private boolean isViewPortByMeasureSuppressed; + public BotWebViewContainer(@NonNull Context context, Theme.ResourcesProvider resourcesProvider, int backgroundColor) { super(context); this.resourcesProvider = resourcesProvider; @@ -165,6 +167,10 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent setFocusable(false); } + public void setViewPortByMeasureSuppressed(boolean viewPortByMeasureSuppressed) { + isViewPortByMeasureSuppressed = viewPortByMeasureSuppressed; + } + private void checkCreateWebView() { if (webView == null && !webViewNotAvailable) { try { @@ -571,7 +577,9 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent @Override protected void onSizeChanged(int w, int h, int oldw, int oldh) { super.onSizeChanged(w, h, oldw, oldh); - invalidateViewPortHeight(true); + if (!isViewPortByMeasureSuppressed) { + invalidateViewPortHeight(true); + } } public void invalidateViewPortHeight() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index c11f445fb..44da40dfe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -3487,6 +3487,10 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific } } + public void forceSmoothKeyboard(boolean smoothKeyboard) { + this.smoothKeyboard = smoothKeyboard && SharedConfig.smoothKeyboard && !AndroidUtilities.isInMultiwindow && (parentFragment == null || !parentFragment.isInBubbleMode()); + } + protected void onLineCountChanged(int oldLineCount, int newLineCount) { } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java index c42a4fd14..b782d3e6a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlert.java @@ -136,6 +136,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N ChatAttachAlertBotWebViewLayout webViewLayout = new ChatAttachAlertBotWebViewLayout(this, getContext(), resourcesProvider); botAttachLayouts.put(id, webViewLayout); botAttachLayouts.get(id).setDelegate(new BotWebViewContainer.Delegate() { + private ValueAnimator botButtonAnimator; + @Override public void onCloseRequested(Runnable callback) { if (currentAttachLayout != webViewLayout) { @@ -173,8 +175,13 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N botMainButtonTextView.setTextColor(textColor); botMainButtonTextView.setBackground(BotWebViewContainer.getMainButtonRippleDrawable(color)); if (botButtonWasVisible != isVisible) { - ValueAnimator animator = ValueAnimator.ofFloat(isVisible ? 0 : 1, isVisible ? 1 : 0).setDuration(250); - animator.addUpdateListener(animation -> { + botButtonWasVisible = isVisible; + + if (botButtonAnimator != null) { + botButtonAnimator.cancel(); + } + botButtonAnimator = ValueAnimator.ofFloat(isVisible ? 0 : 1, isVisible ? 1 : 0).setDuration(250); + botButtonAnimator.addUpdateListener(animation -> { float value = (float) animation.getAnimatedValue(); buttonsRecyclerView.setAlpha(1f - value); botMainButtonTextView.setAlpha(value); @@ -182,7 +189,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N shadow.setTranslationY(botMainButtonOffsetY); buttonsRecyclerView.setTranslationY(botMainButtonOffsetY); }); - animator.addListener(new AnimatorListenerAdapter() { + botButtonAnimator.addListener(new AnimatorListenerAdapter() { @Override public void onAnimationStart(Animator animation) { if (isVisible) { @@ -201,7 +208,6 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N @Override public void onAnimationEnd(Animator animation) { - botButtonWasVisible = isVisible; if (!isVisible) { botMainButtonTextView.setVisibility(View.GONE); } else { @@ -212,9 +218,13 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N for (int i = 0; i < botAttachLayouts.size(); i++) { botAttachLayouts.valueAt(i).setMeasureOffsetY(offsetY); } + + if (botButtonAnimator == animation) { + botButtonAnimator = null; + } } }); - animator.start(); + botButtonAnimator.start(); } botProgressView.setProgressColor(textColor); if (botButtonProgressWasVisible != isProgressVisible) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java index 6e824bb31..dfe6a65d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java @@ -217,44 +217,58 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert return; } + webViewContainer.setViewPortByMeasureSuppressed(true); + + boolean doNotScroll = false; + float openOffset = -swipeContainer.getOffsetY() + swipeContainer.getTopActionBarOffsetY(); + if (swipeContainer.getSwipeOffsetY() != openOffset) { + swipeContainer.stickTo(openOffset); + doNotScroll = true; + } + int oldh = contentHeight + parentAlert.sizeNotifierFrameLayout.measureKeyboardHeight(); setMeasuredDimension(getMeasuredWidth(), contentHeight); ignoreMeasure = true; + swipeContainer.setSwipeOffsetAnimationDisallowed(true); - if (webViewScrollAnimator != null) { - webViewScrollAnimator.cancel(); - webViewScrollAnimator = null; - } + if (!doNotScroll) { + if (webViewScrollAnimator != null) { + webViewScrollAnimator.cancel(); + webViewScrollAnimator = null; + } - if (webViewContainer.getWebView() != null) { - int fromY = webViewContainer.getWebView().getScrollY(); - int toY = fromY + (oldh - contentHeight); - webViewScrollAnimator = ValueAnimator.ofInt(fromY, toY).setDuration(250); - webViewScrollAnimator.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR); - webViewScrollAnimator.addUpdateListener(animation -> { - int val = (int) animation.getAnimatedValue(); - if (webViewContainer.getWebView() != null) { - webViewContainer.getWebView().setScrollY(val); - } - }); - webViewScrollAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { + if (webViewContainer.getWebView() != null) { + int fromY = webViewContainer.getWebView().getScrollY(); + int toY = fromY + (oldh - contentHeight); + webViewScrollAnimator = ValueAnimator.ofInt(fromY, toY).setDuration(250); + webViewScrollAnimator.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR); + webViewScrollAnimator.addUpdateListener(animation -> { + int val = (int) animation.getAnimatedValue(); if (webViewContainer.getWebView() != null) { - webViewContainer.getWebView().setScrollY(toY); + webViewContainer.getWebView().setScrollY(val); } - if (animation == webViewScrollAnimator) { - webViewScrollAnimator = null; + }); + webViewScrollAnimator.addListener(new AnimatorListenerAdapter() { + @Override + public void onAnimationEnd(Animator animation) { + if (webViewContainer.getWebView() != null) { + webViewContainer.getWebView().setScrollY(toY); + } + if (animation == webViewScrollAnimator) { + webViewScrollAnimator = null; + } } - } - }); - webViewScrollAnimator.start(); + }); + webViewScrollAnimator.start(); + } } } @Override public void onPanTransitionEnd() { ignoreMeasure = false; + swipeContainer.setSwipeOffsetAnimationDisallowed(false); + webViewContainer.setViewPortByMeasureSuppressed(false); requestLayout(); } @@ -443,7 +457,7 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert @Override int getButtonsHideOffset() { - return AndroidUtilities.dp(56); + return (int) swipeContainer.getTopActionBarOffsetY() + AndroidUtilities.dp(12); } @Override @@ -510,9 +524,12 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert private float topActionBarOffsetY = ActionBar.getCurrentActionBarHeight(); private float offsetY = -1; + private float pendingOffsetY = -1; private float swipeOffsetY; private boolean isSwipeOffsetAnimationDisallowed; + private ValueAnimator offsetYAnimator; + private boolean flingInProgress; private WebView webView; @@ -655,18 +672,43 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert float wasOffsetY = this.offsetY; boolean wasOnTop = swipeOffsetY == -wasOffsetY + topActionBarOffsetY; if (wasOffsetY != -1 && !isSwipeOffsetAnimationDisallowed) { - ValueAnimator animator = ValueAnimator.ofFloat(wasOffsetY, offsetY).setDuration(200); - animator.setInterpolator(CubicBezierInterpolator.DEFAULT); - animator.addUpdateListener(animation -> { + offsetYAnimator = ValueAnimator.ofFloat(wasOffsetY, offsetY).setDuration(200); + offsetYAnimator.setInterpolator(CubicBezierInterpolator.DEFAULT); + offsetYAnimator.addUpdateListener(animation -> { this.offsetY = (float) animation.getAnimatedValue(); if (wasOnTop) { swipeOffsetY = -this.offsetY + topActionBarOffsetY; } else { swipeOffsetY = MathUtils.clamp(swipeOffsetY, -this.offsetY + topActionBarOffsetY, getHeight() - this.offsetY + topActionBarOffsetY); } + if (scrollAnimator != null && scrollAnimator.getSpring().getFinalPosition() == -wasOffsetY + topActionBarOffsetY) { + scrollAnimator.getSpring().setFinalPosition(-offsetY + topActionBarOffsetY); + } invalidateTranslation(); }); - animator.start(); + offsetYAnimator.addListener(new AnimatorListenerAdapter() { + private boolean isCanceled; + + @Override + public void onAnimationEnd(Animator animation) { + if (offsetYAnimator == animation) { + offsetYAnimator = null; + + if (!isCanceled) { + WebViewSwipeContainer.this.offsetY = offsetY; + invalidateTranslation(); + } else { + pendingOffsetY = offsetY; + } + } + } + + @Override + public void onAnimationCancel(Animator animation) { + isCanceled = true; + } + }); + offsetYAnimator.start(); } else { this.offsetY = offsetY; if (wasOnTop) { @@ -724,9 +766,13 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert flingInProgress = false; } else { if (swipeOffsetY <= -swipeStickyRange) { - stickTo(-offsetY + topActionBarOffsetY); + if (swipeOffsetY != -offsetY + topActionBarOffsetY) { + stickTo(-offsetY + topActionBarOffsetY); + } } else if (swipeOffsetY > -swipeStickyRange && swipeOffsetY <= swipeStickyRange) { - stickTo(0); + if (swipeOffsetY != 0) { + stickTo(0); + } } else { if (delegate != null) { delegate.onDismiss(); @@ -747,7 +793,7 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert } public void stickTo(float offset, Runnable callback) { - if (swipeOffsetY == offset) { + if (swipeOffsetY == offset || scrollAnimator != null && scrollAnimator.getSpring().getFinalPosition() == offset) { if (callback != null) { callback.run(); } @@ -757,6 +803,9 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert return; } + if (offsetYAnimator != null) { + offsetYAnimator.cancel(); + } if (scrollAnimator != null) { scrollAnimator.cancel(); } @@ -775,6 +824,14 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert if (scrollEndListener != null) { scrollEndListener.run(); } + + if (pendingOffsetY != -1) { + boolean wasDisallowed = isSwipeOffsetAnimationDisallowed; + isSwipeOffsetAnimationDisallowed = true; + setOffsetY(pendingOffsetY); + pendingOffsetY = -1; + isSwipeOffsetAnimationDisallowed = wasDisallowed; + } } }); scrollAnimator.start(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatScrimPopupContainerLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatScrimPopupContainerLayout.java index 71e39d830..1f1f5e552 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatScrimPopupContainerLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatScrimPopupContainerLayout.java @@ -40,6 +40,9 @@ public class ChatScrimPopupContainerLayout extends LinearLayout { if (popupWindowLayout.getSwipeBack() != null) { widthDiff = popupWindowLayout.getSwipeBack().getMeasuredWidth() - popupWindowLayout.getSwipeBack().getChildAt(0).getMeasuredWidth(); } + if (reactionsLayout.getLayoutParams().width != LayoutHelper.WRAP_CONTENT && reactionsLayout.getLayoutParams().width + widthDiff > getMeasuredWidth()) { + widthDiff = getMeasuredWidth() - reactionsLayout.getLayoutParams().width + AndroidUtilities.dp(8); + } ((LayoutParams) reactionsLayout.getLayoutParams()).rightMargin = widthDiff; if (bottomView != null) { if (popupWindowLayout.getSwipeBack() != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index d208f9e81..8ff366efa 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -303,6 +303,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. private RecyclerView sideMenu; private ChatActivityEnterView commentView; private View commentViewBg; + private final boolean commentViewAnimated = false; private ImageView[] writeButton; private FrameLayout writeButtonContainer; private View selectedCountView; @@ -781,13 +782,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } else { h = heightSize - inputFieldHeight + AndroidUtilities.dp(2) - (onlySelect ? 0 : actionBar.getMeasuredHeight()) - topPadding; } - int paddingBottom = 0; - if (keyboardSize > AndroidUtilities.dp(20)) { - h += (paddingBottom = inputFieldHeight + keyboardSize); - } - if (((ViewPage) child).listView != null) { - ((ViewPage) child).listView.setPadding(0, 0, 0, paddingBottom); - } if (filtersTabAnimator != null && filterTabsView != null && filterTabsView.getVisibility() == VISIBLE) { h += filterTabsMoveFrom; @@ -822,39 +816,10 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } } - private int previousHeight = -1; - private AnimatorSet keyboardAnimator; - @Override protected void onLayout(boolean changed, int l, int t, int r, int b) { final int count = getChildCount(); - int layoutHeight = b - t; - if (previousHeight != -1 && commentView != null) { - if (Math.abs(previousHeight - layoutHeight) > AndroidUtilities.dp(20)) { - if (keyboardAnimator != null) { - keyboardAnimator.cancel(); - } - keyboardAnimator = new AnimatorSet(); - ArrayList animators = new ArrayList<>(); - animators.add(ObjectAnimator.ofFloat(commentView, TRANSLATION_Y, previousHeight - layoutHeight, 0)); - if (commentViewBg != null) { - animators.add(ObjectAnimator.ofFloat(commentViewBg, TRANSLATION_Y, previousHeight - layoutHeight, 0)); - } - if (writeButtonContainer != null) { - animators.add(ObjectAnimator.ofFloat(writeButtonContainer, TRANSLATION_Y, previousHeight - layoutHeight, 0)); - } - if (selectedCountView != null) { - animators.add(ObjectAnimator.ofFloat(selectedCountView, TRANSLATION_Y, previousHeight - layoutHeight, 0)); - } - keyboardAnimator.playTogether(animators); - keyboardAnimator.setDuration(AdjustPanLayoutHelper.keyboardDuration); - keyboardAnimator.setInterpolator(AdjustPanLayoutHelper.keyboardInterpolator); - keyboardAnimator.start(); - } - } - previousHeight = layoutHeight; - int paddingBottom; Object tag = commentView != null ? commentView.getTag() : null; int keyboardSize = measureKeyboardHeight(); @@ -866,9 +831,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. setBottomClip(paddingBottom); lastMeasuredTopPadding = topPadding; - for (int i = 0; i < count; i++) { - final View child = getChildAt(i); - if (child.getVisibility() == GONE) { + for (int i = -1; i < count; i++) { + final View child = i == -1 ? commentView : getChildAt(i); + if (child == null || child.getVisibility() == GONE) { continue; } final FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) child.getLayoutParams(); @@ -943,6 +908,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. searchViewPager.setKeyboardHeight(keyboardSize); notifyHeightChanged(); updateContextViewPosition(); + updateCommentView(); } @Override @@ -3367,17 +3333,35 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. AndroidUtilities.requestAdjustResize(getParentActivity(), classGuid); } return super.dispatchTouchEvent(ev); + } + @Override + public void setTranslationY(float translationY) { + super.setTranslationY(translationY); + if (!commentViewAnimated) { + return; + } + if (commentViewBg != null) { + commentViewBg.setTranslationY(translationY); + } + if (writeButtonContainer != null) { + writeButtonContainer.setTranslationY(translationY); + } + if (selectedCountView != null) { + selectedCountView.setTranslationY(translationY); + } } }; + contentView.setClipChildren(false); + contentView.setClipToPadding(false); commentView.allowBlur = false; commentView.setAllowStickersAndGifs(false, false); commentView.setForceShowSendButton(true, false); commentView.setVisibility(View.GONE); commentView.getSendButton().setAlpha(0); - contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); commentViewBg = new View(getParentActivity()); commentViewBg.setBackgroundColor(getThemedColor(Theme.key_chat_messagePanelBackground)); contentView.addView(commentViewBg, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 1600, Gravity.BOTTOM | Gravity.FILL_HORIZONTAL, 0, 0, 0, -1600)); + contentView.addView(commentView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.LEFT | Gravity.BOTTOM)); commentView.setDelegate(new ChatActivityEnterView.ChatActivityEnterViewDelegate() { @Override public void onMessageSend(CharSequence message, boolean notify, int scheduleDate) { @@ -3397,6 +3381,20 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. } + @Override + public void bottomPanelTranslationYChanged(float translation) { + if (commentViewAnimated) { + if (keyboardAnimator != null) { + keyboardAnimator.cancel(); + keyboardAnimator = null; + } + if (commentView != null) { + commentView.setTranslationY(translation); + commentViewIgnoreTopUpdate = true; + } + } + } + @Override public void onStickersExpandedChange() { @@ -3797,6 +3795,35 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. return fragmentView; } + private int commentViewPreviousTop = -1; + private ValueAnimator keyboardAnimator; + private boolean commentViewIgnoreTopUpdate = false; + + private void updateCommentView() { + if (!commentViewAnimated || commentView == null) { + return; + } + int top = commentView.getTop(); + if (commentViewPreviousTop > 0 && Math.abs(top - commentViewPreviousTop) > AndroidUtilities.dp(20) && !commentView.isPopupShowing()) { + if (commentViewIgnoreTopUpdate) { + commentViewIgnoreTopUpdate = false; + commentViewPreviousTop = top; + return; + } + if (keyboardAnimator != null) { + keyboardAnimator.cancel(); + } + keyboardAnimator = ValueAnimator.ofFloat(commentViewPreviousTop - top, 0); + keyboardAnimator.addUpdateListener(a -> { + commentView.setTranslationY((float) a.getAnimatedValue()); + }); + keyboardAnimator.setDuration(AdjustPanLayoutHelper.keyboardDuration); + keyboardAnimator.setInterpolator(AdjustPanLayoutHelper.keyboardInterpolator); + keyboardAnimator.start(); + } + commentViewPreviousTop = top; + } + private void updateAppUpdateViews(boolean animated) { if (updateLayout == null) { return; @@ -7644,11 +7671,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. int[] location = new int[2]; view.getLocationInWindow(location); int y; -// if (keyboardVisible && parentFragment.contentView.getMeasuredHeight() > AndroidUtilities.dp(58)) { -// y = location[1] + view.getMeasuredHeight(); -// } else { y = location[1] - layout.getMeasuredHeight() - AndroidUtilities.dp(2); -// } sendPopupWindow.showAtLocation(view, Gravity.LEFT | Gravity.TOP, location[0] + view.getMeasuredWidth() - layout.getMeasuredWidth() + AndroidUtilities.dp(8), y); sendPopupWindow.dimBehind(); view.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java b/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java index 000b5611a..c07fb49a7 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DownloadProgressIcon.java @@ -73,6 +73,7 @@ public class DownloadProgressIcon extends View implements NotificationCenter.Not paint.setColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); paint2.setColor(Theme.getColor(Theme.key_actionBarDefaultIcon)); downloadImageReceiver.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultIcon), PorterDuff.Mode.MULTIPLY)); + downloadCompleteImageReceiver.setColorFilter(new PorterDuffColorFilter(Theme.getColor(Theme.key_actionBarDefaultIcon), PorterDuff.Mode.MULTIPLY)); paint2.setAlpha(100); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index f9f0e3f5a..09869e811 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -3037,7 +3037,7 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar MessagesController.getInstance(intentAccount).checkIsInChat(chat, user, (isInChatAlready, currentRights, currentRank) -> AndroidUtilities.runOnUIThread(() -> { TLRPC.TL_chatAdminRights requestingRights = null; if (botChatAdminParams != null) { - String[] adminParams = botChatAdminParams.split("\\+"); + String[] adminParams = botChatAdminParams.split("\\+| "); requestingRights = new TLRPC.TL_chatAdminRights(); final int count = adminParams.length; for (int i = 0; i < count; ++i) { @@ -3053,12 +3053,14 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar requestingRights.edit_messages = true; break; case "add_admins": + case "promote_members": requestingRights.add_admins = true; break; case "delete_messages": requestingRights.delete_messages = true; break; case "ban_users": + case "restrict_members": requestingRights.ban_users = true; break; case "invite_users": @@ -3067,9 +3069,13 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar case "pin_messages": requestingRights.pin_messages = true; break; + case "manage_video_chats": case "manage_call": requestingRights.manage_call = true; break; + case "manage_chat": + requestingRights.other = true; + break; case "anonymous": requestingRights.anonymous = true; break; @@ -3094,6 +3100,7 @@ public class LaunchActivity extends BasePermissionsActivity implements ActionBar editRights.pin_messages = requestingRights.pin_messages || editRights.pin_messages; editRights.manage_call = requestingRights.manage_call || editRights.manage_call; editRights.anonymous = requestingRights.anonymous || editRights.anonymous; + editRights.other = requestingRights.other || editRights.other; } } ChatRightsEditActivity editRightsActivity = new ChatRightsEditActivity(user.id, -did, editRights, null, null, currentRank, ChatRightsEditActivity.TYPE_ADD_BOT, true, !isInChatAlready, null);