From 32aef72421378252f575e7dedaad9eafa7b6edec Mon Sep 17 00:00:00 2001 From: xaxtix Date: Thu, 28 Apr 2022 23:24:40 +0300 Subject: [PATCH] Update to 8.7.4 --- TMessagesProj/build.gradle | 4 +- .../org/telegram/messenger/BuildVars.java | 4 +- .../Components/BotWebViewMenuContainer.java | 61 +++--- .../ui/Components/BotWebViewSheet.java | 185 ++++++------------ .../ui/Components/ChatActivityEnterView.java | 13 +- .../ChatAttachAlertBotWebViewLayout.java | 14 +- 6 files changed, 90 insertions(+), 191 deletions(-) diff --git a/TMessagesProj/build.gradle b/TMessagesProj/build.gradle index b20fa134d..dfe51baa5 100644 --- a/TMessagesProj/build.gradle +++ b/TMessagesProj/build.gradle @@ -300,7 +300,7 @@ android { } } - defaultConfig.versionCode = 2635 + defaultConfig.versionCode = 2636 applicationVariants.all { variant -> variant.outputs.all { output -> @@ -319,7 +319,7 @@ android { defaultConfig { minSdkVersion 16 targetSdkVersion 30 - versionName "8.7.3" + versionName "8.7.4" vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java index ffd074517..719aab790 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/BuildVars.java @@ -20,8 +20,8 @@ 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 = 2635; - public static String BUILD_VERSION_STRING = "8.7.3"; + public static int BUILD_VERSION = 2636; + public static String BUILD_VERSION_STRING = "8.7.4"; public static int APP_ID = 4; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewMenuContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewMenuContainer.java index 9d5d2c8af..0ced05bc3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewMenuContainer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewMenuContainer.java @@ -171,6 +171,9 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification ignoreLayout = false; } + if (AndroidUtilities.isTablet() && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isSmallTablet()) { + widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f), MeasureSpec.EXACTLY); + } super.onMeasure(widthMeasureSpec, MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(heightMeasureSpec) - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.statusBarHeight + AndroidUtilities.dp(24) - AndroidUtilities.dp(5), MeasureSpec.EXACTLY)); } @@ -206,7 +209,6 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification swipeContainer.setDelegate(this::dismiss); swipeContainer.setTopActionBarOffsetY(ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight - AndroidUtilities.dp(24)); swipeContainer.setSwipeOffsetAnimationDisallowed(true); - swipeContainer.setIsKeyboardVisible(obj -> parentEnterView.getSizeNotifierLayout().getKeyboardHeight() >= AndroidUtilities.dp(20)); addView(swipeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP, 0, 24, 0, 0)); addView(progressView = new ChatAttachAlertBotWebViewLayout.WebProgressView(context, parentEnterView.getParentFragment().getResourceProvider()), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 5)); @@ -364,47 +366,38 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification return; } - boolean doNotScroll = false; - float openOffset = -swipeContainer.getOffsetY() + swipeContainer.getTopActionBarOffsetY(); - if (swipeContainer.getSwipeOffsetY() != openOffset) { - swipeContainer.stickTo(openOffset); - doNotScroll = true; - } - int oldh = contentHeight + parentEnterView.getSizeNotifierLayout().measureKeyboardHeight(); setMeasuredDimension(getMeasuredWidth(), contentHeight); ignoreMeasure = true; - if (!doNotScroll) { - if (webViewScrollAnimator != null) { - webViewScrollAnimator.cancel(); - webViewScrollAnimator = null; - } + 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) { + 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) { - webViewContainer.getWebView().setScrollY(val); + webViewContainer.getWebView().setScrollY(toY); } - }); - webViewScrollAnimator.addListener(new AnimatorListenerAdapter() { - @Override - public void onAnimationEnd(Animator animation) { - if (webViewContainer.getWebView() != null) { - webViewContainer.getWebView().setScrollY(toY); - } - if (animation == webViewScrollAnimator) { - webViewScrollAnimator = null; - } + if (animation == webViewScrollAnimator) { + webViewScrollAnimator = null; } - }); - webViewScrollAnimator.start(); - } + } + }); + webViewScrollAnimator.start(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java index 09c2c6273..89036c35b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BotWebViewSheet.java @@ -22,7 +22,6 @@ import android.view.Window; import android.view.WindowManager; import android.widget.TextView; -import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.core.content.ContextCompat; import androidx.core.graphics.ColorUtils; @@ -48,20 +47,7 @@ import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ChatActivity; import org.telegram.ui.LaunchActivity; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; - public class BotWebViewSheet extends Dialog implements NotificationCenter.NotificationCenterDelegate { - public final static int TYPE_WEB_VIEW_BUTTON = 0, TYPE_SIMPLE_WEB_VIEW_BUTTON = 1, TYPE_BOT_MENU_BUTTON = 2; - - @Retention(RetentionPolicy.SOURCE) - @IntDef(value = { - TYPE_WEB_VIEW_BUTTON, - TYPE_SIMPLE_WEB_VIEW_BUTTON, - TYPE_BOT_MENU_BUTTON - }) - public @interface WebViewType {} - private final static int POLL_PERIOD = 60000; private final static SimpleFloatPropertyCompat ACTION_BAR_TRANSITION_PROGRESS_VALUE = new SimpleFloatPropertyCompat("actionBarTransitionProgress", obj -> obj.actionBarTransitionProgress, (obj, value) -> { @@ -272,8 +258,8 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight()); canvas.drawRect(AndroidUtilities.rectTmp, dimPaint); - float radius = AndroidUtilities.dp(16) * (AndroidUtilities.isTablet() ? 1f : 1f - actionBarTransitionProgress); - AndroidUtilities.rectTmp.set(swipeContainer.getLeft(), AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), swipeContainer.getRight(), getHeight() + radius); + float radius = AndroidUtilities.dp(16) * (1f - actionBarTransitionProgress); + AndroidUtilities.rectTmp.set(0, AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), getWidth(), getHeight() + radius); canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, backgroundPaint); } @@ -281,14 +267,12 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi public void draw(Canvas canvas) { super.draw(canvas); - float transitionProgress = AndroidUtilities.isTablet() ? 0 : actionBarTransitionProgress; linePaint.setColor(Theme.getColor(Theme.key_dialogGrayLine)); - linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, transitionProgress) / 0.5f))); + linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, actionBarTransitionProgress) / 0.5f))); canvas.save(); - float scale = 1f - transitionProgress; - float y = AndroidUtilities.isTablet() ? AndroidUtilities.lerp(swipeContainer.getTranslationY() + AndroidUtilities.dp(12), AndroidUtilities.statusBarHeight / 2f, actionBarTransitionProgress) : - (AndroidUtilities.lerp(swipeContainer.getTranslationY(), AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight() / 2f, transitionProgress) + AndroidUtilities.dp(12)); + float scale = 1f - actionBarTransitionProgress; + float y = AndroidUtilities.lerp(swipeContainer.getTranslationY(), AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight() / 2f, actionBarTransitionProgress) + AndroidUtilities.dp(12); canvas.scale(scale, scale, getWidth() / 2f, y); canvas.drawLine(getWidth() / 2f - AndroidUtilities.dp(16), y, getWidth() / 2f + AndroidUtilities.dp(16), y, linePaint); canvas.restore(); @@ -302,8 +286,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi @SuppressLint("ClickableViewAccessibility") @Override public boolean onTouchEvent(MotionEvent event) { - if (event.getAction() == MotionEvent.ACTION_DOWN && (event.getY() <= AndroidUtilities.lerp(swipeContainer.getTranslationY() + AndroidUtilities.dp(24), 0, actionBarTransitionProgress) || - event.getX() > swipeContainer.getRight() || event.getX() < swipeContainer.getLeft())) { + if (event.getAction() == MotionEvent.ACTION_DOWN && event.getY() <= AndroidUtilities.lerp(swipeContainer.getTranslationY() + AndroidUtilities.dp(24), 0, actionBarTransitionProgress)) { dismiss(); return true; } @@ -315,17 +298,9 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi swipeContainer.stickTo(-swipeContainer.getOffsetY() + swipeContainer.getTopActionBarOffsetY()); } }); - frameLayout.addView(swipeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 0, 24, 0, 0)); + frameLayout.addView(swipeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP, 0, 24, 0, 0)); - mainButton = new TextView(context) { - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (AndroidUtilities.isTablet() && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isSmallTablet()) { - widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f), MeasureSpec.EXACTLY); - } - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - }; + mainButton = new TextView(context); mainButton.setVisibility(View.GONE); mainButton.setAlpha(0f); mainButton.setSingleLine(); @@ -335,7 +310,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi mainButton.setPadding(padding, 0, padding, 0); mainButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); mainButton.setOnClickListener(v -> webViewContainer.onMainButtonPressed()); - frameLayout.addView(mainButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL)); + frameLayout.addView(mainButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM)); mainButtonAutoAnimator = VerticalPositionAutoAnimator.attach(mainButton); radialProgressView = new RadialProgressView(context); @@ -349,15 +324,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi actionBarShadow = ContextCompat.getDrawable(getContext(), R.drawable.header_shadow).mutate(); - actionBar = new ActionBar(context, resourcesProvider) { - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (AndroidUtilities.isTablet() && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isSmallTablet()) { - widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f), MeasureSpec.EXACTLY); - } - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - }; + actionBar = new ActionBar(context, resourcesProvider); actionBar.setBackgroundColor(Color.TRANSPARENT); actionBar.setBackButtonImage(R.drawable.ic_ab_back); updateActionBarColors(); @@ -370,17 +337,9 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi } }); actionBar.setAlpha(0f); - frameLayout.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL)); + frameLayout.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP)); - frameLayout.addView(progressView = new ChatAttachAlertBotWebViewLayout.WebProgressView(context, resourcesProvider) { - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (AndroidUtilities.isTablet() && !AndroidUtilities.isInMultiwindow && !AndroidUtilities.isSmallTablet()) { - widthMeasureSpec = MeasureSpec.makeMeasureSpec((int) (Math.min(AndroidUtilities.displaySize.x, AndroidUtilities.displaySize.y) * 0.8f), MeasureSpec.EXACTLY); - } - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - }, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL, 0, 0, 0, 0)); + frameLayout.addView(progressView = new ChatAttachAlertBotWebViewLayout.WebProgressView(context, resourcesProvider), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 0)); webViewContainer.setWebViewProgressListener(progress -> { progressView.setLoadProgressAnimated(progress); if (progress == 1f) { @@ -423,7 +382,6 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi swipeContainer.setScrollEndListener(()-> webViewContainer.invalidateViewPortHeight(true)); swipeContainer.setDelegate(this::dismiss); swipeContainer.setTopActionBarOffsetY(ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight - AndroidUtilities.dp(24)); - swipeContainer.setIsKeyboardVisible(obj -> frameLayout.getKeyboardHeight() >= AndroidUtilities.dp(20)); setContentView(frameLayout, new ViewGroup.LayoutParams(ViewGroup.LayoutParams.MATCH_PARENT, ViewGroup.LayoutParams.MATCH_PARENT)); } @@ -444,7 +402,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi private void updateLightStatusBar() { int color = Theme.getColor(Theme.key_windowBackgroundWhite, null, true); - boolean lightStatusBar = !AndroidUtilities.isTablet() && ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f; + boolean lightStatusBar = ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f; if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) { return; @@ -529,7 +487,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi } } - public void requestWebView(int currentAccount, long peerId, long botId, String buttonText, String buttonUrl, @WebViewType int type, int replyToMsgId, boolean silent) { + public void requestWebView(int currentAccount, long peerId, long botId, String buttonText, String buttonUrl, boolean simple, int replyToMsgId, boolean silent) { this.currentAccount = currentAccount; this.peerId = peerId; this.botId = botId; @@ -591,88 +549,55 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi webViewContainer.setBotUser(MessagesController.getInstance(currentAccount).getUser(botId)); webViewContainer.loadFlicker(currentAccount, botId); - switch (type) { - case TYPE_BOT_MENU_BUTTON: { - TLRPC.TL_messages_requestWebView req = new TLRPC.TL_messages_requestWebView(); - req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); - req.peer = MessagesController.getInstance(currentAccount).getInputPeer(botId); + if (simple) { + TLRPC.TL_messages_requestSimpleWebView req = new TLRPC.TL_messages_requestSimpleWebView(); + req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); + if (hasThemeParams) { + req.theme_params = new TLRPC.TL_dataJSON(); + req.theme_params.data = themeParams; + req.flags |= 1; + } + req.url = buttonUrl; + ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(()->{ + if (response instanceof TLRPC.TL_simpleWebViewResultUrl) { + TLRPC.TL_simpleWebViewResultUrl resultUrl = (TLRPC.TL_simpleWebViewResultUrl) response; + queryId = 0; + webViewContainer.loadUrl(resultUrl.url); + swipeContainer.setWebView(webViewContainer.getWebView()); + } + })); + } else { + TLRPC.TL_messages_requestWebView req = new TLRPC.TL_messages_requestWebView(); + req.peer = MessagesController.getInstance(currentAccount).getInputPeer(peerId); + req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); + if (buttonUrl != null) { req.url = buttonUrl; req.flags |= 2; - - if (hasThemeParams) { - req.theme_params = new TLRPC.TL_dataJSON(); - req.theme_params.data = themeParams; - req.flags |= 4; - } - - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { - if (response instanceof TLRPC.TL_webViewResultUrl) { - TLRPC.TL_webViewResultUrl resultUrl = (TLRPC.TL_webViewResultUrl) response; - queryId = resultUrl.query_id; - webViewContainer.loadUrl(resultUrl.url); - swipeContainer.setWebView(webViewContainer.getWebView()); - - AndroidUtilities.runOnUIThread(pollRunnable, POLL_PERIOD); - } - })); - NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.webViewResultSent); - - break; } - case TYPE_SIMPLE_WEB_VIEW_BUTTON: { - TLRPC.TL_messages_requestSimpleWebView req = new TLRPC.TL_messages_requestSimpleWebView(); - req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); - if (hasThemeParams) { - req.theme_params = new TLRPC.TL_dataJSON(); - req.theme_params.data = themeParams; - req.flags |= 1; - } - req.url = buttonUrl; - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { - if (response instanceof TLRPC.TL_simpleWebViewResultUrl) { - TLRPC.TL_simpleWebViewResultUrl resultUrl = (TLRPC.TL_simpleWebViewResultUrl) response; - queryId = 0; - webViewContainer.loadUrl(resultUrl.url); - swipeContainer.setWebView(webViewContainer.getWebView()); - } - })); - break; + if (replyToMsgId != 0) { + req.reply_to_msg_id = replyToMsgId; + req.flags |= 1; } - case TYPE_WEB_VIEW_BUTTON: { - TLRPC.TL_messages_requestWebView req = new TLRPC.TL_messages_requestWebView(); - req.peer = MessagesController.getInstance(currentAccount).getInputPeer(peerId); - req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); - if (buttonUrl != null) { - req.url = buttonUrl; - req.flags |= 2; - } - if (replyToMsgId != 0) { - req.reply_to_msg_id = replyToMsgId; - req.flags |= 1; - } - - if (hasThemeParams) { - req.theme_params = new TLRPC.TL_dataJSON(); - req.theme_params.data = themeParams; - req.flags |= 4; - } - - ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { - if (response instanceof TLRPC.TL_webViewResultUrl) { - TLRPC.TL_webViewResultUrl resultUrl = (TLRPC.TL_webViewResultUrl) response; - queryId = resultUrl.query_id; - webViewContainer.loadUrl(resultUrl.url); - swipeContainer.setWebView(webViewContainer.getWebView()); - - AndroidUtilities.runOnUIThread(pollRunnable, POLL_PERIOD); - } - })); - NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.webViewResultSent); - break; + if (hasThemeParams) { + req.theme_params = new TLRPC.TL_dataJSON(); + req.theme_params.data = themeParams; + req.flags |= 4; } + + ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { + if (response instanceof TLRPC.TL_webViewResultUrl) { + TLRPC.TL_webViewResultUrl resultUrl = (TLRPC.TL_webViewResultUrl) response; + queryId = resultUrl.query_id; + webViewContainer.loadUrl(resultUrl.url); + swipeContainer.setWebView(webViewContainer.getWebView()); + + AndroidUtilities.runOnUIThread(pollRunnable, POLL_PERIOD); + } + })); + NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.webViewResultSent); } } 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 8882e0a40..44da40dfe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -3431,16 +3431,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific private void openWebViewMenu() { Runnable onRequestWebView = () -> { AndroidUtilities.hideKeyboard(this); - if (AndroidUtilities.isTablet()) { - BotWebViewSheet webViewSheet = new BotWebViewSheet(getContext(), parentFragment.getResourceProvider()); - webViewSheet.setParentActivity(parentActivity); - webViewSheet.requestWebView(currentAccount, dialog_id, dialog_id, botMenuWebViewTitle, botMenuWebViewUrl, BotWebViewSheet.TYPE_BOT_MENU_BUTTON, 0, false); - webViewSheet.show(); - - botCommandsMenuButton.setOpened(false); - } else { - botWebViewMenuContainer.show(currentAccount, dialog_id, botMenuWebViewUrl); - } + botWebViewMenuContainer.show(currentAccount, dialog_id, botMenuWebViewUrl); }; if (SharedPrefsHelper.isWebViewConfirmShown(currentAccount, dialog_id)) { @@ -7078,7 +7069,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific BotWebViewSheet webViewSheet = new BotWebViewSheet(getContext(), resourcesProvider); webViewSheet.setParentActivity(parentActivity); - webViewSheet.requestWebView(currentAccount, messageObject.messageOwner.dialog_id, botId, button.text, button.url, button instanceof TLRPC.TL_keyboardButtonSimpleWebView ? BotWebViewSheet.TYPE_SIMPLE_WEB_VIEW_BUTTON : BotWebViewSheet.TYPE_WEB_VIEW_BUTTON, replyMessageObject != null ? replyMessageObject.messageOwner.id : 0, false); + webViewSheet.requestWebView(currentAccount, messageObject.messageOwner.dialog_id, botId, button.text, button.url, button instanceof TLRPC.TL_keyboardButtonSimpleWebView, replyMessageObject != null ? replyMessageObject.messageOwner.id : 0, false); webViewSheet.show(); } }; 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 a8a63dc39..dfe6a65d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertBotWebViewLayout.java @@ -28,7 +28,6 @@ import androidx.recyclerview.widget.ChatListItemAnimator; import org.json.JSONObject; import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.FileLog; -import org.telegram.messenger.GenericProvider; import org.telegram.messenger.LocaleController; import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MessagesController; @@ -165,7 +164,6 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert }); swipeContainer.setScrollEndListener(()-> webViewContainer.invalidateViewPortHeight(true)); swipeContainer.setDelegate(() -> parentAlert.dismiss()); - swipeContainer.setIsKeyboardVisible(obj -> parentAlert.sizeNotifierFrameLayout.getKeyboardHeight() >= AndroidUtilities.dp(20)); addView(swipeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); addView(progressView = new WebProgressView(context, resourcesProvider), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 84)); @@ -544,8 +542,6 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert private int swipeStickyRange; - private GenericProvider isKeyboardVisible = obj -> false; - public WebViewSwipeContainer(@NonNull Context context) { super(context); @@ -578,9 +574,7 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert @Override public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { if (!isScrolling && !isSwipeDisallowed) { - if (isKeyboardVisible.provide(null) && swipeOffsetY == -offsetY + topActionBarOffsetY) { - isSwipeDisallowed = true; - } else if (Math.abs(distanceY) >= touchSlop && Math.abs(distanceY) * 1.5f >= Math.abs(distanceX) && (swipeOffsetY != -offsetY + topActionBarOffsetY || webView == null || distanceY < 0 && webView.getScrollY() == 0)) { + if (Math.abs(distanceY) >= touchSlop && Math.abs(distanceY) * 1.5f >= Math.abs(distanceX) && (swipeOffsetY != -offsetY + topActionBarOffsetY || webView == null || distanceY < 0 && webView.getScrollY() == 0)) { isScrolling = true; MotionEvent ev = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0); @@ -628,10 +622,6 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert updateStickyRange(); } - public void setIsKeyboardVisible(GenericProvider isKeyboardVisible) { - this.isKeyboardVisible = isKeyboardVisible; - } - @Override protected void onConfigurationChanged(Configuration newConfig) { super.onConfigurationChanged(newConfig); @@ -859,7 +849,7 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert } } - public static class WebProgressView extends View { + public final static class WebProgressView extends View { private final SimpleFloatPropertyCompat LOAD_PROGRESS_PROPERTY = new SimpleFloatPropertyCompat<>("loadProgress", obj -> obj.loadProgress, WebProgressView::setLoadProgress).setMultiplier(100f); private Paint bluePaint = new Paint(Paint.ANTI_ALIAS_FLAG);