mirror of
https://github.com/DrKLO/Telegram.git
synced 2024-12-22 14:35:03 +01:00
Update to 8.7.3
This commit is contained in:
parent
8283c12364
commit
136c9582a8
11 changed files with 278 additions and 120 deletions
|
@ -300,7 +300,7 @@ android {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
defaultConfig.versionCode = 2634
|
defaultConfig.versionCode = 2635
|
||||||
|
|
||||||
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.2"
|
versionName "8.7.3"
|
||||||
|
|
||||||
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
|
vectorDrawables.generatedDensities = ['mdpi', 'hdpi', 'xhdpi', 'xxhdpi']
|
||||||
|
|
||||||
|
|
|
@ -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 = 2634;
|
public static int BUILD_VERSION = 2635;
|
||||||
public static String BUILD_VERSION_STRING = "8.7.2";
|
public static String BUILD_VERSION_STRING = "8.7.3";
|
||||||
public static int APP_ID = 4;
|
public static int APP_ID = 4;
|
||||||
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";
|
||||||
|
|
||||||
|
|
|
@ -2679,7 +2679,7 @@ public class ImageLoader {
|
||||||
img.imageType = FileLoader.IMAGE_TYPE_LOTTIE;
|
img.imageType = FileLoader.IMAGE_TYPE_LOTTIE;
|
||||||
} else if ("application/x-tgwallpattern".equals(imageLocation.document.mime_type)) {
|
} else if ("application/x-tgwallpattern".equals(imageLocation.document.mime_type)) {
|
||||||
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
||||||
} else if (BuildVars.DEBUG_PRIVATE_VERSION) {
|
} else {
|
||||||
String name = FileLoader.getDocumentFileName(imageLocation.document);
|
String name = FileLoader.getDocumentFileName(imageLocation.document);
|
||||||
if (name.endsWith(".svg")) {
|
if (name.endsWith(".svg")) {
|
||||||
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
||||||
|
@ -2711,7 +2711,7 @@ public class ImageLoader {
|
||||||
img.imageType = FileLoader.IMAGE_TYPE_LOTTIE;
|
img.imageType = FileLoader.IMAGE_TYPE_LOTTIE;
|
||||||
} else if ("application/x-tgwallpattern".equals(document.mime_type)) {
|
} else if ("application/x-tgwallpattern".equals(document.mime_type)) {
|
||||||
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
||||||
} else if (BuildVars.DEBUG_PRIVATE_VERSION) {
|
} else {
|
||||||
String name = FileLoader.getDocumentFileName(imageLocation.document);
|
String name = FileLoader.getDocumentFileName(imageLocation.document);
|
||||||
if (name.endsWith(".svg")) {
|
if (name.endsWith(".svg")) {
|
||||||
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
img.imageType = FileLoader.IMAGE_TYPE_SVG;
|
||||||
|
|
|
@ -90,6 +90,7 @@ import org.telegram.messenger.BuildConfig;
|
||||||
import org.telegram.messenger.BuildVars;
|
import org.telegram.messenger.BuildVars;
|
||||||
import org.telegram.messenger.ChatObject;
|
import org.telegram.messenger.ChatObject;
|
||||||
import org.telegram.messenger.ContactsController;
|
import org.telegram.messenger.ContactsController;
|
||||||
|
import org.telegram.messenger.DownloadController;
|
||||||
import org.telegram.messenger.FileLoader;
|
import org.telegram.messenger.FileLoader;
|
||||||
import org.telegram.messenger.FileLog;
|
import org.telegram.messenger.FileLog;
|
||||||
import org.telegram.messenger.ImageLoader;
|
import org.telegram.messenger.ImageLoader;
|
||||||
|
@ -3407,15 +3408,62 @@ public class VoIPService extends Service implements SensorEventListener, AudioMa
|
||||||
req.peer = new TLRPC.TL_inputPhoneCall();
|
req.peer = new TLRPC.TL_inputPhoneCall();
|
||||||
req.peer.access_hash = privateCall.access_hash;
|
req.peer.access_hash = privateCall.access_hash;
|
||||||
req.peer.id = privateCall.id;
|
req.peer.id = privateCall.id;
|
||||||
|
|
||||||
|
File file = new File(VoIPHelper.getLogFilePath(privateCall.id, true));
|
||||||
|
String cachedFile = MediaController.copyFileToCache(Uri.fromFile(file), "log");
|
||||||
|
|
||||||
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
||||||
if (BuildVars.LOGS_ENABLED) {
|
if (BuildVars.LOGS_ENABLED) {
|
||||||
FileLog.d("Sent debug logs, response = " + response);
|
FileLog.d("Sent debug logs, response = " + response);
|
||||||
}
|
}
|
||||||
|
try {
|
||||||
|
if (response instanceof TLRPC.TL_boolFalse) {
|
||||||
|
AndroidUtilities.runOnUIThread(() -> {
|
||||||
|
uploadLogFile(cachedFile);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
File cacheFile = new File(cachedFile);
|
||||||
|
cacheFile.delete();
|
||||||
|
}
|
||||||
|
} catch (Exception e) {
|
||||||
|
FileLog.e(e);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
needSendDebugLog = false;
|
needSendDebugLog = false;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void uploadLogFile(String filePath) {
|
||||||
|
NotificationCenter.NotificationCenterDelegate uploadDelegate = new NotificationCenter.NotificationCenterDelegate() {
|
||||||
|
@Override
|
||||||
|
public void didReceivedNotification(int id, int account, Object... args) {
|
||||||
|
if (id == NotificationCenter.fileUploaded || id == NotificationCenter.fileUploadFailed) {
|
||||||
|
final String location = (String) args[0];
|
||||||
|
if (location.equals(filePath)) {
|
||||||
|
if (id == NotificationCenter.fileUploaded) {
|
||||||
|
TLRPC.TL_phone_saveCallLog req = new TLRPC.TL_phone_saveCallLog();
|
||||||
|
final TLRPC.InputFile file = (TLRPC.InputFile) args[1];
|
||||||
|
req.file = file;
|
||||||
|
req.peer = new TLRPC.TL_inputPhoneCall();
|
||||||
|
req.peer.access_hash = privateCall.access_hash;
|
||||||
|
req.peer.id = privateCall.id;
|
||||||
|
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {
|
||||||
|
if (BuildVars.LOGS_ENABLED) {
|
||||||
|
FileLog.d("Sent debug file log, response = " + response);
|
||||||
|
}
|
||||||
|
});
|
||||||
|
}
|
||||||
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileUploaded);
|
||||||
|
NotificationCenter.getInstance(currentAccount).removeObserver(this, NotificationCenter.fileUploadFailed);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
};
|
||||||
|
NotificationCenter.getInstance(currentAccount).addObserver(uploadDelegate, NotificationCenter.fileUploaded);
|
||||||
|
NotificationCenter.getInstance(currentAccount).addObserver(uploadDelegate, NotificationCenter.fileUploadFailed);
|
||||||
|
FileLoader.getInstance(currentAccount).uploadFile(filePath, false, true, ConnectionsManager.FileTypeFile);
|
||||||
|
}
|
||||||
|
|
||||||
private void initializeAccountRelatedThings() {
|
private void initializeAccountRelatedThings() {
|
||||||
updateServerConfig();
|
updateServerConfig();
|
||||||
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.appDidLogout);
|
NotificationCenter.getInstance(currentAccount).addObserver(this, NotificationCenter.appDidLogout);
|
||||||
|
|
|
@ -52484,6 +52484,23 @@ public class TLRPC {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static class TL_phone_saveCallLog extends TLObject {
|
||||||
|
public static int constructor = 0x41248786;
|
||||||
|
|
||||||
|
public TL_inputPhoneCall peer;
|
||||||
|
public InputFile file;
|
||||||
|
|
||||||
|
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
|
||||||
|
return Bool.TLdeserialize(stream, constructor, exception);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void serializeToStream(AbstractSerializedData stream) {
|
||||||
|
stream.writeInt32(constructor);
|
||||||
|
peer.serializeToStream(stream);
|
||||||
|
file.serializeToStream(stream);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public static class TL_phone_sendSignalingData extends TLObject {
|
public static class TL_phone_sendSignalingData extends TLObject {
|
||||||
public static int constructor = 0xff7a9383;
|
public static int constructor = 0xff7a9383;
|
||||||
|
|
||||||
|
|
|
@ -32,20 +32,16 @@ public class AttachBotIntroTopView extends View {
|
||||||
public AttachBotIntroTopView(Context context) {
|
public AttachBotIntroTopView(Context context) {
|
||||||
super(context);
|
super(context);
|
||||||
|
|
||||||
imageReceiver = new ImageReceiver(this) {
|
imageReceiver = new ImageReceiver(this);
|
||||||
@Override
|
|
||||||
protected boolean setImageBitmapByKey(Drawable drawable, String key, int type, boolean memCache, int guid) {
|
|
||||||
boolean set = super.setImageBitmapByKey(drawable, key, type, memCache, guid);
|
|
||||||
ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
|
|
||||||
anim.addUpdateListener(animation -> {
|
|
||||||
imageReceiver.setAlpha((Float) animation.getAnimatedValue());
|
|
||||||
invalidate();
|
|
||||||
});
|
|
||||||
anim.start();
|
|
||||||
return set;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
imageReceiver.setAlpha(0);
|
imageReceiver.setAlpha(0);
|
||||||
|
imageReceiver.setDelegate((imageReceiver1, set, thumb, memCache) -> {
|
||||||
|
ValueAnimator anim = ValueAnimator.ofFloat(0, 1).setDuration(150);
|
||||||
|
anim.addUpdateListener(animation -> {
|
||||||
|
imageReceiver.setAlpha((Float) animation.getAnimatedValue());
|
||||||
|
invalidate();
|
||||||
|
});
|
||||||
|
anim.start();
|
||||||
|
});
|
||||||
|
|
||||||
attachDrawable = ContextCompat.getDrawable(context, R.drawable.input_attach).mutate().getConstantState().newDrawable();
|
attachDrawable = ContextCompat.getDrawable(context, R.drawable.input_attach).mutate().getConstantState().newDrawable();
|
||||||
paint.setStyle(Paint.Style.STROKE);
|
paint.setStyle(Paint.Style.STROKE);
|
||||||
|
|
|
@ -171,9 +171,6 @@ 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));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -209,6 +206,7 @@ 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));
|
||||||
|
@ -366,38 +364,47 @@ 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 (webViewScrollAnimator != null) {
|
if (!doNotScroll) {
|
||||||
webViewScrollAnimator.cancel();
|
if (webViewScrollAnimator != null) {
|
||||||
webViewScrollAnimator = null;
|
webViewScrollAnimator.cancel();
|
||||||
}
|
webViewScrollAnimator = null;
|
||||||
|
}
|
||||||
|
|
||||||
if (webViewContainer.getWebView() != null) {
|
if (webViewContainer.getWebView() != null) {
|
||||||
int fromY = webViewContainer.getWebView().getScrollY();
|
int fromY = webViewContainer.getWebView().getScrollY();
|
||||||
int toY = fromY + (oldh - contentHeight);
|
int toY = fromY + (oldh - contentHeight);
|
||||||
webViewScrollAnimator = ValueAnimator.ofInt(fromY, toY).setDuration(250);
|
webViewScrollAnimator = ValueAnimator.ofInt(fromY, toY).setDuration(250);
|
||||||
webViewScrollAnimator.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR);
|
webViewScrollAnimator.setInterpolator(ChatListItemAnimator.DEFAULT_INTERPOLATOR);
|
||||||
webViewScrollAnimator.addUpdateListener(animation -> {
|
webViewScrollAnimator.addUpdateListener(animation -> {
|
||||||
int val = (int) animation.getAnimatedValue();
|
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) {
|
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();
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -22,6 +22,7 @@ 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;
|
||||||
|
@ -47,7 +48,20 @@ 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) -> {
|
||||||
|
@ -258,8 +272,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) * (1f - actionBarTransitionProgress);
|
float radius = AndroidUtilities.dp(16) * (AndroidUtilities.isTablet() ? 1f : 1f - actionBarTransitionProgress);
|
||||||
AndroidUtilities.rectTmp.set(0, AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), getWidth(), getHeight() + radius);
|
AndroidUtilities.rectTmp.set(swipeContainer.getLeft(), AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), swipeContainer.getRight(), getHeight() + radius);
|
||||||
canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, backgroundPaint);
|
canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, backgroundPaint);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -267,12 +281,14 @@ 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, actionBarTransitionProgress) / 0.5f)));
|
linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, transitionProgress) / 0.5f)));
|
||||||
|
|
||||||
canvas.save();
|
canvas.save();
|
||||||
float scale = 1f - actionBarTransitionProgress;
|
float scale = 1f - transitionProgress;
|
||||||
float y = AndroidUtilities.lerp(swipeContainer.getTranslationY(), AndroidUtilities.statusBarHeight + ActionBar.getCurrentActionBarHeight() / 2f, actionBarTransitionProgress) + AndroidUtilities.dp(12);
|
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));
|
||||||
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();
|
||||||
|
@ -286,7 +302,8 @@ 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;
|
||||||
}
|
}
|
||||||
|
@ -298,9 +315,17 @@ 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, 0, 24, 0, 0));
|
frameLayout.addView(swipeContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL, 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();
|
||||||
|
@ -310,7 +335,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));
|
frameLayout.addView(mainButton, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 48, Gravity.BOTTOM | Gravity.CENTER_HORIZONTAL));
|
||||||
mainButtonAutoAnimator = VerticalPositionAutoAnimator.attach(mainButton);
|
mainButtonAutoAnimator = VerticalPositionAutoAnimator.attach(mainButton);
|
||||||
|
|
||||||
radialProgressView = new RadialProgressView(context);
|
radialProgressView = new RadialProgressView(context);
|
||||||
|
@ -324,7 +349,15 @@ 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();
|
||||||
|
@ -337,9 +370,17 @@ 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));
|
frameLayout.addView(actionBar, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.TOP | Gravity.CENTER_HORIZONTAL));
|
||||||
|
|
||||||
frameLayout.addView(progressView = new ChatAttachAlertBotWebViewLayout.WebProgressView(context, resourcesProvider), LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.BOTTOM, 0, 0, 0, 0));
|
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));
|
||||||
webViewContainer.setWebViewProgressListener(progress -> {
|
webViewContainer.setWebViewProgressListener(progress -> {
|
||||||
progressView.setLoadProgressAnimated(progress);
|
progressView.setLoadProgressAnimated(progress);
|
||||||
if (progress == 1f) {
|
if (progress == 1f) {
|
||||||
|
@ -382,6 +423,7 @@ 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));
|
||||||
}
|
}
|
||||||
|
@ -402,7 +444,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 = ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f;
|
boolean lightStatusBar = !AndroidUtilities.isTablet() && ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f;
|
||||||
|
|
||||||
if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) {
|
if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) {
|
||||||
return;
|
return;
|
||||||
|
@ -487,7 +529,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void requestWebView(int currentAccount, long peerId, long botId, String buttonText, String buttonUrl, boolean simple, int replyToMsgId, boolean silent) {
|
public void requestWebView(int currentAccount, long peerId, long botId, String buttonText, String buttonUrl, @WebViewType int type, int replyToMsgId, boolean silent) {
|
||||||
this.currentAccount = currentAccount;
|
this.currentAccount = currentAccount;
|
||||||
this.peerId = peerId;
|
this.peerId = peerId;
|
||||||
this.botId = botId;
|
this.botId = botId;
|
||||||
|
@ -549,55 +591,88 @@ 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);
|
||||||
if (simple) {
|
switch (type) {
|
||||||
TLRPC.TL_messages_requestSimpleWebView req = new TLRPC.TL_messages_requestSimpleWebView();
|
case TYPE_BOT_MENU_BUTTON: {
|
||||||
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
|
TLRPC.TL_messages_requestWebView req = new TLRPC.TL_messages_requestWebView();
|
||||||
if (hasThemeParams) {
|
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botId);
|
||||||
req.theme_params = new TLRPC.TL_dataJSON();
|
req.peer = MessagesController.getInstance(currentAccount).getInputPeer(botId);
|
||||||
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.url = buttonUrl;
|
||||||
req.flags |= 2;
|
req.flags |= 2;
|
||||||
}
|
|
||||||
|
|
||||||
if (replyToMsgId != 0) {
|
if (hasThemeParams) {
|
||||||
req.reply_to_msg_id = replyToMsgId;
|
req.theme_params = new TLRPC.TL_dataJSON();
|
||||||
req.flags |= 1;
|
req.theme_params.data = themeParams;
|
||||||
}
|
req.flags |= 4;
|
||||||
|
|
||||||
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);
|
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;
|
||||||
|
}
|
||||||
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -3431,7 +3431,16 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific
|
||||||
private void openWebViewMenu() {
|
private void openWebViewMenu() {
|
||||||
Runnable onRequestWebView = () -> {
|
Runnable onRequestWebView = () -> {
|
||||||
AndroidUtilities.hideKeyboard(this);
|
AndroidUtilities.hideKeyboard(this);
|
||||||
botWebViewMenuContainer.show(currentAccount, dialog_id, botMenuWebViewUrl);
|
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);
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
if (SharedPrefsHelper.isWebViewConfirmShown(currentAccount, dialog_id)) {
|
if (SharedPrefsHelper.isWebViewConfirmShown(currentAccount, dialog_id)) {
|
||||||
|
@ -7069,7 +7078,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, replyMessageObject != null ? replyMessageObject.messageOwner.id : 0, false);
|
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.show();
|
webViewSheet.show();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
|
@ -71,7 +71,6 @@ import org.telegram.messenger.ChatObject;
|
||||||
import org.telegram.messenger.ContactsController;
|
import org.telegram.messenger.ContactsController;
|
||||||
import org.telegram.messenger.Emoji;
|
import org.telegram.messenger.Emoji;
|
||||||
import org.telegram.messenger.ImageLocation;
|
import org.telegram.messenger.ImageLocation;
|
||||||
import org.telegram.messenger.ImageReceiver;
|
|
||||||
import org.telegram.messenger.LocaleController;
|
import org.telegram.messenger.LocaleController;
|
||||||
import org.telegram.messenger.MediaController;
|
import org.telegram.messenger.MediaController;
|
||||||
import org.telegram.messenger.MediaDataController;
|
import org.telegram.messenger.MediaDataController;
|
||||||
|
@ -752,17 +751,14 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
|
||||||
|
|
||||||
imageView = new BackupImageView(context) {
|
imageView = new BackupImageView(context) {
|
||||||
{
|
{
|
||||||
imageReceiver = new ImageReceiver(this) {
|
imageReceiver.setDelegate((imageReceiver1, set, thumb, memCache) -> {
|
||||||
@Override
|
Drawable drawable = imageReceiver1.getDrawable();
|
||||||
protected boolean setImageBitmapByKey(Drawable drawable, String key, int type, boolean memCache, int guid) {
|
if (drawable instanceof RLottieDrawable) {
|
||||||
if (drawable instanceof RLottieDrawable) {
|
((RLottieDrawable) drawable).setCustomEndFrame(0);
|
||||||
((RLottieDrawable) drawable).setCustomEndFrame(0);
|
((RLottieDrawable) drawable).stop();
|
||||||
((RLottieDrawable) drawable).stop();
|
((RLottieDrawable) drawable).setProgress(0, false);
|
||||||
((RLottieDrawable) drawable).setProgress(0, false);
|
|
||||||
}
|
|
||||||
return super.setImageBitmapByKey(drawable, key, type, memCache, guid);
|
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -28,6 +28,7 @@ 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;
|
||||||
|
@ -164,6 +165,7 @@ 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));
|
||||||
|
@ -542,6 +544,8 @@ 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);
|
||||||
|
|
||||||
|
@ -574,7 +578,9 @@ 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 (Math.abs(distanceY) >= touchSlop && Math.abs(distanceY) * 1.5f >= Math.abs(distanceX) && (swipeOffsetY != -offsetY + topActionBarOffsetY || webView == null || distanceY < 0 && webView.getScrollY() == 0)) {
|
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)) {
|
||||||
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);
|
||||||
|
@ -622,6 +628,10 @@ 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);
|
||||||
|
@ -849,7 +859,7 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public final static class WebProgressView extends View {
|
public 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);
|
||||||
|
|
Loading…
Reference in a new issue