update to 10.0.5 (3804)

This commit is contained in:
xaxtix 2023-09-06 18:30:04 +04:00
parent 534f9f6c6e
commit 36067f8b38
15 changed files with 386 additions and 48 deletions

View file

@ -101,6 +101,7 @@ public class BillingController implements PurchasesUpdatedListener, BillingClien
@SuppressWarnings("ConstantConditions") @SuppressWarnings("ConstantConditions")
public int getCurrencyExp(String currency) { public int getCurrencyExp(String currency) {
BillingUtilities.extractCurrencyExp(currencyExpMap);
return currencyExpMap.getOrDefault(currency, 0); return currencyExpMap.getOrDefault(currency, 0);
} }

View file

@ -24,8 +24,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 = 3802; public static int BUILD_VERSION = 3804;
public static String BUILD_VERSION_STRING = "10.0.4"; public static String BUILD_VERSION_STRING = "10.0.5";
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

@ -53,6 +53,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
List<ImageReceiver> preloadReceivers; List<ImageReceiver> preloadReceivers;
private boolean allowCrossfadeWithImage = true; private boolean allowCrossfadeWithImage = true;
private boolean allowDrawWhileCacheGenerating;
public boolean updateThumbShaderMatrix() { public boolean updateThumbShaderMatrix() {
if (currentThumbDrawable != null && thumbShader != null) { if (currentThumbDrawable != null && thumbShader != null) {
@ -84,6 +85,10 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
setStaticDrawable(new BitmapDrawable(bitmap)); setStaticDrawable(new BitmapDrawable(bitmap));
} }
public void setAllowDrawWhileCacheGenerating(boolean allow) {
allowDrawWhileCacheGenerating = allow;
}
public interface ImageReceiverDelegate { public interface ImageReceiverDelegate {
void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb, boolean memCache); void didSetImage(ImageReceiver imageReceiver, boolean set, boolean thumb, boolean memCache);
@ -2249,7 +2254,11 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
} }
public boolean hasNotThumb() { public boolean hasNotThumb() {
return currentImageDrawable != null || currentMediaDrawable != null || staticThumbDrawable instanceof VectorAvatarThumbDrawable || (staticThumbDrawable != null && currentImageKey == null && currentMediaKey == null); return currentImageDrawable != null || currentMediaDrawable != null || staticThumbDrawable instanceof VectorAvatarThumbDrawable;
}
public boolean hasNotThumbOrOnlyStaticThumb() {
return currentImageDrawable != null || currentMediaDrawable != null || staticThumbDrawable instanceof VectorAvatarThumbDrawable || (staticThumbDrawable != null && !(staticThumbDrawable instanceof AvatarDrawable) && currentImageKey == null && currentMediaKey == null);
} }
public boolean hasStaticThumb() { public boolean hasStaticThumb() {
@ -2824,6 +2833,7 @@ public class ImageReceiver implements NotificationCenter.NotificationCenterDeleg
fileDrawable.setAutoRepeat(autoRepeat); fileDrawable.setAutoRepeat(autoRepeat);
fileDrawable.setAutoRepeatCount(autoRepeatCount); fileDrawable.setAutoRepeatCount(autoRepeatCount);
fileDrawable.setAutoRepeatTimeout(autoRepeatTimeout); fileDrawable.setAutoRepeatTimeout(autoRepeatTimeout);
fileDrawable.setAllowDrawFramesWhileCacheGenerating(allowDrawWhileCacheGenerating);
animationReadySent = false; animationReadySent = false;
} }
invalidate(); invalidate();

View file

@ -3823,7 +3823,9 @@ public class MessageObject {
} else if (messageOwner.action instanceof TLRPC.TL_messageActionBotAllowed) { } else if (messageOwner.action instanceof TLRPC.TL_messageActionBotAllowed) {
String domain = ((TLRPC.TL_messageActionBotAllowed) messageOwner.action).domain; String domain = ((TLRPC.TL_messageActionBotAllowed) messageOwner.action).domain;
TLRPC.BotApp botApp = ((TLRPC.TL_messageActionBotAllowed) messageOwner.action).app; TLRPC.BotApp botApp = ((TLRPC.TL_messageActionBotAllowed) messageOwner.action).app;
if (botApp != null) { if (((TLRPC.TL_messageActionBotAllowed) messageOwner.action).from_request) {
messageText = LocaleController.getString(R.string.ActionBotAllowedWebapp);
} else if (botApp != null) {
String botAppTitle = botApp.title; String botAppTitle = botApp.title;
String text = LocaleController.getString("ActionBotAllowedApp", R.string.ActionBotAllowedApp); String text = LocaleController.getString("ActionBotAllowedApp", R.string.ActionBotAllowedApp);
int start = text.indexOf("%1$s"); int start = text.indexOf("%1$s");

View file

@ -74,7 +74,7 @@ public class TLRPC {
public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800; public static final int MESSAGE_FLAG_HAS_BOT_ID = 0x00000800;
public static final int MESSAGE_FLAG_EDITED = 0x00008000; public static final int MESSAGE_FLAG_EDITED = 0x00008000;
public static final int LAYER = 161; public static final int LAYER = 162;
public static class TL_stats_megagroupStats extends TLObject { public static class TL_stats_megagroupStats extends TLObject {
public static int constructor = 0xef7ff916; public static int constructor = 0xef7ff916;
@ -26688,12 +26688,14 @@ public class TLRPC {
public static int constructor = 0xc516d679; public static int constructor = 0xc516d679;
public boolean attach_menu; public boolean attach_menu;
public boolean from_request;
public String domain; public String domain;
public BotApp app; public BotApp app;
public void readParams(AbstractSerializedData stream, boolean exception) { public void readParams(AbstractSerializedData stream, boolean exception) {
flags = stream.readInt32(exception); flags = stream.readInt32(exception);
attach_menu = (flags & 2) != 0; attach_menu = (flags & 2) != 0;
from_request = (flags & 8) != 0;
if ((flags & 1) != 0) { if ((flags & 1) != 0) {
domain = stream.readString(exception); domain = stream.readString(exception);
} }
@ -26705,6 +26707,7 @@ public class TLRPC {
public void serializeToStream(AbstractSerializedData stream) { public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor); stream.writeInt32(constructor);
flags = attach_menu ? (flags | 2) : (flags &~ 2); flags = attach_menu ? (flags | 2) : (flags &~ 2);
flags = from_request ? (flags | 8) : (flags &~ 8);
stream.writeInt32(flags); stream.writeInt32(flags);
if ((flags & 1) != 0) { if ((flags & 1) != 0) {
stream.writeString(domain); stream.writeString(domain);
@ -71082,6 +71085,56 @@ public class TLRPC {
reaction.serializeToStream(stream); reaction.serializeToStream(stream);
} }
} }
public static class TL_bots_canSendMessage extends TLObject {
public static int constructor = 0x1359f4e6;
public InputUser bot;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Bool.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
bot.serializeToStream(stream);
}
}
public static class TL_bots_allowSendMessage extends TLObject {
public static int constructor = 0xf132e3ef;
public InputUser bot;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return Updates.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
bot.serializeToStream(stream);
}
}
public static class TL_bots_invokeWebViewCustomMethod extends TLObject {
public static int constructor = 0x87fc5e7;
public InputUser bot;
public String custom_method;
public TL_dataJSON params;
public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) {
return TL_dataJSON.TLdeserialize(stream, constructor, exception);
}
public void serializeToStream(AbstractSerializedData stream) {
stream.writeInt32(constructor);
bot.serializeToStream(stream);
stream.writeString(custom_method);
params.serializeToStream(stream);
}
}
//functions //functions
public static class Vector extends TLObject { public static class Vector extends TLObject {

View file

@ -993,7 +993,7 @@ public final class FloatingToolbar {
final boolean premiumLocked = MessagesController.getInstance(UserConfig.selectedAccount).premiumLocked; final boolean premiumLocked = MessagesController.getInstance(UserConfig.selectedAccount).premiumLocked;
for (int i = 0; i < size; i++) { for (int i = 0; i < size; i++) {
final MenuItem menuItem = menuItems.get(i); final MenuItem menuItem = menuItems.get(i);
if (!premiumOptions.contains(menuItem.getItemId()) || !premiumLocked) { if (premiumLockClickListener == null || premiumLocked && !premiumOptions.contains(menuItem.getItemId())) {
overflowPanelAdapter.add(menuItem); overflowPanelAdapter.add(menuItem);
} }
} }

View file

@ -21,8 +21,8 @@ import android.graphics.drawable.Drawable;
import android.net.Uri; import android.net.Uri;
import android.os.Build; import android.os.Build;
import android.os.Message; import android.os.Message;
import android.text.SpannableStringBuilder;
import android.text.TextUtils; import android.text.TextUtils;
import android.util.Log;
import android.util.TypedValue; import android.util.TypedValue;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.MotionEvent;
@ -33,7 +33,6 @@ import android.webkit.JavascriptInterface;
import android.webkit.PermissionRequest; import android.webkit.PermissionRequest;
import android.webkit.ValueCallback; import android.webkit.ValueCallback;
import android.webkit.WebChromeClient; import android.webkit.WebChromeClient;
import android.webkit.WebResourceRequest;
import android.webkit.WebSettings; import android.webkit.WebSettings;
import android.webkit.WebView; import android.webkit.WebView;
import android.webkit.WebViewClient; import android.webkit.WebViewClient;
@ -49,17 +48,22 @@ import androidx.core.util.Consumer;
import org.json.JSONArray; import org.json.JSONArray;
import org.json.JSONException; import org.json.JSONException;
import org.json.JSONObject; import org.json.JSONObject;
import org.json.JSONTokener;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AndroidUtilities; import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader; import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BotWebViewVibrationEffect; import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.FileLog; import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation; import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver; import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController; import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController; import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController; import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R; import org.telegram.messenger.R;
import org.telegram.messenger.SendMessagesHelper;
import org.telegram.messenger.SvgHelper; import org.telegram.messenger.SvgHelper;
import org.telegram.messenger.UserConfig; import org.telegram.messenger.UserConfig;
import org.telegram.messenger.UserObject; import org.telegram.messenger.UserObject;
@ -88,7 +92,6 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
private final static String DURGER_KING_USERNAME = "DurgerKingBot"; private final static String DURGER_KING_USERNAME = "DurgerKingBot";
private final static int REQUEST_CODE_WEB_VIEW_FILE = 3000, REQUEST_CODE_WEB_PERMISSION = 4000, REQUEST_CODE_QR_CAMERA_PERMISSION = 5000; private final static int REQUEST_CODE_WEB_VIEW_FILE = 3000, REQUEST_CODE_WEB_PERMISSION = 4000, REQUEST_CODE_QR_CAMERA_PERMISSION = 5000;
private final static int DIALOG_SEQUENTIAL_COOLDOWN_TIME = 3000; private final static int DIALOG_SEQUENTIAL_COOLDOWN_TIME = 3000;
private final static boolean ENABLE_REQUEST_PHONE = false;
private final static List<String> WHITELISTED_SCHEMES = Arrays.asList("http", "https"); private final static List<String> WHITELISTED_SCHEMES = Arrays.asList("http", "https");
@ -466,6 +469,30 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
break; break;
} }
} }
} else if (
resources.length == 2 &&
(PermissionRequest.RESOURCE_AUDIO_CAPTURE.equals(resources[0]) || PermissionRequest.RESOURCE_VIDEO_CAPTURE.equals(resources[0])) &&
(PermissionRequest.RESOURCE_AUDIO_CAPTURE.equals(resources[1]) || PermissionRequest.RESOURCE_VIDEO_CAPTURE.equals(resources[1]))
) {
lastPermissionsDialog = AlertsCreator.createWebViewPermissionsRequestDialog(parentActivity, resourcesProvider, new String[] {Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}, R.raw.permission_request_camera, LocaleController.formatString(R.string.BotWebViewRequestCameraMicPermission, UserObject.getUserName(botUser)), LocaleController.formatString(R.string.BotWebViewRequestCameraMicPermissionWithHint, UserObject.getUserName(botUser)), allow -> {
if (lastPermissionsDialog != null) {
lastPermissionsDialog = null;
if (allow) {
runWithPermissions(new String[] {Manifest.permission.CAMERA, Manifest.permission.RECORD_AUDIO}, allowSystem -> {
if (allowSystem) {
request.grant(new String[] {resources[0], resources[1]});
hasUserPermissions = true;
} else {
request.deny();
}
});
} else {
request.deny();
}
}
});
lastPermissionsDialog.show();
} }
} }
@ -866,6 +893,17 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewTheme); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.didSetNewTheme);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.onActivityResultReceived); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.onActivityResultReceived);
NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.onRequestPermissionResultReceived); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.onRequestPermissionResultReceived);
Bulletin.addDelegate(this, new Bulletin.Delegate() {
@Override
public int getBottomOffset(int tag) {
if (getParent() instanceof ChatAttachAlertBotWebViewLayout.WebViewSwipeContainer) {
ChatAttachAlertBotWebViewLayout.WebViewSwipeContainer swipeContainer = (ChatAttachAlertBotWebViewLayout.WebViewSwipeContainer) getParent();
return (int) (swipeContainer.getOffsetY() + swipeContainer.getSwipeOffsetY() - swipeContainer.getTopActionBarOffsetY());
}
return 0;
}
});
} }
@Override @Override
@ -875,6 +913,8 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewTheme); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.didSetNewTheme);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.onActivityResultReceived); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.onActivityResultReceived);
NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.onRequestPermissionResultReceived); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.onRequestPermissionResultReceived);
Bulletin.removeDelegate(this);
} }
public void destroyWebView() { public void destroyWebView() {
@ -1035,36 +1075,6 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
} }
break; break;
} }
case "web_app_request_phone": {
if (currentDialog != null || !ENABLE_REQUEST_PHONE) {
break;
}
AtomicBoolean notifiedPhone = new AtomicBoolean(false);
AlertDialog.Builder builder = new AlertDialog.Builder(getContext())
.setTitle(LocaleController.getString(R.string.ShareYouPhoneNumberTitle))
.setMessage(LocaleController.getString(R.string.AreYouSureShareMyContactInfoBot))
.setPositiveButton(LocaleController.getString("ShareContact", R.string.ShareContact), (dialogInterface, i) -> {
TLRPC.User currentUser = UserConfig.getInstance(currentAccount).getCurrentUser();
if (currentUser != null) {
try {
notifyEvent("phone_requested", new JSONObject().put("phone_number", currentUser.phone));
} catch (JSONException e) {
FileLog.e(e);
}
notifiedPhone.set(true);
}
}).setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), null)
.setOnDismissListener(dialog1 -> {
if (!notifiedPhone.get()) {
notifyEvent("phone_requested", new JSONObject());
}
currentDialog = null;
});
currentDialog = builder.show();
break;
}
case "web_app_open_popup": { case "web_app_open_popup": {
try { try {
if (currentDialog != null) { if (currentDialog != null) {
@ -1394,7 +1404,242 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
} }
break; break;
} }
case "web_app_request_write_access": {
if (ignoreDialog(3)) {
try {
JSONObject data = new JSONObject();
data.put("status", "cancelled");
notifyEvent("write_access_requested", data);
} catch (Exception e) {
FileLog.e(e);
} }
return;
}
TLRPC.TL_bots_canSendMessage req = new TLRPC.TL_bots_canSendMessage();
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botUser);
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
if (res instanceof TLRPC.TL_boolTrue) {
try {
JSONObject data = new JSONObject();
data.put("status", "allowed");
notifyEvent("write_access_requested", data);
} catch (Exception e) {
FileLog.e(e);
}
return;
} else if (err != null) {
unknownError(err.text);
return;
}
final String[] status = new String[] { "cancelled" };
showDialog(3, new AlertDialog.Builder(getContext())
.setTitle(LocaleController.getString(R.string.BotWebViewRequestWriteTitle))
.setMessage(LocaleController.getString(R.string.BotWebViewRequestWriteMessage))
.setPositiveButton(LocaleController.getString(R.string.BotWebViewRequestAllow), (di, w) -> {
TLRPC.TL_bots_allowSendMessage req2 = new TLRPC.TL_bots_allowSendMessage();
req2.bot = MessagesController.getInstance(currentAccount).getInputUser(botUser);
ConnectionsManager.getInstance(currentAccount).sendRequest(req2, (res2, err2) -> AndroidUtilities.runOnUIThread(() -> {
if (res2 != null) {
status[0] = "allowed";
}
if (err2 != null) {
unknownError(err2.text);
}
di.dismiss();
}));
})
.setNegativeButton(LocaleController.getString(R.string.BotWebViewRequestDontAllow), (di, w) -> {
di.dismiss();
})
.create(),
() -> {
try {
JSONObject data = new JSONObject();
data.put("status", status[0]);
notifyEvent("write_access_requested", data);
} catch (Exception e) {
FileLog.e(e);
}
}
);
}));
break;
}
case "web_app_invoke_custom_method": {
String reqId, method, paramsString;
try {
JSONObject jsonObject = new JSONObject(eventData);
reqId = jsonObject.getString("req_id");
method = jsonObject.getString("method");
Object params = jsonObject.get("params");
paramsString = params.toString();
} catch (Exception e) {
FileLog.e(e);
if (e instanceof JSONException) {
error("JSON Parse error");
} else {
unknownError();
}
return;
}
TLRPC.TL_bots_invokeWebViewCustomMethod req = new TLRPC.TL_bots_invokeWebViewCustomMethod();
req.bot = MessagesController.getInstance(currentAccount).getInputUser(botUser);
req.custom_method = method;
req.params = new TLRPC.TL_dataJSON();
req.params.data = paramsString;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (res, err) -> AndroidUtilities.runOnUIThread(() -> {
try {
JSONObject data = new JSONObject();
data.put("req_id", reqId);
if (res instanceof TLRPC.TL_dataJSON) {
Object json = new JSONTokener(((TLRPC.TL_dataJSON) res).data).nextValue();
data.put("result", json);
} else if (err != null) {
data.put("error", err.text);
}
notifyEvent("custom_method_invoked", data);
} catch (Exception e) {
FileLog.e(e);
unknownError();
}
}));
break;
}
case "web_app_request_phone": {
if (ignoreDialog(4)) {
try {
JSONObject data = new JSONObject();
data.put("status", "cancelled");
notifyEvent("phone_requested", data);
} catch (Exception e) {
FileLog.e(e);
}
return;
}
final String[] status = new String[] { "cancelled" };
AlertDialog.Builder builder = new AlertDialog.Builder(getContext(), resourcesProvider);
builder.setTitle(LocaleController.getString("ShareYouPhoneNumberTitle", R.string.ShareYouPhoneNumberTitle));
SpannableStringBuilder message = new SpannableStringBuilder();
String botName = UserObject.getUserName(botUser);
if (!TextUtils.isEmpty(botName)) {
message.append(AndroidUtilities.replaceTags(LocaleController.formatString(R.string.AreYouSureShareMyContactInfoWebapp, botName)));
} else {
message.append(AndroidUtilities.replaceTags(LocaleController.getString(R.string.AreYouSureShareMyContactInfoBot)));
}
final boolean blocked = MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(botUser.id) >= 0;
if (blocked) {
message.append("\n\n");
message.append(LocaleController.getString(R.string.AreYouSureShareMyContactInfoBotUnblock));
}
builder.setMessage(message);
builder.setPositiveButton(LocaleController.getString("ShareContact", R.string.ShareContact), (di, i) -> {
status[0] = null;
di.dismiss();
if (blocked) {
MessagesController.getInstance(currentAccount).unblockPeer(botUser.id, () -> {
SendMessagesHelper.getInstance(currentAccount).sendMessage(SendMessagesHelper.SendMessageParams.of(UserConfig.getInstance(currentAccount).getCurrentUser(), botUser.id, null, null, null, null, true, 0));
try {
JSONObject data = new JSONObject();
data.put("status", "sent");
notifyEvent("phone_requested", data);
} catch (Exception e) {
FileLog.e(e);
}
});
} else {
SendMessagesHelper.getInstance(currentAccount).sendMessage(SendMessagesHelper.SendMessageParams.of(UserConfig.getInstance(currentAccount).getCurrentUser(), botUser.id, null, null, null, null, true, 0));
try {
JSONObject data = new JSONObject();
data.put("status", "sent");
notifyEvent("phone_requested", data);
} catch (Exception e) {
FileLog.e(e);
}
}
});
builder.setNegativeButton(LocaleController.getString("Cancel", R.string.Cancel), (di, i) -> {
di.dismiss();
});
showDialog(4, builder.create(), () -> {
if (status[0] == null) {
return;
}
try {
JSONObject data = new JSONObject();
data.put("status", status[0]);
notifyEvent("phone_requested", data);
} catch (Exception e) {
FileLog.e(e);
}
});
break;
}
default: {
FileLog.d("unknown webapp event " + eventType);
break;
}
}
}
private void unknownError() {
unknownError(null);
}
private void unknownError(String errCode) {
error(LocaleController.getString("UnknownError", R.string.UnknownError) + (errCode != null ? ": " + errCode : ""));
}
private void error(String reason) {
BulletinFactory.of(this, resourcesProvider).createSimpleBulletin(R.raw.error, reason).show();
}
private int lastDialogType = -1;
private int shownDialogsCount = 0;
private long blockedDialogsUntil;
private boolean ignoreDialog(int type) {
if (currentDialog != null) {
return true;
}
if (blockedDialogsUntil > 0 && System.currentTimeMillis() < blockedDialogsUntil) {
return true;
}
if (lastDialogType == type && shownDialogsCount > 3) {
blockedDialogsUntil = System.currentTimeMillis() + 3 * 1000L;
shownDialogsCount = 0;
return true;
}
return false;
}
private boolean showDialog(int type, AlertDialog dialog, Runnable onDismiss) {
if (dialog == null || ignoreDialog(type)) {
return false;
}
dialog.setOnDismissListener(di -> {
if (onDismiss != null) {
onDismiss.run();
}
currentDialog = null;
});
currentDialog = dialog;
currentDialog.setDismissDialogByButtons(false);
currentDialog.show();
if (lastDialogType != type) {
lastDialogType = type;
shownDialogsCount = 0;
blockedDialogsUntil = 0;
}
shownDialogsCount++;
return true;
} }
private void openQrScanActivity() { private void openQrScanActivity() {
@ -1557,6 +1802,10 @@ public class BotWebViewContainer extends FrameLayout implements NotificationCent
default boolean isClipboardAvailable() { default boolean isClipboardAvailable() {
return false; return false;
} }
default String getWebAppName() {
return null;
}
} }
public final static class PopupButton { public final static class PopupButton {

View file

@ -112,6 +112,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
private boolean silent; private boolean silent;
private String buttonText; private String buttonText;
private Paint linePaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint linePaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private Paint dimPaint = new Paint(); private Paint dimPaint = new Paint();
private Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
@ -124,6 +125,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
private ActionBar actionBar; private ActionBar actionBar;
private Drawable actionBarShadow; private Drawable actionBarShadow;
private ActionBarMenuSubItem settingsItem; private ActionBarMenuSubItem settingsItem;
private TLRPC.BotApp currentWebApp;
private boolean dismissed; private boolean dismissed;
@ -414,6 +416,14 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
}).start(); }).start();
} }
} }
@Override
public String getWebAppName() {
if (currentWebApp != null) {
return currentWebApp.title;
}
return null;
}
}); });
linePaint.setStyle(Paint.Style.FILL_AND_STROKE); linePaint.setStyle(Paint.Style.FILL_AND_STROKE);
@ -764,6 +774,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
this.replyToMsgId = replyToMsgId; this.replyToMsgId = replyToMsgId;
this.silent = silent; this.silent = silent;
this.buttonText = buttonText; this.buttonText = buttonText;
this.currentWebApp = app;
actionBar.setTitle(UserObject.getUserName(MessagesController.getInstance(currentAccount).getUser(botId))); actionBar.setTitle(UserObject.getUserName(MessagesController.getInstance(currentAccount).getUser(botId)));
ActionBarMenu menu = actionBar.createMenu(); ActionBarMenu menu = actionBar.createMenu();

View file

@ -845,6 +845,11 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
if (scrollListener != null) { if (scrollListener != null) {
scrollListener.run(); scrollListener.run();
} }
if (Bulletin.getVisibleBulletin() != null) {
Bulletin bulletin = Bulletin.getVisibleBulletin();
bulletin.updatePosition();
}
} }
public float getTopActionBarOffsetY() { public float getTopActionBarOffsetY() {

View file

@ -1395,6 +1395,10 @@ public class RLottieDrawable extends BitmapDrawable implements Animatable, Bitma
} }
} }
public void setAllowDrawFramesWhileCacheGenerating(boolean allowDrawWhileCacheGenerating) {
//TODO
}
private class NativePtrArgs { private class NativePtrArgs {
public int[] colorReplacement; public int[] colorReplacement;
public int fitzModifier; public int fitzModifier;

View file

@ -1558,7 +1558,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
actionBar.setTranslationY(0); actionBar.setTranslationY(0);
} else { } else {
if (hasOnlySlefStories) { if (hasOnlySlefStories) {
dialogStoriesCell.setTranslationY(-AndroidUtilities.dp(DialogStoriesCell.HEIGHT_IN_DP) + scrollYOffset); dialogStoriesCell.setTranslationY(-AndroidUtilities.dp(DialogStoriesCell.HEIGHT_IN_DP) + scrollYOffset - AndroidUtilities.dp(8));
dialogStoriesCell.setProgressToCollapse(1f); dialogStoriesCell.setProgressToCollapse(1f);
dialogStoriesCell.setClipTop((int) (AndroidUtilities.statusBarHeight - dialogStoriesCell.getY())); dialogStoriesCell.setClipTop((int) (AndroidUtilities.statusBarHeight - dialogStoriesCell.getY()));
} }
@ -5464,9 +5464,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
dialogsHintCellVisible = true; dialogsHintCellVisible = true;
dialogsHintCell.setVisibility(View.VISIBLE); dialogsHintCell.setVisibility(View.VISIBLE);
dialogsHintCell.setOnClickListener(v -> { dialogsHintCell.setOnClickListener(v -> {
if (dialogStoriesCell.getAlpha() == 0) {
return;
}
presentFragment(new PremiumPreviewFragment("dialogs_hint").setSelectAnnualByDefault()); presentFragment(new PremiumPreviewFragment("dialogs_hint").setSelectAnnualByDefault());
AndroidUtilities.runOnUIThread(() -> { AndroidUtilities.runOnUIThread(() -> {
MessagesController.getInstance(currentAccount).removeSuggestion(0, isPremiumHintUpgrade ? "PREMIUM_UPGRADE" : "PREMIUM_ANNUAL"); MessagesController.getInstance(currentAccount).removeSuggestion(0, isPremiumHintUpgrade ? "PREMIUM_UPGRADE" : "PREMIUM_ANNUAL");

View file

@ -393,7 +393,7 @@ public class PinchToZoomHelper {
return true; return true;
} }
} }
return receiver.hasNotThumb(); return receiver.hasNotThumbOrOnlyStaticThumb();
} }

View file

@ -525,11 +525,10 @@ public class DialogStoriesCell extends FrameLayout implements NotificationCenter
if (clipTop > 0) { if (clipTop > 0) {
canvas.clipRect(0, clipTop, getMeasuredWidth(), getMeasuredHeight()); canvas.clipRect(0, clipTop, getMeasuredWidth(), getMeasuredHeight());
} }
float y = AndroidUtilities.lerp(0, getMeasuredHeight() - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(4) - AndroidUtilities.dp(FAKE_TOP_PADDING), collapsedProgress1); float y = AndroidUtilities.lerp(0, getMeasuredHeight() - ActionBar.getCurrentActionBarHeight() - AndroidUtilities.dp(4), collapsedProgress1);
recyclerListView.setTranslationY(y); recyclerListView.setTranslationY(y);
listViewMini.setTranslationY(y); listViewMini.setTranslationY(y);
listViewMini.setTranslationX(AndroidUtilities.dp(68)); listViewMini.setTranslationX(AndroidUtilities.dp(68));
float progressHalf = Utilities.clamp((CubicBezierInterpolator.EASE_OUT.getInterpolation(collapsedProgress) - 0.5f) / 0.5f, 1f, 0);
for (int i = 0; i < viewsDrawInParent.size(); i++) { for (int i = 0; i < viewsDrawInParent.size(); i++) {
viewsDrawInParent.get(i).drawInParent = false; viewsDrawInParent.get(i).drawInParent = false;

View file

@ -3562,6 +3562,8 @@
<string name="BotWebViewRequestDontAllow">Don\'t Allow</string> <string name="BotWebViewRequestDontAllow">Don\'t Allow</string>
<string name="BotWebViewChangesMayNotBeSaved">Changes that you made may not be saved.</string> <string name="BotWebViewChangesMayNotBeSaved">Changes that you made may not be saved.</string>
<string name="BotWebViewCloseAnyway">Close anyway</string> <string name="BotWebViewCloseAnyway">Close anyway</string>
<string name="BotWebViewRequestWriteTitle">Allow messaging</string>
<string name="BotWebViewRequestWriteMessage">Allow this bot to send you messages?</string>
<!--button titles--> <!--button titles-->
<string name="Done">Done</string> <string name="Done">Done</string>
<string name="Open">Open</string> <string name="Open">Open</string>
@ -3664,6 +3666,7 @@
<string name="ActionGroupCallInvitedYou">un1 invited you to the voice chat</string> <string name="ActionGroupCallInvitedYou">un1 invited you to the voice chat</string>
<string name="ActionBotAllowed">You allowed this bot to message you when you logged in on %1$s.</string> <string name="ActionBotAllowed">You allowed this bot to message you when you logged in on %1$s.</string>
<string name="ActionBotAllowedApp">You allowed this bot to message you when you logged in on "%1$s" app.</string> <string name="ActionBotAllowedApp">You allowed this bot to message you when you logged in on "%1$s" app.</string>
<string name="ActionBotAllowedWebapp">You allowed this bot to message you in its web-app</string>
<string name="ActionBotDocuments">%1$s received the following documents: %2$s</string> <string name="ActionBotDocuments">%1$s received the following documents: %2$s</string>
<string name="ActionBotDocumentIdentity">Personal details</string> <string name="ActionBotDocumentIdentity">Personal details</string>
<string name="ActionBotDocumentAddress">Address</string> <string name="ActionBotDocumentAddress">Address</string>
@ -3790,6 +3793,8 @@
<string name="ShareYouLocationInline">This bot would like to know your location each time you send it a request. This can be used to provide location-specific results.</string> <string name="ShareYouLocationInline">This bot would like to know your location each time you send it a request. This can be used to provide location-specific results.</string>
<string name="ShareYouPhoneNumberTitle">Share your phone number?</string> <string name="ShareYouPhoneNumberTitle">Share your phone number?</string>
<string name="AreYouSureShareMyContactInfoBot">The bot will know your phone number. This can be useful for integration with other services.</string> <string name="AreYouSureShareMyContactInfoBot">The bot will know your phone number. This can be useful for integration with other services.</string>
<string name="AreYouSureShareMyContactInfoWebapp">**%s** will know your phone number. This can be useful for integration with other services.</string>
<string name="AreYouSureShareMyContactInfoBotUnblock">This will also unblock the bot.</string>
<string name="AreYouSureShareMyContactInfoUser">Are you sure you want to share your phone number %1$s with **%2$s**?</string> <string name="AreYouSureShareMyContactInfoUser">Are you sure you want to share your phone number %1$s with **%2$s**?</string>
<string name="AreYouSureShareMyContactInfo">Are you sure you want to share your phone number?</string> <string name="AreYouSureShareMyContactInfo">Are you sure you want to share your phone number?</string>
<string name="AreYouSureBlockContact2">Are you sure you want to block **%1$s**?</string> <string name="AreYouSureBlockContact2">Are you sure you want to block **%1$s**?</string>
@ -5750,6 +5755,8 @@
<string name="BotWebViewRequestMicrophonePermissionWithHint">Allow **%1$s** to access to your microphone?\n\nThe developer of **%1$s** will be able to access your microphone when this web app is open.\n\nEnable microphone access in Settings > Permissions > Microphone.</string> <string name="BotWebViewRequestMicrophonePermissionWithHint">Allow **%1$s** to access to your microphone?\n\nThe developer of **%1$s** will be able to access your microphone when this web app is open.\n\nEnable microphone access in Settings > Permissions > Microphone.</string>
<string name="BotWebViewRequestCameraPermission">Allow **%1$s** to access to your camera?\n\nThe developer of **%1$s** will be able to access your camera when this web app is open.</string> <string name="BotWebViewRequestCameraPermission">Allow **%1$s** to access to your camera?\n\nThe developer of **%1$s** will be able to access your camera when this web app is open.</string>
<string name="BotWebViewRequestCameraPermissionWithHint">Allow **%1$s** to access to your camera?\n\nThe developer of **%1$s** will be able to access your camera when this web app is open.\n\nEnable camera access in Settings > Permissions > Camera.</string> <string name="BotWebViewRequestCameraPermissionWithHint">Allow **%1$s** to access to your camera?\n\nThe developer of **%1$s** will be able to access your camera when this web app is open.\n\nEnable camera access in Settings > Permissions > Camera.</string>
<string name="BotWebViewRequestCameraMicPermission">Allow **%1$s** to access to your camera and microphone?\n\nThe developer of **%1$s** will be able to access your camera and microphone when this web app is open.</string>
<string name="BotWebViewRequestCameraMicPermissionWithHint">Allow **%1$s** to access to your camera and microphone?\n\nThe developer of **%1$s** will be able to access your camera and microphone when this web app is open.\n\nEnable camera access in Settings > Permissions > Camera.</string>
<string name="ErrorRingtoneDurationTooLong">Length must be under %s seconds.</string> <string name="ErrorRingtoneDurationTooLong">Length must be under %s seconds.</string>
<string name="ErrorRingtoneSizeTooBig">Size must be under %s Kb.</string> <string name="ErrorRingtoneSizeTooBig">Size must be under %s Kb.</string>
<string name="ErrorRingtoneInvalidFormat">File must be mp3 or ogg format.</string> <string name="ErrorRingtoneInvalidFormat">File must be mp3 or ogg format.</string>

View file

@ -13,8 +13,8 @@
# http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
# org.gradle.parallel=true # org.gradle.parallel=true
#Sat Mar 12 05:53:50 MSK 2016 #Sat Mar 12 05:53:50 MSK 2016
APP_VERSION_CODE=3802 APP_VERSION_CODE=3804
APP_VERSION_NAME=10.0.4 APP_VERSION_NAME=10.0.5
APP_PACKAGE=org.telegram.messenger APP_PACKAGE=org.telegram.messenger
RELEASE_KEY_PASSWORD=android RELEASE_KEY_PASSWORD=android
RELEASE_KEY_ALIAS=androidkey RELEASE_KEY_ALIAS=androidkey