Update to 8.7.4

This commit is contained in:
xaxtix 2022-04-28 23:24:40 +03:00
parent 136c9582a8
commit 32aef72421
6 changed files with 90 additions and 191 deletions

View file

@ -300,7 +300,7 @@ android {
} }
} }
defaultConfig.versionCode = 2635 defaultConfig.versionCode = 2636
applicationVariants.all { variant -> applicationVariants.all { variant ->
variant.outputs.all { output -> variant.outputs.all { output ->
@ -319,7 +319,7 @@ android {
defaultConfig { defaultConfig {
minSdkVersion 16 minSdkVersion 16
targetSdkVersion 30 targetSdkVersion 30
versionName "8.7.3" versionName "8.7.4"
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi'] vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']

View file

@ -20,8 +20,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true; public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true; public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29; public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 2635; public static int BUILD_VERSION = 2636;
public static String BUILD_VERSION_STRING = "8.7.3"; public static String BUILD_VERSION_STRING = "8.7.4";
public static int APP_ID = 4; public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103"; public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -171,6 +171,9 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
ignoreLayout = false; 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)); 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.setDelegate(this::dismiss);
swipeContainer.setTopActionBarOffsetY(ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight - AndroidUtilities.dp(24)); swipeContainer.setTopActionBarOffsetY(ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight - AndroidUtilities.dp(24));
swipeContainer.setSwipeOffsetAnimationDisallowed(true); 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(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)); addView(progressView = new ChatAttachAlertBotWebViewLayout.WebProgressView(context, parentEnterView.getParentFragment().getResourceProvider()), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 5));
@ -364,18 +366,10 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
return; 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(); int oldh = contentHeight + parentEnterView.getSizeNotifierLayout().measureKeyboardHeight();
setMeasuredDimension(getMeasuredWidth(), contentHeight); setMeasuredDimension(getMeasuredWidth(), contentHeight);
ignoreMeasure = true; ignoreMeasure = true;
if (!doNotScroll) {
if (webViewScrollAnimator != null) { if (webViewScrollAnimator != null) {
webViewScrollAnimator.cancel(); webViewScrollAnimator.cancel();
webViewScrollAnimator = null; webViewScrollAnimator = null;
@ -406,7 +400,6 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
webViewScrollAnimator.start(); webViewScrollAnimator.start();
} }
} }
}
public void onPanTransitionEnd() { public void onPanTransitionEnd() {
ignoreMeasure = false; ignoreMeasure = false;

View file

@ -22,7 +22,6 @@ import android.view.Window;
import android.view.WindowManager; import android.view.WindowManager;
import android.widget.TextView; import android.widget.TextView;
import androidx.annotation.IntDef;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat; import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
@ -48,20 +47,7 @@ import org.telegram.ui.ActionBar.Theme;
import org.telegram.ui.ChatActivity; import org.telegram.ui.ChatActivity;
import org.telegram.ui.LaunchActivity; import org.telegram.ui.LaunchActivity;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
public class BotWebViewSheet extends Dialog implements NotificationCenter.NotificationCenterDelegate { 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 int POLL_PERIOD = 60000;
private final static SimpleFloatPropertyCompat<BotWebViewSheet> ACTION_BAR_TRANSITION_PROGRESS_VALUE = new SimpleFloatPropertyCompat<BotWebViewSheet>("actionBarTransitionProgress", obj -> obj.actionBarTransitionProgress, (obj, value) -> { private final static SimpleFloatPropertyCompat<BotWebViewSheet> ACTION_BAR_TRANSITION_PROGRESS_VALUE = new SimpleFloatPropertyCompat<BotWebViewSheet>("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()); AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight());
canvas.drawRect(AndroidUtilities.rectTmp, dimPaint); canvas.drawRect(AndroidUtilities.rectTmp, dimPaint);
float radius = AndroidUtilities.dp(16) * (AndroidUtilities.isTablet() ? 1f : 1f - actionBarTransitionProgress); float radius = AndroidUtilities.dp(16) * (1f - actionBarTransitionProgress);
AndroidUtilities.rectTmp.set(swipeContainer.getLeft(), AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), swipeContainer.getRight(), getHeight() + radius); AndroidUtilities.rectTmp.set(0, AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), getWidth(), getHeight() + radius);
canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, backgroundPaint); canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, backgroundPaint);
} }
@ -281,14 +267,12 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
super.draw(canvas); super.draw(canvas);
float transitionProgress = AndroidUtilities.isTablet() ? 0 : actionBarTransitionProgress;
linePaint.setColor(Theme.getColor(Theme.key_dialogGrayLine)); 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(); canvas.save();
float scale = 1f - transitionProgress; float scale = 1f - actionBarTransitionProgress;
float y = AndroidUtilities.isTablet() ? AndroidUtilities.lerp(swipeContainer.getTranslationY() + AndroidUtilities.dp(12), AndroidUtilities.statusBarHeight / 2f, actionBarTransitionProgress) : float y = AndroidUtilities.lerp(swipeContainer.getTranslationY(), AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight() / 2f, actionBarTransitionProgress) + AndroidUtilities.dp(12);
(AndroidUtilities.lerp(swipeContainer.getTranslationY(), AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight() / 2f, transitionProgress) + AndroidUtilities.dp(12));
canvas.scale(scale, scale, getWidth() / 2f, y); canvas.scale(scale, scale, getWidth() / 2f, y);
canvas.drawLine(getWidth() / 2f - AndroidUtilities.dp(16), y, getWidth() / 2f + AndroidUtilities.dp(16), y, linePaint); canvas.drawLine(getWidth() / 2f - AndroidUtilities.dp(16), y, getWidth() / 2f + AndroidUtilities.dp(16), y, linePaint);
canvas.restore(); canvas.restore();
@ -302,8 +286,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
if (event.getAction() == MotionEvent.ACTION_DOWN && (event.getY() <= AndroidUtilities.lerp(swipeContainer.getTranslationY() + AndroidUtilities.dp(24), 0, actionBarTransitionProgress) || 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())) {
dismiss(); dismiss();
return true; return true;
} }
@ -315,17 +298,9 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
swipeContainer.stickTo(-swipeContainer.getOffsetY() + swipeContainer.getTopActionBarOffsetY()); 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) { 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.setVisibility(View.GONE); mainButton.setVisibility(View.GONE);
mainButton.setAlpha(0f); mainButton.setAlpha(0f);
mainButton.setSingleLine(); mainButton.setSingleLine();
@ -335,7 +310,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
mainButton.setPadding(padding, 0, padding, 0); mainButton.setPadding(padding, 0, padding, 0);
mainButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); mainButton.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14);
mainButton.setOnClickListener(v -> webViewContainer.onMainButtonPressed()); 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); mainButtonAutoAnimator = VerticalPositionAutoAnimator.attach(mainButton);
radialProgressView = new RadialProgressView(context); 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(); actionBarShadow = ContextCompat.getDrawable(getContext(), R.drawable.header_shadow).mutate();
actionBar = new ActionBar(context, resourcesProvider) { 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.setBackgroundColor(Color.TRANSPARENT); actionBar.setBackgroundColor(Color.TRANSPARENT);
actionBar.setBackButtonImage(R.drawable.ic_ab_back); actionBar.setBackButtonImage(R.drawable.ic_ab_back);
updateActionBarColors(); updateActionBarColors();
@ -370,17 +337,9 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
} }
}); });
actionBar.setAlpha(0f); 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) { frameLayout.addView(progressView = new ChatAttachAlertBotWebViewLayout.WebProgressView(context, resourcesProvider), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 0));
@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));
webViewContainer.setWebViewProgressListener(progress -> { webViewContainer.setWebViewProgressListener(progress -> {
progressView.setLoadProgressAnimated(progress); progressView.setLoadProgressAnimated(progress);
if (progress == 1f) { if (progress == 1f) {
@ -423,7 +382,6 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
swipeContainer.setScrollEndListener(()-> webViewContainer.invalidateViewPortHeight(true)); swipeContainer.setScrollEndListener(()-> webViewContainer.invalidateViewPortHeight(true));
swipeContainer.setDelegate(this::dismiss); swipeContainer.setDelegate(this::dismiss);
swipeContainer.setTopActionBarOffsetY(ActionBar.getCurrentActionBarHeight() + AndroidUtilities.statusBarHeight - AndroidUtilities.dp(24)); 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)); 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() { private void updateLightStatusBar() {
int color = Theme.getColor(Theme.key_windowBackgroundWhite, null, true); 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) { if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) {
return; 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.currentAccount = currentAccount;
this.peerId = peerId; this.peerId = peerId;
this.botId = botId; this.botId = botId;
@ -591,36 +549,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
webViewContainer.setBotUser(MessagesController.getInstance(currentAccount).getUser(botId)); webViewContainer.setBotUser(MessagesController.getInstance(currentAccount).getUser(botId));
webViewContainer.loadFlicker(currentAccount, botId); webViewContainer.loadFlicker(currentAccount, botId);
switch (type) { if (simple) {
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);
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(); TLRPC.TL_messages_requestSimpleWebView req = new TLRPC.TL_messages_requestSimpleWebView();
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
if (hasThemeParams) { if (hasThemeParams) {
@ -638,9 +567,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
swipeContainer.setWebView(webViewContainer.getWebView()); swipeContainer.setWebView(webViewContainer.getWebView());
} }
})); }));
break; } else {
}
case TYPE_WEB_VIEW_BUTTON: {
TLRPC.TL_messages_requestWebView req = new TLRPC.TL_messages_requestWebView(); TLRPC.TL_messages_requestWebView req = new TLRPC.TL_messages_requestWebView();
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(peerId); req.peer = MessagesController.getInstance(currentAccount).getInputPeer(peerId);
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId); req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
@ -671,8 +598,6 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
} }
})); }));
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.webViewResultSent); NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.webViewResultSent);
break;
}
} }
} }

View file

@ -3431,16 +3431,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
private void openWebViewMenu() { private void openWebViewMenu() {
Runnable onRequestWebView = () -> { Runnable onRequestWebView = () -> {
AndroidUtilities.hideKeyboard(this); 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)) { if (SharedPrefsHelper.isWebViewConfirmShown(currentAccount, dialog_id)) {
@ -7078,7 +7069,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
BotWebViewSheet webViewSheet = new BotWebViewSheet(getContext(), resourcesProvider); BotWebViewSheet webViewSheet = new BotWebViewSheet(getContext(), resourcesProvider);
webViewSheet.setParentActivity(parentActivity); 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(); webViewSheet.show();
} }
}; };

View file

@ -28,7 +28,6 @@ import androidx.recyclerview.widget.ChatListItemAnimator;
import org.json.JSONObject; import org.json.JSONObject;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.GenericProvider;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
@ -165,7 +164,6 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
}); });
swipeContainer.setScrollEndListener(()-> webViewContainer.invalidateViewPortHeight(true)); swipeContainer.setScrollEndListener(()-> webViewContainer.invalidateViewPortHeight(true));
swipeContainer.setDelegate(() -> parentAlert.dismiss()); swipeContainer.setDelegate(() -> parentAlert.dismiss());
swipeContainer.setIsKeyboardVisible(obj -> parentAlert.sizeNotifierFrameLayout.getKeyboardHeight() >= AndroidUtilities.dp(20));
addView(swipeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT)); 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)); 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 int swipeStickyRange;
private GenericProvider<Void, Boolean> isKeyboardVisible = obj -> false;
public WebViewSwipeContainer(@NonNull Context context) { public WebViewSwipeContainer(@NonNull Context context) {
super(context); super(context);
@ -578,9 +574,7 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
@Override @Override
public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) { public boolean onScroll(MotionEvent e1, MotionEvent e2, float distanceX, float distanceY) {
if (!isScrolling && !isSwipeDisallowed) { if (!isScrolling && !isSwipeDisallowed) {
if (isKeyboardVisible.provide(null) && swipeOffsetY == -offsetY + topActionBarOffsetY) { if (Math.abs(distanceY) >= touchSlop && Math.abs(distanceY) * 1.5f >= Math.abs(distanceX) && (swipeOffsetY != -offsetY + topActionBarOffsetY || webView == null || distanceY < 0 && webView.getScrollY() == 0)) {
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)) {
isScrolling = true; isScrolling = true;
MotionEvent ev = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0); MotionEvent ev = MotionEvent.obtain(0, 0, MotionEvent.ACTION_CANCEL, 0, 0, 0);
@ -628,10 +622,6 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
updateStickyRange(); updateStickyRange();
} }
public void setIsKeyboardVisible(GenericProvider<Void, Boolean> isKeyboardVisible) {
this.isKeyboardVisible = isKeyboardVisible;
}
@Override @Override
protected void onConfigurationChanged(Configuration newConfig) { protected void onConfigurationChanged(Configuration newConfig) {
super.onConfigurationChanged(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<WebProgressView> LOAD_PROGRESS_PROPERTY = new SimpleFloatPropertyCompat<>("loadProgress", obj -> obj.loadProgress, WebProgressView::setLoadProgress).setMultiplier(100f); private final SimpleFloatPropertyCompat<WebProgressView> LOAD_PROGRESS_PROPERTY = new SimpleFloatPropertyCompat<>("loadProgress", obj -> obj.loadProgress, WebProgressView::setLoadProgress).setMultiplier(100f);
private Paint bluePaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint bluePaint = new Paint(Paint.ANTI_ALIAS_FLAG);