update to 10.0.9 (3872)

This commit is contained in:
xaxtix 2023-09-16 01:02:29 +04:00
parent dcad7b4375
commit 6b4602c20a
25 changed files with 568 additions and 520 deletions

View file

@ -24,8 +24,8 @@ public class BuildVars {
public static boolean USE_CLOUD_STRINGS = true;
public static boolean CHECK_UPDATES = true;
public static boolean NO_SCOPED_STORAGE = Build.VERSION.SDK_INT <= 29;
public static int BUILD_VERSION = 3867;
public static String BUILD_VERSION_STRING = "10.0.8";
public static int BUILD_VERSION = 3872;
public static String BUILD_VERSION_STRING = "10.0.9";
public static int APP_ID = 4;
public static String APP_HASH = "014b35b6184100b085b0d0572f9b5103";

View file

@ -2994,10 +2994,10 @@ public class MediaDataController extends BaseController {
* @param toggle 0 - remove, 1 - archive, 2 - add
*/
public void toggleStickerSet(Context context, TLObject stickerSetObject, int toggle, BaseFragment baseFragment, boolean showSettings, boolean showTooltip) {
toggleStickerSet(context, stickerSetObject, toggle, baseFragment, showSettings, showTooltip, null);
toggleStickerSet(context, stickerSetObject, toggle, baseFragment, showSettings, showTooltip, null, true);
}
public void toggleStickerSet(Context context, TLObject stickerSetObject, int toggle, BaseFragment baseFragment, boolean showSettings, boolean showTooltip, Runnable onUndo) {
public void toggleStickerSet(Context context, TLObject stickerSetObject, int toggle, BaseFragment baseFragment, boolean showSettings, boolean showTooltip, Runnable onUndo, boolean forget) {
TLRPC.StickerSet stickerSet;
TLRPC.TL_messages_stickerSet messages_stickerSet;
@ -3036,7 +3036,7 @@ public class MediaDataController extends BaseController {
stickerSets[type].remove(a);
if (toggle == 2) {
stickerSets[type].add(0, set);
} else {
} else if (forget) {
stickerSetsById.remove(set.set.id);
installedStickerSetsById.remove(set.set.id);
stickerSetsByName.remove(set.set.short_name);
@ -7233,6 +7233,19 @@ public class MediaDataController extends BaseController {
}
}
public void applyAttachMenuBot(TLRPC.TL_attachMenuBotsBot attachMenuBot) {
attachMenuBots.bots.add(attachMenuBot.bot);
}
public boolean botInAttachMenu(long id) {
for (int i = 0; i < attachMenuBots.bots.size(); i++) {
if (attachMenuBots.bots.get(i).bot_id == id) {
return true;
}
}
return false;
}
//---------------- BOT END ----------------
//---------------- EMOJI START ----------------

View file

@ -3604,7 +3604,15 @@ public class MessageObject {
}
if (object == null && chats != null) {
object = chats.get(action.auto_setting_from);
}
if (object == null) {
if (action.auto_setting_from > 0) {
object = MessagesController.getInstance(currentAccount).getUser(action.auto_setting_from);
} else {
object = MessagesController.getInstance(currentAccount).getChat(-action.auto_setting_from);
}
}
if (object == null) {
object = fromObject;
}
messageText = replaceWithLink(AndroidUtilities.replaceTags(LocaleController.formatString("AutoDeleteGlobalAction", R.string.AutoDeleteGlobalAction, LocaleController.formatTTLString(action.period))), "un1", object);

View file

@ -10561,7 +10561,6 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
startY = textY + currentMessageObject.textHeight + AndroidUtilities.dp(8);
linkX = unmovedTextX + AndroidUtilities.dp(1);
}
startY += (int) transitionParams.deltaBottom;
int linkPreviewY = startY;
int smallImageStartY = 0;

View file

@ -423,6 +423,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private SimpleTextView mentiondownButtonCounter;
private ImageView mentiondownButtonImage;
private Bulletin messageSeenPrivacyBulletin;
TextView webBotTitle;
private int reactionsMentionCount;
private FrameLayout reactionsMentiondownButton;
@ -1198,6 +1199,17 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
}
}
public TextView getOrCreateWebBotTitleView() {
if (webBotTitle == null) {
webBotTitle = new TextView(getContext());
webBotTitle.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
webBotTitle.setTypeface(AndroidUtilities.getTypeface("fonts/rmedium.ttf"));
webBotTitle.setGravity(Gravity.CENTER_VERTICAL);
actionBar.addView(webBotTitle, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.MATCH_PARENT, 0, 72, 0, 72, 0));
}
return webBotTitle;
}
private interface ChatActivityDelegate {
default void openReplyMessage(int mid) {
@ -13460,6 +13472,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop();
if (webBotTitle != null) {
((LayoutParams) webBotTitle.getLayoutParams()).topMargin = AndroidUtilities.statusBarHeight;
webBotTitle.setTextSize(!AndroidUtilities.isTablet() && getResources().getConfiguration().orientation == Configuration.ORIENTATION_LANDSCAPE ? 18 : 20);
}
measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int actionBarHeight = actionBar.getMeasuredHeight();
if (actionBar.getVisibility() == VISIBLE) {
@ -14762,6 +14778,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public boolean canScrollAway() {
return false;
}
@Override
public boolean canCaptureMorePhotos() {
return false;
}
}, this);
} else {
fillEditingMediaWithCaption(caption, null);
@ -24613,7 +24634,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
didPressMessageUrl(link, false, selectedObject, v instanceof ChatMessageCell ? (ChatMessageCell) v : null);
return true;
};
TLRPC.InputPeer inputPeer = selectedObject != null && (selectedObject.isPoll() || selectedObject.isVoiceTranscriptionOpen() || selectedObject.isSponsored()) ? null : getMessagesController().getInputPeer(dialog_id);
TLRPC.InputPeer inputPeer = selectedObject != null && (selectedObject.isPoll() || selectedObject.isVoiceTranscriptionOpen() || selectedObject.isSponsored() || selectedObject.scheduled) ? null : getMessagesController().getInputPeer(dialog_id);
if (selectedObject != null && selectedObject.messageOwner != null && selectedObject.messageOwner.originalLanguage != null) {
waitForLangDetection.set(false);
String fromLang = selectedObject.messageOwner.originalLanguage;

View file

@ -49,17 +49,14 @@ import org.json.JSONArray;
import org.json.JSONException;
import org.json.JSONObject;
import org.json.JSONTokener;
import org.telegram.PhoneFormat.PhoneFormat;
import org.telegram.messenger.AndroidUtilities;
import org.telegram.messenger.ApplicationLoader;
import org.telegram.messenger.BotWebViewVibrationEffect;
import org.telegram.messenger.ContactsController;
import org.telegram.messenger.FileLog;
import org.telegram.messenger.ImageLocation;
import org.telegram.messenger.ImageReceiver;
import org.telegram.messenger.LocaleController;
import org.telegram.messenger.MediaDataController;
import org.telegram.messenger.MessageObject;
import org.telegram.messenger.MessagesController;
import org.telegram.messenger.NotificationCenter;
import org.telegram.messenger.R;
@ -1214,7 +1211,14 @@ public abstract class BotWebViewContainer extends FrameLayout implements Notific
case "web_app_set_header_color": {
try {
JSONObject jsonObject = new JSONObject(eventData);
String key = jsonObject.getString("color_key");
String overrideColorString = jsonObject.optString("color", null);
if (!TextUtils.isEmpty(overrideColorString)) {
int color = Color.parseColor(overrideColorString);
if (color != 0) {
delegate.onWebAppSetActionBarColor(color, true);
}
} else {
String key = jsonObject.optString("color_key");
int themeKey = -1;
switch (key) {
case "bg_color": {
@ -1227,7 +1231,8 @@ public abstract class BotWebViewContainer extends FrameLayout implements Notific
}
}
if (themeKey >= 0) {
delegate.onWebAppSetActionBarColor(themeKey);
delegate.onWebAppSetActionBarColor(Theme.getColor(themeKey, resourcesProvider), false);
}
}
} catch (JSONException e) {
FileLog.e(e);
@ -1763,8 +1768,9 @@ public abstract class BotWebViewContainer extends FrameLayout implements Notific
* Called when WebView requests to set action bar color
*
* @param colorKey Color theme key
* @param isOverrideColor
*/
void onWebAppSetActionBarColor(int colorKey);
void onWebAppSetActionBarColor(int colorKey, boolean isOverrideColor);
/**
* Called when WebView requests to set background color

View file

@ -1,15 +1,19 @@
package org.telegram.ui.Components;
import static org.telegram.ui.ActionBar.Theme.key_windowBackgroundWhiteBlackText;
import android.animation.Animator;
import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator;
import android.annotation.SuppressLint;
import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint;
import android.os.Build;
import android.os.Bundle;
import android.text.Editable;
import android.util.SparseIntArray;
import android.view.Gravity;
import android.view.MotionEvent;
import android.view.View;
@ -106,6 +110,7 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
private boolean overrideBackgroundColor;
private boolean needCloseConfirmation;
ActionBarColorsAnimating actionBarColors;
private Runnable pollRunnable = () -> {
if (!dismissed) {
@ -126,6 +131,8 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
}));
}
};
private boolean actionBarIsLight;
private int lineColor;
private void checkBotMenuItem() {
if (botMenuItem == null) {
@ -139,6 +146,9 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
public BotWebViewMenuContainer(@NonNull Context context, ChatActivityEnterView parentEnterView) {
super(context);
actionBarColors = new ActionBarColorsAnimating();
actionBarColors.setTo(0, null);
actionBarColors.progress = 1;
this.parentEnterView = parentEnterView;
ChatActivity chatActivity = parentEnterView.getParentFragment();
@ -164,10 +174,15 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
}
@Override
public void onWebAppSetActionBarColor(int colorKey) {
public void onWebAppSetActionBarColor(int color, boolean isOverrideColor) {
int from = overrideActionBarBackground;
int to = getColor(colorKey);
int to = color;
actionBarColors = new BotWebViewMenuContainer.ActionBarColorsAnimating();
actionBarColors.setFrom(overrideBackgroundColor ? from : 0, null);
overrideBackgroundColor = isOverrideColor;
actionBarIsLight = ColorUtils.calculateLuminance(color) < 0.5f;
actionBarColors.setTo(overrideBackgroundColor ? to : 0, null);
if (from == 0) {
overrideActionBarBackground = to;
}
@ -175,11 +190,13 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
if (from != 0) {
overrideActionBarBackground = ColorUtils.blendARGB(from, to, (float) animation.getAnimatedValue());
overrideActionBarBackground = ColorUtils.blendARGB(from, to, progress);
} else {
overrideActionBarBackgroundProgress = (float) animation.getAnimatedValue();
overrideActionBarBackgroundProgress = progress;
}
actionBarColors.progress = progress;
actionBarPaint.setColor(overrideActionBarBackground);
invalidateActionBar();
});
@ -393,21 +410,22 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
return;
}
ChatAvatarContainer avatarContainer = chatActivity.getAvatarContainer();
int subtitleDefaultColorKey = avatarContainer.getLastSubtitleColorKey() < 0 ? Theme.key_actionBarDefaultSubtitle : avatarContainer.getLastSubtitleColorKey();
int subtitleColor = ColorUtils.blendARGB(getColor(subtitleDefaultColorKey), getColor(Theme.key_windowBackgroundWhiteGrayText), actionBarTransitionProgress);
ActionBar actionBar = chatActivity.getActionBar();
int backgroundColor = ColorUtils.blendARGB(getColor(Theme.key_actionBarDefault), getColor(Theme.key_windowBackgroundWhite), actionBarTransitionProgress);
if (overrideBackgroundColor) {
backgroundColor = ColorUtils.blendARGB(getColor(Theme.key_actionBarDefault), overrideActionBarBackground, actionBarTransitionProgress);
} else {
ColorUtils.blendARGB(getColor(Theme.key_actionBarDefault), actionBarColors.getColor(Theme.key_windowBackgroundWhite), actionBarTransitionProgress);
}
actionBar.setBackgroundColor(backgroundColor);
actionBar.setItemsColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultIcon), getColor(Theme.key_windowBackgroundWhiteBlackText), actionBarTransitionProgress), false);
actionBar.setItemsBackgroundColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultSelector), getColor(Theme.key_actionBarWhiteSelector), actionBarTransitionProgress), false);
actionBar.setSubtitleColor(subtitleColor);
actionBar.setItemsColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultIcon), actionBarColors.getColor(key_windowBackgroundWhiteBlackText), actionBarTransitionProgress), false);
actionBar.setItemsBackgroundColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultSelector), actionBarColors.getColor(Theme.key_actionBarWhiteSelector), actionBarTransitionProgress), false);
ChatAvatarContainer chatAvatarContainer = chatActivity.getAvatarContainer();
chatAvatarContainer.getTitleTextView().setTextColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultTitle), getColor(Theme.key_windowBackgroundWhiteBlackText), actionBarTransitionProgress));
chatAvatarContainer.getSubtitleTextView().setTextColor(subtitleColor);
chatAvatarContainer.setOverrideSubtitleColor(actionBarTransitionProgress == 0 ? null : subtitleColor);
chatAvatarContainer.setAlpha(1f - actionBarTransitionProgress);
chatActivity.getOrCreateWebBotTitleView().setAlpha(actionBarTransitionProgress);
chatActivity.getOrCreateWebBotTitleView().setTextColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultIcon), actionBarColors.getColor(key_windowBackgroundWhiteBlackText), actionBarTransitionProgress));
updateLightStatusBar();
}
@ -672,7 +690,9 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
public void draw(Canvas canvas) {
super.draw(canvas);
linePaint.setColor(getColor(Theme.key_sheet_scrollUp));
lineColor = actionBarColors.getColor(Theme.key_sheet_scrollUp);
linePaint.setColor(lineColor);
linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, actionBarTransitionProgress) / 0.5f)));
canvas.save();
@ -702,6 +722,8 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
ChatActivity chatActivity = parentEnterView.getParentFragment();
if (chatActivity != null) {
chatActivity.hideFieldPanel(true);
TextView webViewTitle = chatActivity.getOrCreateWebBotTitleView();
webViewTitle.setText(chatActivity.getCurrentUser().first_name);
}
if (!isLoaded) {
@ -752,7 +774,7 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
JSONObject jsonObject = new JSONObject();
jsonObject.put("bg_color", getColor(Theme.key_windowBackgroundWhite));
jsonObject.put("secondary_bg_color", getColor(Theme.key_windowBackgroundGray));
jsonObject.put("text_color", getColor(Theme.key_windowBackgroundWhiteBlackText));
jsonObject.put("text_color", getColor(key_windowBackgroundWhiteBlackText));
jsonObject.put("hint_color", getColor(Theme.key_windowBackgroundWhiteHintText));
jsonObject.put("link_color", getColor(Theme.key_windowBackgroundWhiteLinkText));
jsonObject.put("button_color", getColor(Theme.key_featuredStickers_addButton));
@ -904,4 +926,69 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
AndroidUtilities.runOnUIThread(this::invalidateActionBar, 300);
}
}
public static class ActionBarColorsAnimating {
SparseIntArray fromColors = new SparseIntArray();
SparseIntArray toColors = new SparseIntArray();
int[] colorKeys = new int[]{
Theme.key_windowBackgroundWhiteBlackText,
Theme.key_actionBarWhiteSelector,
Theme.key_actionBarDefaultSubmenuBackground,
Theme.key_actionBarDefaultSubmenuItem,
Theme.key_actionBarDefaultSubmenuItemIcon,
Theme.key_dialogButtonSelector,
Theme.key_sheet_scrollUp
};
public float progress;
public void setFrom(int actionBarColor, Theme.ResourcesProvider resourcesProvider) {
updateColors(fromColors, actionBarColor, resourcesProvider);
}
public void setTo(int actionBarColor, Theme.ResourcesProvider resourcesProvider) {
updateColors(toColors, actionBarColor, resourcesProvider);
}
private void updateColors(SparseIntArray fromColors, int actionBarColor, Theme.ResourcesProvider resourcesProvider) {
if (actionBarColor == 0) {
for (int i = 0; i < colorKeys.length; i++) {
int key = colorKeys[i];
fromColors.put(key, Theme.getColor(key, resourcesProvider));
}
} else {
int color = ColorUtils.calculateLuminance(actionBarColor) < 0.5f ? Color.WHITE : Color.BLACK;
int selectorColor = ColorUtils.setAlphaComponent(color, 60);
for (int i = 0; i < colorKeys.length; i++) {
int key = colorKeys[i];
if (key == Theme.key_actionBarDefaultSubmenuBackground || key == Theme.key_actionBarDefaultSubmenuItem || key == Theme.key_actionBarDefaultSubmenuItemIcon || key == Theme.key_dialogButtonSelector) {
fromColors.put(key, Theme.getColor(key, resourcesProvider));
} else if (key == Theme.key_sheet_scrollUp) {
fromColors.put(key, ColorUtils.blendARGB(actionBarColor, color, 0.5f));
} else if (key == Theme.key_actionBarWhiteSelector || key == Theme.key_dialogButtonSelector) {
fromColors.put(key, selectorColor);
} else {
fromColors.put(key, color);
}
}
}
}
public int getColor(int key) {
return ColorUtils.blendARGB(fromColors.get(key), toColors.get(key), progress);
}
public void updateActionBar(ActionBar actionBar, float progress) {
this.progress = progress;
actionBar.setTitleColor(getColor(Theme.key_windowBackgroundWhiteBlackText));
actionBar.setItemsColor(getColor(Theme.key_windowBackgroundWhiteBlackText), false);
actionBar.setItemsBackgroundColor(getColor(Theme.key_actionBarWhiteSelector), false);
actionBar.setPopupBackgroundColor(getColor(Theme.key_actionBarDefaultSubmenuBackground), false);
actionBar.setPopupItemsColor(getColor(Theme.key_actionBarDefaultSubmenuItem), false, false);
actionBar.setPopupItemsColor(getColor(Theme.key_actionBarDefaultSubmenuItemIcon), true, false);
actionBar.setPopupItemsSelectorColor(getColor(Theme.key_dialogButtonSelector), false);
}
}
}

View file

@ -31,7 +31,6 @@ import androidx.annotation.NonNull;
import androidx.core.content.ContextCompat;
import androidx.core.graphics.ColorUtils;
import androidx.core.math.MathUtils;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce;
@ -75,6 +74,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
public final static int FLAG_FROM_INLINE_SWITCH = 1;
public final static int FLAG_FROM_SIDE_MENU = 2;
private int lineColor;
public void showJustAddedBulletin() {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(botId);
@ -152,6 +152,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
private Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private int actionBarColor;
private boolean actionBarIsLight;
private Paint actionBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private boolean overrideBackgroundColor;
@ -202,6 +203,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
public BotWebViewSheet(@NonNull Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, R.style.TransparentDialog);
this.resourcesProvider = resourcesProvider;
lineColor = Theme.getColor(Theme.key_sheet_scrollUp);
swipeContainer = new ChatAttachAlertBotWebViewLayout.WebViewSwipeContainer(context) {
@Override
@ -279,28 +281,40 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
}
@Override
public void onWebAppSetActionBarColor(int colorKey) {
public void onWebAppSetActionBarColor(int color, boolean isOverrideColor) {
int from = actionBarColor;
int to = getColor(colorKey);
int to = color;
BotWebViewMenuContainer.ActionBarColorsAnimating actionBarColorsAnimating = new BotWebViewMenuContainer.ActionBarColorsAnimating();
actionBarColorsAnimating.setFrom(overrideBackgroundColor ? actionBarColor : 0, resourcesProvider);
overrideBackgroundColor = isOverrideColor;
actionBarIsLight = ColorUtils.calculateLuminance(color) < 0.5f;
actionBarColorsAnimating.setTo(overrideBackgroundColor ? to : 0, resourcesProvider);
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> {
actionBarColor = ColorUtils.blendARGB(from, to, (Float) animation.getAnimatedValue());
float progress = (float) animation.getAnimatedValue();
actionBarColor = ColorUtils.blendARGB(from, to, progress);
actionBar.setBackgroundColor(actionBarColor);
actionBarColorsAnimating.updateActionBar(actionBar, progress);
lineColor = actionBarColorsAnimating.getColor(Theme.key_sheet_scrollUp);
frameLayout.invalidate();
});
animator.start();
updateLightStatusBar();
}
@Override
public void onWebAppSetBackgroundColor(int color) {
overrideBackgroundColor = true;
int from = backgroundPaint.getColor();
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> {
backgroundPaint.setColor(ColorUtils.blendARGB(from, color, (Float) animation.getAnimatedValue()));
updateActionBarColors();
frameLayout.invalidate();
});
animator.start();
@ -488,7 +502,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight());
canvas.drawRect(AndroidUtilities.rectTmp, dimPaint);
actionBarPaint.setColor(ColorUtils.blendARGB(actionBarColor, getColor(Theme.key_windowBackgroundWhite), actionBarTransitionProgress));
actionBarPaint.setColor(actionBarColor);
float radius = AndroidUtilities.dp(16) * (AndroidUtilities.isTablet() ? 1f : 1f - actionBarTransitionProgress);
AndroidUtilities.rectTmp.set(swipeContainer.getLeft(), AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), swipeContainer.getRight(), swipeContainer.getTranslationY() + AndroidUtilities.dp(24) + radius);
canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, actionBarPaint);
@ -503,7 +517,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
super.draw(canvas);
float transitionProgress = AndroidUtilities.isTablet() ? 0 : actionBarTransitionProgress;
linePaint.setColor(Theme.getColor(Theme.key_sheet_scrollUp));
linePaint.setColor(lineColor);
linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, transitionProgress) / 0.5f)));
canvas.save();
@ -716,6 +730,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
}
private void updateActionBarColors() {
if (!overrideBackgroundColor) {
actionBar.setTitleColor(getColor(Theme.key_windowBackgroundWhiteBlackText));
actionBar.setItemsColor(getColor(Theme.key_windowBackgroundWhiteBlackText), false);
actionBar.setItemsBackgroundColor(getColor(Theme.key_actionBarWhiteSelector), false);
@ -724,11 +739,16 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
actionBar.setPopupItemsColor(getColor(Theme.key_actionBarDefaultSubmenuItemIcon), true, false);
actionBar.setPopupItemsSelectorColor(getColor(Theme.key_dialogButtonSelector), false);
}
}
private void updateLightStatusBar() {
boolean lightStatusBar;
if (overrideBackgroundColor) {
lightStatusBar = !actionBarIsLight;
} else {
int color = Theme.getColor(Theme.key_windowBackgroundWhite, null, true);
boolean lightStatusBar = !AndroidUtilities.isTablet() && ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f;
lightStatusBar = !AndroidUtilities.isTablet() && ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f;
}
if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) {
return;
}
@ -945,6 +965,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
req.theme_params.data = themeParams;
req.flags |= 1;
}
req.flags |= 8;
req.url = buttonUrl;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
@ -1037,7 +1058,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
return;
}
String botName = currentBot.short_name;
description = LocaleController.formatString("BotRemoveFromMenu", R.string.BotRemoveFromMenu, botName);
description = LocaleController.formatString("BotRemoveFromMenuAll", R.string.BotRemoveFromMenuAll, botName);
TLRPC.TL_attachMenuBot finalCurrentBot = currentBot;
new AlertDialog.Builder(LaunchActivity.getLastFragment().getContext())
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))

View file

@ -142,6 +142,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
public boolean allowEnterCaption;
private ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate documentsDelegate;
private long dialogId;
private boolean overrideBackgroundColor;
public void setCanOpenPreview(boolean canOpenPreview) {
this.canOpenPreview = canOpenPreview;
@ -187,13 +188,26 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
}
@Override
public void onWebAppSetActionBarColor(int colorKey) {
public void onWebAppSetActionBarColor(int color, boolean isOverrideColor) {
int from = ((ColorDrawable) actionBar.getBackground()).getColor();
int to = getThemedColor(colorKey);
int to = color;
BotWebViewMenuContainer.ActionBarColorsAnimating actionBarColorsAnimating = new BotWebViewMenuContainer.ActionBarColorsAnimating();
actionBarColorsAnimating.setFrom(overrideBackgroundColor ? from : 0, resourcesProvider);
overrideBackgroundColor = isOverrideColor;
// actionBarIsLight = ColorUtils.calculateLuminance(color) < 0.5f;
actionBarColorsAnimating.setTo(overrideBackgroundColor ? to : 0, resourcesProvider);
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> actionBar.setBackgroundColor(ColorUtils.blendARGB(from, to, (float) animation.getAnimatedValue())));
animator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
actionBar.setBackgroundColor(ColorUtils.blendARGB(from, to, progress));
webViewLayout.setCustomActionBarBackground(ColorUtils.blendARGB(from, to, progress));
currentAttachLayout.invalidate();
sizeNotifierFrameLayout.invalidate();
actionBarColorsAnimating.updateActionBar(actionBar, progress);
});
animator.start();
}
@ -583,6 +597,15 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
return 0;
}
boolean hasCustomActionBarBackground() {
return false;
}
int getCustomActionBarBackground() {
return 0;
}
void onButtonsTranslationYUpdated() {
}
@ -1617,8 +1640,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
canvas.restore();
}
if (rad != 1.0f && actionBarType != 2) {
Theme.dialogs_onlineCirclePaint.setColor(backgroundColor);
if ((rad != 1.0f && actionBarType != 2) || currentAttachLayout.hasCustomActionBarBackground()) {
Theme.dialogs_onlineCirclePaint.setColor(currentAttachLayout.hasCustomActionBarBackground() ? currentAttachLayout.getCustomActionBarBackground() : backgroundColor);
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24));
canvas.save();
@ -1627,6 +1650,19 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
canvas.restore();
}
if (currentAttachLayout.hasCustomActionBarBackground()) {
Theme.dialogs_onlineCirclePaint.setColor(currentAttachLayout.getCustomActionBarBackground());
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
int top2 = getScrollOffsetY(0);
if (Build.VERSION.SDK_INT >= 21 && !inBubbleMode) {
top2 += AndroidUtilities.statusBarHeight;
}
rect.set(backgroundPaddingLeft, (backgroundPaddingTop + top + AndroidUtilities.dp(12)) * (rad), getMeasuredWidth() - backgroundPaddingLeft, top2 + AndroidUtilities.dp(12));
canvas.save();
canvas.drawRect(rect, Theme.dialogs_onlineCirclePaint);
canvas.restore();
}
if ((headerView == null || headerView.getAlpha() != 1.0f) && rad != 0) {
int w = AndroidUtilities.dp(36);
rect.set((getMeasuredWidth() - w) / 2, y, (getMeasuredWidth() + w) / 2, y + AndroidUtilities.dp(4));
@ -1635,6 +1671,11 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (actionBarType == 2) {
color = 0x20000000;
alphaProgress = rad;
} else if (currentAttachLayout.hasCustomActionBarBackground()) {
int actionBarColor = currentAttachLayout.getCustomActionBarBackground();
int blendColor = ColorUtils.calculateLuminance(actionBarColor) < 0.5f ? Color.WHITE : Color.BLACK;
color = ColorUtils.blendARGB(actionBarColor, blendColor, 0.5f);
alphaProgress = headerView == null ? 1.0f : 1.0f - headerView.getAlpha();
} else {
color = getThemedColor(Theme.key_sheet_scrollUp);
alphaProgress = headerView == null ? 1.0f : 1.0f - headerView.getAlpha();
@ -1777,10 +1818,6 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (inBubbleMode) {
return;
}
// int color1 = currentAttachLayout.hasCustomBackground() ? currentAttachLayout.getCustomBackground() : getThemedColor(forceDarkTheme ? Theme.key_voipgroup_listViewBackground : Theme.key_dialogBackground);
// int finalColor = Color.argb((int) (255 * actionBar.getAlpha()), Color.red(color1), Color.green(color1), Color.blue(color1));
// Theme.dialogs_onlineCirclePaint.setColor(finalColor);
// canvas.drawRect(backgroundPaddingLeft, currentPanTranslationY, getMeasuredWidth() - backgroundPaddingLeft, AndroidUtilities.statusBarHeight + currentPanTranslationY, Theme.dialogs_onlineCirclePaint);
}
private int getCurrentTop() {
@ -2801,7 +2838,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
break;
}
}
description = LocaleController.formatString("BotRemoveFromMenu", R.string.BotRemoveFromMenu, botName);
description = LocaleController.formatString("BotRemoveFromMenuAll", R.string.BotRemoveFromMenuAll, botName);
new AlertDialog.Builder(getContext())
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))
.setMessage(AndroidUtilities.replaceTags(attachMenuBot != null ? description : LocaleController.formatString("BotRemoveInlineFromMenu", R.string.BotRemoveInlineFromMenu, botName)))

View file

@ -122,6 +122,8 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
}));
}
};
private boolean hasCustomActionBarBackground;
private int customActionBarBackground;
public ChatAttachAlertBotWebViewLayout(ChatAttachAlert alert, Context context, Theme.ResourcesProvider resourcesProvider) {
super(alert, context, resourcesProvider);
@ -279,6 +281,21 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
return customBackground;
}
@Override
boolean hasCustomActionBarBackground() {
return hasCustomActionBarBackground;
}
@Override
int getCustomActionBarBackground() {
return customActionBarBackground;
}
public void setCustomActionBarBackground(int customActionBarBackground) {
hasCustomActionBarBackground = true;
this.customActionBarBackground = customActionBarBackground;
}
public boolean canExpandByRequest() {
return /* System.currentTimeMillis() - lastSwipeTime > 1000 && */ !swipeContainer.isSwipeInProgress();
}

View file

@ -3072,16 +3072,22 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
if (count == 0) {
parentAlert.selectedMenuItem.showSubItem(open_in);
parentAlert.selectedMenuItem.hideSubItem(compress);
} else {
} else if (documentsEnabled) {
parentAlert.selectedMenuItem.showSubItem(compress);
} else {
parentAlert.selectedMenuItem.hideSubItem(compress);
}
} else {
parentAlert.selectedMenuItem.showSubItem(group);
if (documentsEnabled) {
parentAlert.selectedMenuItem.showSubItem(compress);
} else {
parentAlert.selectedMenuItem.hideSubItem(compress);
}
}
if (count != 0) {
parentAlert.selectedMenuItem.hideSubItem(open_in);
}
compressItem.setVisibility(documentsEnabled ? View.VISIBLE : View.GONE);
if (count > 1) {
parentAlert.selectedMenuItem.showSubItem(preview_gap);
parentAlert.selectedMenuItem.showSubItem(preview);

View file

@ -994,18 +994,18 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
}));
}
public static void uninstallSet(BaseFragment fragment, TLRPC.TL_messages_stickerSet set, boolean showBulletin, Runnable onUndo) {
public static void uninstallSet(BaseFragment fragment, TLRPC.TL_messages_stickerSet set, boolean showBulletin, Runnable onUndo, boolean forget) {
if (fragment == null || set == null || fragment.getFragmentView() == null) {
return;
}
MediaDataController.getInstance(fragment.getCurrentAccount()).toggleStickerSet(fragment.getFragmentView().getContext(), set, 0, fragment, true, showBulletin, onUndo);
MediaDataController.getInstance(fragment.getCurrentAccount()).toggleStickerSet(fragment.getFragmentView().getContext(), set, 0, fragment, true, showBulletin, onUndo, forget);
}
public static void uninstallSet(Context context, TLRPC.TL_messages_stickerSet set, boolean showBulletin, Runnable onUndo) {
if (set == null) {
return;
}
MediaDataController.getInstance(UserConfig.selectedAccount).toggleStickerSet(context, set, 0, null, true, showBulletin, onUndo);
MediaDataController.getInstance(UserConfig.selectedAccount).toggleStickerSet(context, set, 0, null, true, showBulletin, onUndo, true);
}
private ValueAnimator loadAnimator;
@ -1607,7 +1607,7 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
removeButtonView.setOnClickListener(e -> {
uninstallSet(dummyFragment, set, true, () -> {
toggle(true, true);
});
}, true);
toggle(false, true);
});
removeButtonView.setClickable(false);

View file

@ -25,6 +25,7 @@ import android.widget.LinearLayout;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import androidx.core.graphics.ColorUtils;
import androidx.core.math.MathUtils;
@ -108,7 +109,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
contentView = new LinearLayout(context) {
HashMap<Integer, Integer> lastX = new HashMap<>();
private final LongSparseArray<Integer> lastX = new LongSparseArray<>();
@Override
protected void onLayout(boolean changed, int l, int t, int r, int b) {
@ -122,7 +123,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
if (child != null) {
child.layout(x, cy - child.getMeasuredHeight() / 2, x + child.getMeasuredWidth(), cy + child.getMeasuredHeight() / 2);
Integer id = child instanceof EmojiTabButton ? ((EmojiTabButton) child).id : (child instanceof EmojiTabsView ? ((EmojiTabsView) child).id : null);
Long id = child instanceof EmojiTabButton ? ((EmojiTabButton) child).id() : (child instanceof EmojiTabsView ? (Long) ((EmojiTabsView) child).id : null);
if (animateAppear && child instanceof EmojiTabButton && ((EmojiTabButton) child).newly) {
((EmojiTabButton) child).newly = false;
child.setScaleX(0);
@ -131,8 +132,9 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
child.animate().scaleX(1f).scaleY(1f).alpha(1f).setDuration(HwEmojis.isHwEnabledOrPreparing() ? 0 : 200).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).start();
}
if (id != null) {
if (lastX.get(id) != null && lastX.get(id) != x) {
child.setTranslationX(lastX.get(id) - x);
Integer lx = lastX.get(id);
if (lx != null && lx != x && Math.abs(lx - x) < AndroidUtilities.dp(45)) {
child.setTranslationX(lx - x);
child.animate().translationX(0).setDuration(250).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).start();
}
lastX.put(id, x);
@ -142,7 +144,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
if (settingsTab != null) {
x += (!recentIsShown ? AndroidUtilities.dp(30 + 3) : 0);
Integer id = settingsTab.id;
Long id = settingsTab.id;
if (x + settingsTab.getMeasuredWidth() + getPaddingRight() <= EmojiTabsStrip.this.getMeasuredWidth()) {
settingsTab.layout(x = (r - l - getPaddingRight() - settingsTab.getMeasuredWidth()), cy - settingsTab.getMeasuredHeight() / 2, r - l - getPaddingRight(), cy + settingsTab.getMeasuredHeight() / 2);
} else {
@ -292,7 +294,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
if (includeRecent) {
contentView.addView(recentTab = new EmojiTabButton(context, recentDrawableId, false, false));
recentTab.id = "recent".hashCode();
recentTab.id = (long) "recent".hashCode();
}
if (!includeAnimated) {
for (int i = 0; i < emojiTabsDrawableIds.length; ++i) {
@ -302,12 +304,12 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} else {
if (includeStandard) {
contentView.addView(emojiTabs = new EmojiTabsView(context));
emojiTabs.id = "tabs".hashCode();
emojiTabs.id = (long) "tabs".hashCode();
}
packsIndexStart = contentView.getChildCount();
if (onSettingsOpen != null) {
contentView.addView(settingsTab = new EmojiTabButton(context, settingsDrawableId, false, true));
settingsTab.id = "settings".hashCode();
settingsTab.id = (long) "settings".hashCode();
settingsTab.setAlpha(0);
}
updateClickListeners();
@ -415,122 +417,6 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
}
private static class DelayedAnimatedEmojiDrawable extends Drawable {
int account;
int cacheType;
TLRPC.Document document;
long documentId;
AnimatedEmojiDrawable drawable;
int alpha = 0xFF;
public DelayedAnimatedEmojiDrawable(int account, int cacheType, TLRPC.Document document) {
this.account = account;
this.cacheType = cacheType;
this.document = document;
if (this.document != null) {
this.documentId = this.document.id;
}
}
public DelayedAnimatedEmojiDrawable(int account, int cacheType, long documentId) {
this.account = account;
this.cacheType = cacheType;
this.documentId = documentId;
}
public void load() {
if (drawable != null) {
return;
}
if (document != null) {
drawable = AnimatedEmojiDrawable.make(account, cacheType, document);
} else {
drawable = AnimatedEmojiDrawable.make(account, cacheType, documentId);
}
if (lastColorFilter != null) {
drawable.setColorFilter(lastColorFilter);
}
drawable.setAlpha(alpha);
drawable.setCallback(new Callback() {
@Override
public void invalidateDrawable(@NonNull Drawable who) {
DelayedAnimatedEmojiDrawable.this.invalidateSelf();
}
@Override
public void scheduleDrawable(@NonNull Drawable who, @NonNull Runnable what, long when) {
DelayedAnimatedEmojiDrawable.this.scheduleSelf(what, when);
}
@Override
public void unscheduleDrawable(@NonNull Drawable who, @NonNull Runnable what) {
DelayedAnimatedEmojiDrawable.this.unscheduleSelf(what);
}
});
if (view != null) {
view.invalidate();
}
invalidateSelf();
}
public boolean equals(long documentId) {
return this.documentId == documentId;
}
private View view;
public void updateView(View view) {
if (this.view == view) {
return;
}
if (this.view != null && drawable != null) {
drawable.removeView(this.view);
}
this.view = view;
if (this.view != null && drawable != null) {
drawable.addView(this.view);
}
}
public void removeView() {
if (view != null && drawable != null) {
drawable.removeView(view);
}
view = null;
}
@Override
public void draw(@NonNull Canvas canvas) {
if (drawable != null) {
drawable.setBounds(getBounds());
drawable.draw(canvas);
}
}
@Override
public void setAlpha(int alpha) {
this.alpha = alpha;
if (drawable != null) {
drawable.setAlpha(alpha);
}
}
private ColorFilter lastColorFilter;
@Override
public void setColorFilter(@Nullable ColorFilter colorFilter) {
lastColorFilter = colorFilter;
if (drawable != null) {
drawable.setColorFilter(lastColorFilter);
}
}
@Override
public int getOpacity() {
return PixelFormat.TRANSPARENT;
}
}
protected boolean isInstalled(EmojiView.EmojiPack pack) {
return pack.installed;
}
@ -596,19 +482,14 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
currentPackButton.setLock(null);
}
} else {
final boolean free = newPack.free; // isFreeEmojiPack(newPack.set, newPack.documents);
DelayedAnimatedEmojiDrawable drawable = currentPackButton == null || !(currentPackButton.getDrawable() instanceof DelayedAnimatedEmojiDrawable) ? null : (DelayedAnimatedEmojiDrawable) currentPackButton.getDrawable();
final boolean free = newPack.free;
TLRPC.Document thumbDocument = getThumbDocument(newPack.set, newPack.documents);
if (thumbDocument != null && (drawable == null || drawable.documentId != thumbDocument.id)) {
drawable = new DelayedAnimatedEmojiDrawable(UserConfig.selectedAccount, animatedEmojiCacheType, thumbDocument);
}
if (currentPackButton == null) {
currentPackButton = new EmojiTabButton(getContext(), drawable, free, false, false);
currentPackButton.setDrawable(drawable);
currentPackButton = new EmojiTabButton(getContext(), thumbDocument, free, false, false);
onTabCreate(currentPackButton);
contentView.addView(currentPackButton, packsIndexStart + i);
} else if (currentPackButton.getDrawable() != drawable) {
currentPackButton.setDrawable(drawable);
} else {
currentPackButton.setAnimatedEmojiDocument(thumbDocument);
}
currentPackButton.updateSelect(selected == i, false);
if (currentType == SelectAnimatedEmojiDialog.TYPE_AVATAR_CONSTRUCTOR) {
@ -625,147 +506,12 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
}
}
// for (int i = 0; i < emojipackTabs.size(); ++i) {
// EmojiTabButton emojipackTab = emojipackTabs.get(i);
// EmojiView.EmojiPack pack = null;
// if (emojipackTab != null && emojipackTab.id != null) {
// for (int j = 0; j < emojiPacks.size(); ++j) {
// EmojiView.EmojiPack p = emojiPacks.get(j);
// if (!includeFeatured && p.featured) {
// continue;
// }
// final int id = Objects.hash(p.set.id, p.featured);
// if (id == emojipackTab.id) {
// pack = p;
// break;
// }
// }
// }
//
// if (pack == null && emojipackTab != null) {
// Rect bounds = new Rect();
// bounds.set(emojipackTab.getLeft(), emojipackTab.getTop(), emojipackTab.getRight(), emojipackTab.getBottom());
// removingViews.put(emojipackTab, bounds);
// ValueAnimator anm = ValueAnimator.ofFloat(emojipackTab.getAlpha(), 0f);
// anm.addUpdateListener(a -> {
// float alpha = (float) a.getAnimatedValue();
// emojipackTab.setAlpha(alpha);
// emojipackTab.setScaleX(alpha);
// emojipackTab.setScaleY(alpha);
// contentView.invalidate();
// });
// anm.addListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationEnd(Animator animation) {
// removingViews.remove(emojipackTab);
// contentView.invalidate();
// }
// });
// anm.setDuration(200);
// anm.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT);
// anm.start();
// emojipackTabs.remove(i--);
// }
// if (emojipackTab != null) {
// emojipackTab.keepAttached = true;
// attachedEmojiPacks.add(emojipackTab);
// }
// contentView.removeView(emojipackTab);
// }
// for (int i = 0; i < emojiPacks.size(); ++i) {
// EmojiView.EmojiPack pack = emojiPacks.get(i);
// if (!includeFeatured && pack.featured) {
// continue;
// }
// final int id = Objects.hash(pack.set.id, pack.featured);
// EmojiTabButton emojipackTab = null;
// for (int j = 0; j < emojipackTabs.size(); ++j) {
// EmojiTabButton tab = emojipackTabs.get(j);
// if (tab != null && tab.id != null && tab.id == id) {
// emojipackTab = tab;
// break;
// }
// }
// final boolean free = isFreeEmojiPack(pack.set, pack.documents);
// DelayedAnimatedEmojiDrawable drawable = emojipackTab == null ? null : (DelayedAnimatedEmojiDrawable) emojipackTab.getDrawable();
// TLRPC.Document thumbDocument = getThumbDocument(pack.set, pack.documents);
// if (thumbDocument != null && (drawable == null || !drawable.equals(thumbDocument.id))) {
// drawable = new DelayedAnimatedEmojiDrawable(UserConfig.selectedAccount, animatedEmojiCacheType, thumbDocument);
// }
// if (emojipackTab == null) {
// emojipackTab = new EmojiTabButton(getContext(), drawable, free, false, false);
// emojipackTab.id = id;
// emojipackTab.setDrawable(drawable);
// onTabCreate(emojipackTab);
// emojipackTabs.add(emojipackTab);
// } else if (emojipackTab.getDrawable() != drawable) {
// emojipackTab.setDrawable(drawable);
// }
// if (currentType == SelectAnimatedEmojiDialog.TYPE_AVATAR_CONSTRUCTOR) {
// emojipackTab.setLock(null);
// } else if (!isPremium && !free) {
// emojipackTab.setLock(true);
// } else if (!this.isInstalled(pack)) {
// emojipackTab.setLock(false);
// } else {
// emojipackTab.setLock(null);
// }
// if (doAppearAnimation && !first) {
// emojipackTab.newly = false;
// }
// if (emojipackTab.getParent() instanceof ViewGroup) {
// ((ViewGroup) emojipackTab.getParent()).removeView(emojipackTab);
// }
// contentView.addView(emojipackTab);
// }
if (settingsTab != null) {
settingsTab.bringToFront();
if (settingsTab.getAlpha() < 1) {
settingsTab.animate().alpha(1f).setDuration(HwEmojis.isHwEnabledOrPreparing() ? 0 : 200).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
}
}
// if (doAppearAnimation) {
// if (emojipackTabs != null) {
// for (int i = 0; i < emojipackTabs.size(); ++i) {
// emojipackTabs.get(i).setScaleX(0);
// emojipackTabs.get(i).setScaleY(0);
// }
// }
// appearAnimation = ValueAnimator.ofFloat(0, 1);
// final OvershootInterpolator innerInterpolator = new OvershootInterpolator(3f);
// appearAnimation.addUpdateListener(anm -> {
// if (emojipackTabs == null) {
// return;
// }
// final float t = (float) anm.getAnimatedValue();
// final int count = emojipackTabs.size();
// final float dur = 1f / count * 4.5f;
// for (int i = 0; i < count; ++i) {
// final float off = i / (float) count * (1f - dur);
// final float T = MathUtils.clamp((t - off) / dur, 0, 1);
// final float scale = innerInterpolator.getInterpolation(T);
// emojipackTabs.get(i).setScaleX(scale);
// emojipackTabs.get(i).setScaleY(scale);
// }
// });
// appearAnimation.addListener(new AnimatorListenerAdapter() {
// @Override
// public void onAnimationCancel(Animator animation) {
// if (emojipackTabs == null) {
// return;
// }
// for (int i = 0; i < emojipackTabs.size(); ++i) {
// emojipackTabs.get(i).setScaleX(1);
// emojipackTabs.get(i).setScaleY(1);
// }
// }
// });
// appearAnimation.setStartDelay(150);
// appearAnimation.setDuration((emojipackTabs == null ? 0 : emojipackTabs.size()) * 75L);
// appearAnimation.setInterpolator(CubicBezierInterpolator.EASE_OUT);
// appearAnimation.start();
// }
for (int i = 0; i < attachedEmojiPacks.size(); i++) {
attachedEmojiPacks.get(i).keepAttached = false;
attachedEmojiPacks.get(i).updateAttachState();
@ -912,7 +658,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
public class EmojiTabButton extends ViewGroup {
public boolean shown = true;
public Integer id;
public Long id;
public boolean newly;
public boolean keepAttached;
private boolean isAnimatedEmoji;
@ -921,9 +667,20 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
private RLottieDrawable lottieDrawable;
private PremiumLockIconView lockView;
private boolean round, forceSelector;
DelayedAnimatedEmojiDrawable animatedEmoji;
TLRPC.Document animatedEmojiDocument;
AnimatedEmojiDrawable animatedEmoji;
boolean attached;
public Long id() {
if (id != null) {
return id;
}
if (animatedEmojiDocument != null) {
return animatedEmojiDocument.id;
}
return null;
}
public EmojiTabButton(Context context, int drawableId, int lottieId, boolean roundSelector, boolean forceSelector) {
super(context);
this.round = roundSelector;
@ -965,7 +722,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
addView(imageView);
}
public EmojiTabButton(Context context, Drawable drawable, boolean free, boolean roundSelector, boolean forceSelector) {
public EmojiTabButton(Context context, TLRPC.Document emojiDocument, boolean free, boolean roundSelector, boolean forceSelector) {
super(context);
this.newly = true;
this.round = roundSelector;
@ -1014,11 +771,9 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
super.setImageDrawable(drawable);
}
};
imageView.setImageDrawable(drawable);
if (drawable instanceof AnimatedEmojiDrawable || drawable instanceof DelayedAnimatedEmojiDrawable) {
animatedEmojiDocument = emojiDocument;
isAnimatedEmoji = true;
imageView.setColorFilter(getEmojiColorFilter());
}
addView(imageView);
lockView = new PremiumLockIconView(context, PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED, resourcesProvider) {
@ -1093,9 +848,26 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
return super.performClick();
}
public void setDrawable(Drawable drawable) {
setAnimatedEmojiDocument(null);
imageView.setImageDrawable(drawable);
}
public void setAnimatedEmojiDocument(TLRPC.Document document) {
if (animatedEmojiDocument == null || document == null || animatedEmojiDocument.id != document.id) {
if (animatedEmoji != null) {
animatedEmoji.removeView(imageView);
animatedEmoji = null;
imageView.setImageDrawable(null);
}
animatedEmojiDocument = document;
updateAttachState();
}
}
private void playAnimation() {
if (animatedEmoji != null && animatedEmoji.drawable != null) {
ImageReceiver imageReceiver = animatedEmoji.drawable.getImageReceiver();
if (animatedEmoji != null) {
ImageReceiver imageReceiver = animatedEmoji.getImageReceiver();
if (imageReceiver != null) {
if (imageReceiver.getAnimation() != null) {
imageReceiver.getAnimation().seekTo(0, true);
@ -1106,8 +878,8 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
private void stopAnimation() {
if (animatedEmoji != null && animatedEmoji.drawable != null) {
ImageReceiver imageReceiver = animatedEmoji.drawable.getImageReceiver();
if (animatedEmoji != null) {
ImageReceiver imageReceiver = animatedEmoji.getImageReceiver();
if (imageReceiver != null) {
if (imageReceiver.getLottieAnimation() != null) {
imageReceiver.getLottieAnimation().setCurrentFrame(0);
@ -1135,9 +907,6 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
if (lockView != null) {
lockView.invalidate();
}
if (imageView != null && imageView.getDrawable() instanceof DelayedAnimatedEmojiDrawable) {
((DelayedAnimatedEmojiDrawable) imageView.getDrawable()).load();
}
initLock();
if (imageView != null) {
imageView.invalidate();
@ -1150,8 +919,8 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
private void initLock() {
if (lockView != null && animatedEmoji != null && animatedEmoji.drawable != null) {
ImageReceiver imageReceiver = animatedEmoji.drawable.getImageReceiver();
if (lockView != null && animatedEmoji != null) {
ImageReceiver imageReceiver = animatedEmoji.getImageReceiver();
if (imageReceiver != null) {
lockView.setImageReceiver(imageReceiver);
}
@ -1249,29 +1018,6 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
return imageView != null ? imageView.getDrawable() : null;
}
public void setDrawable(Drawable drawable) {
DelayedAnimatedEmojiDrawable newEmoji = null;
if (drawable instanceof DelayedAnimatedEmojiDrawable) {
newEmoji = (DelayedAnimatedEmojiDrawable) drawable;
}
if (animatedEmoji != newEmoji) {
if (animatedEmoji != null) {
animatedEmoji.removeView();
}
animatedEmoji = newEmoji;
if (animatedEmoji != null && attached && isVisible) {
animatedEmoji.updateView(imageView);
}
if (isVisible && animatedEmoji != null) {
animatedEmoji.load();
}
initLock();
}
if (imageView != null) {
imageView.setImageDrawable(drawable);
}
}
@Override
protected void onAttachedToWindow() {
super.onAttachedToWindow();
@ -1287,13 +1033,27 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
private void updateAttachState() {
if (animatedEmoji != null) {
if ((keepAttached || attached) && isVisible) {
animatedEmoji.updateView(imageView);
if (imageView == null) {
return;
}
if (animatedEmoji != null && animatedEmojiDocument == null) {
animatedEmoji.removeView(imageView);
animatedEmoji = null;
imageView.setImageDrawable(null);
} else if (attached && isVisible) {
if (animatedEmoji == null && animatedEmojiDocument != null) {
animatedEmoji = AnimatedEmojiDrawable.make(UserConfig.selectedAccount, animatedEmojiCacheType, animatedEmojiDocument);
animatedEmoji.addView(imageView);
imageView.setImageDrawable(animatedEmoji);
}
} else {
animatedEmoji.removeView();
if (animatedEmoji != null) {
animatedEmoji.removeView(imageView);
animatedEmoji = null;
imageView.setImageDrawable(null);
}
}
updateLockImageReceiver();
}
private float selectT;
@ -1371,7 +1131,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
}
private class EmojiTabsView extends ScrollableHorizontalScrollView {
public int id;
public long id;
public EmojiTabsView(Context context) {
super(context);

View file

@ -3850,7 +3850,7 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
installedEmojiSets.add(set.set.id);
}
updateState(true);
});
}, false);
}
@Override
@ -5963,7 +5963,12 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
checkPanels();
}
} else if ((Integer) args[0] == MediaDataController.TYPE_EMOJIPACKS) {
emojiAdapter.notifyDataSetChanged((Boolean) args[1]);
if ((Boolean) args[1]) {
AndroidUtilities.cancelRunOnUIThread(updateStickersLoadedDelayed);
AndroidUtilities.runOnUIThread(updateStickersLoadedDelayed, 100);
} else {
emojiAdapter.notifyDataSetChanged(false);
}
}
} else if (id == NotificationCenter.recentDocumentsDidLoad) {
boolean isGif = (Boolean) args[0];
@ -7064,6 +7069,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
} else {
pack.documents = set.covers;
}
if (pack.documents == null || pack.documents.isEmpty()) {
continue;
}
pack.index = index++;
boolean premium = false;
for (int j = 0; j < pack.documents.size(); ++j) {
@ -7157,6 +7165,9 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
trendingHeaderRow = itemCount++;
trendingRow = itemCount++;
recentlyUsedHeaderRow = itemCount++;
rowHashCodes.add(324953);
rowHashCodes.add(123342);
rowHashCodes.add(929132);
} else {
trendingHeaderRow = -1;
trendingRow = -1;
@ -7199,14 +7210,14 @@ public class EmojiView extends FrameLayout implements NotificationCenter.Notific
if (!pack.expanded && pack.documents.size() > maxlen) {
count--;
}
rowHashCodes.add(Objects.hash(pack.featured ? 56345 : -645231, (pack.set == null ? b : pack.set.id)));
rowHashCodes.add(Objects.hash(pack.featured ? 56345 : -495231, (pack.set == null ? b : pack.set.id)));
for (int i = 1; i < count; ++i) {
rowHashCodes.add(Objects.hash(pack.featured ? 3442 : 3213, pack.documents.get(i - 1).id));
rowHashCodes.add(Objects.hash(pack.featured ? 3442 : -9964, pack.documents.get(i - 1).id));
}
itemCount += count;
if (!pack.expanded && pack.documents.size() > maxlen) {
positionToExpand.put(itemCount, b);
rowHashCodes.add(Objects.hash(-65174, pack.set.id));
rowHashCodes.add(Objects.hash(pack.featured ? -65174 : 92242, pack.set.id));
itemCount++;
}
// if (!pack.installed) {

View file

@ -6,7 +6,11 @@ import android.view.ScaleGestureDetector;
import android.view.View;
import android.widget.FrameLayout;
public class EntitiesContainerView extends FrameLayout implements ScaleGestureDetector.OnScaleGestureListener, RotationGestureDetector.OnRotationGestureListener {
import com.google.zxing.common.detector.MathUtils;
import org.telegram.messenger.AndroidUtilities;
public class EntitiesContainerView extends FrameLayout {
public interface EntitiesContainerViewDelegate {
boolean shouldReceiveTouches();
@ -15,17 +19,12 @@ public class EntitiesContainerView extends FrameLayout implements ScaleGestureDe
}
private EntitiesContainerViewDelegate delegate;
private ScaleGestureDetector gestureDetector;
private RotationGestureDetector rotationGestureDetector;
private float previousScale = 1.0f;
private float previousAngle;
private boolean hasTransformed;
public EntitiesContainerView(Context context, EntitiesContainerViewDelegate entitiesContainerViewDelegate) {
super(context);
gestureDetector = new ScaleGestureDetector(context, this);
rotationGestureDetector = new RotationGestureDetector(this);
delegate = entitiesContainerViewDelegate;
}
@ -41,6 +40,9 @@ public class EntitiesContainerView extends FrameLayout implements ScaleGestureDe
return count;
}
private float px, py;
private boolean cancelled;
@Override
public boolean onTouchEvent(MotionEvent event) {
EntityView selectedEntity = delegate.onSelectedEntityRequest();
@ -52,64 +54,40 @@ public class EntitiesContainerView extends FrameLayout implements ScaleGestureDe
int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) {
hasTransformed = false;
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_MOVE) {
selectedEntity.hasPanned = false;
selectedEntity.hasReleased = false;
px = event.getX();
py = event.getY();
cancelled = false;
} else if (!cancelled && action == MotionEvent.ACTION_MOVE) {
final float x = event.getX();
final float y = event.getY();
if (hasTransformed || MathUtils.distance(x, y, px, py) > AndroidUtilities.touchSlop) {
hasTransformed = true;
selectedEntity.hasPanned = true;
selectedEntity.pan(x - px, y - py);
px = x;
py = y;
}
} else if (action == MotionEvent.ACTION_UP || action == MotionEvent.ACTION_CANCEL) {
selectedEntity.hasPanned = false;
selectedEntity.hasReleased = true;
if (!hasTransformed && delegate != null) {
delegate.onEntityDeselect();
}
invalidate();
return false;
}
} else {
selectedEntity.hasPanned = false;
selectedEntity.hasReleased = true;
hasTransformed = false;
cancelled = true;
invalidate();
}
// gestureDetector.onTouchEvent(event);
// rotationGestureDetector.onTouchEvent(event);
return true;
}
@Override
public boolean onScale(ScaleGestureDetector detector) {
float sf = detector.getScaleFactor();
float newScale = sf / previousScale;
EntityView view = delegate.onSelectedEntityRequest();
view.scale(newScale);
previousScale = sf;
return false;
}
@Override
public boolean onScaleBegin(ScaleGestureDetector detector) {
previousScale = 1.0f;
hasTransformed = true;
return true;
}
@Override
public void onScaleEnd(ScaleGestureDetector detector) {
}
@Override
public void onRotationBegin(RotationGestureDetector rotationDetector) {
previousAngle = rotationDetector.getStartAngle();
hasTransformed = true;
}
@Override
public void onRotation(RotationGestureDetector rotationDetector) {
EntityView view = delegate.onSelectedEntityRequest();
float angle = rotationDetector.getAngle();
float delta = previousAngle - angle;
view.rotate(view.getRotation() + delta);
previousAngle = angle;
}
@Override
public void onRotationEnd(RotationGestureDetector rotationDetector) {
}
@Override
protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
if (child instanceof TextPaintView) {

View file

@ -68,8 +68,8 @@ public class EntityView extends FrameLayout {
private float previousLocationX, previousLocationY;
private float previousLocationX2, previousLocationY2;
private float previousLocationCX, previousLocationCY;
private boolean hasPanned = false;
private boolean hasReleased = false;
public boolean hasPanned = false;
public boolean hasReleased = false;
private boolean hasTransformed = false;
private boolean announcedDrag = false;
private boolean announcedMultitouchDrag = false;

View file

@ -32,6 +32,7 @@ import android.view.MotionEvent;
import android.view.View;
import android.view.ViewGroup;
import android.view.WindowManager;
import android.view.animation.OvershootInterpolator;
import android.widget.FrameLayout;
import android.widget.ImageView;
import android.widget.LinearLayout;
@ -93,6 +94,7 @@ import org.telegram.ui.Components.SizeNotifierFrameLayout;
import org.telegram.ui.Components.SizeNotifierFrameLayoutPhoto;
import org.telegram.ui.Components.StickerMasksAlert;
import org.telegram.ui.PhotoViewer;
import org.telegram.ui.Stories.recorder.EmojiBottomSheet;
import java.math.BigInteger;
import java.util.ArrayList;
@ -217,7 +219,7 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
} else if (key == Theme.key_actionBarDefaultSubmenuItem) {
return 0xFFFFFFFF;
} else if (key == Theme.key_dialogBackground) {
return -14803426;
return 0xFF1F1F1F;
} else if (key == Theme.key_dialogTextBlack) {
return -592138;
} else if (key == Theme.key_dialogTextGray3) {
@ -233,7 +235,7 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
} else if (key == Theme.key_chat_emojiPanelIcon) {
return -9539985;
} else if (key == Theme.key_chat_emojiPanelIconSelected) {
return -10177041;
return 0xffffffff;
} else if (key == Theme.key_windowBackgroundWhiteBlackText) {
return -1;
} else if (key == Theme.key_featuredStickers_addedIcon) {
@ -248,9 +250,14 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
return 0xFFFFFFFF;
} else if (key == Theme.key_profile_tabSelector) {
return 0x14FFFFFF;
} else if (key == Theme.key_chat_emojiSearchIcon || key == Theme.key_featuredStickers_addedIcon) {
return 0xFF878787;
} else if (key == Theme.key_chat_emojiSearchBackground) {
return 0x2E878787;
} else if (key == Theme.key_windowBackgroundGray) {
return 0xFF0D0D0D;
}
if (resourcesProvider != null) {
return resourcesProvider.getColor(key);
} else {
@ -1330,20 +1337,23 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
detectFaces();
}
}, 350);
StickerMasksAlert stickerMasksAlert = new StickerMasksAlert(getContext(), facesBitmap == null, resourcesProvider) {
EmojiBottomSheet emojiBottomSheet = new EmojiBottomSheet(getContext(), false, resourcesProvider) {
@Override
public void onDismissAnimationStart() {
super.onDismissAnimationStart();
switchTab(wasSelectedIndex);
public boolean canShowWidget(Integer id) {
return false;
}
};
stickerMasksAlert.setImageReceiverNumLevel(4 + 8 + 16, 4 + 8 + 16);
stickerMasksAlert.setDelegate((parentObject, sticker) -> createSticker(parentObject, sticker, true));
stickerMasksAlert.setOnDismissListener(dialog -> {
emojiBottomSheet.whenDocumentSelected((parentObject, document, isGif) -> {
StickerView stickerView = createSticker(parentObject, document, true);
if (isGif) {
stickerView.setScale(1.5f);
}
});
emojiBottomSheet.setOnDismissListener(di -> {
onOpenCloseStickersAlert(false);
switchTab(wasSelectedIndex);
});
stickerMasksAlert.show();
emojiBottomSheet.show();
onOpenCloseStickersAlert(true);
}
@ -2754,6 +2764,9 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh
LPhotoPaintView.this.didSetAnimatedSticker(drawable);
}
};
if (MessageObject.isTextColorEmoji(sticker)) {
view.centerImage.setColorFilter(new PorterDuffColorFilter(0xffffffff, PorterDuff.Mode.SRC_IN));
}
view.centerImage.setLayerNum(4 + 8);
if (position.position.x == entitiesView.getMeasuredWidth() / 2f) {
view.setStickyX(EntityView.STICKY_CENTER);

View file

@ -725,6 +725,7 @@ public class PhotoFilterView extends FrameLayout implements FilterShaders.Filter
blurLinearButton.setCompoundDrawablesWithIntrinsicBounds(null, drawable, null, null);
blurLinearButton.setTextColor(getThemedColor(Theme.key_dialogFloatingButton));
}
updateFiltersEmpty();
}
public MediaController.SavedFilterState getSavedFilterState() {

View file

@ -5873,20 +5873,20 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
}
totalOffset += storiesOverscroll;
if (dialogsHintCell != null) {
if (dialogsHintCell != null && dialogsHintCell.getVisibility() == View.VISIBLE) {
if (rightSlidingDialogContainer != null && rightSlidingDialogContainer.hasFragment()) {
totalOffset -= dialogsHintCell.getMeasuredHeight() * rightSlidingDialogContainer.openedProgress;
}
dialogsHintCell.setTranslationY(totalOffset);
totalOffset += dialogsHintCell.getMeasuredHeight();
}
if (authHintCell != null) {
if (authHintCell != null && authHintCell.getVisibility() == View.VISIBLE) {
if (rightSlidingDialogContainer != null && rightSlidingDialogContainer.hasFragment()) {
totalOffset -= authHintCell.getMeasuredHeight() * rightSlidingDialogContainer.openedProgress;
}
float authHintCellTranslation = authHintCell.getMeasuredHeight() * (1f - authHintCellProgress);
authHintCell.setTranslationY(-authHintCellTranslation + totalOffset);
totalOffset += authHintCellTranslation;
totalOffset += authHintCell.getMeasuredHeight() - authHintCellTranslation;
}
if (fragmentContextView != null) {
float from = 0;
@ -9726,7 +9726,6 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
if (Build.VERSION.SDK_INT >= 33) {
permissons.add(Manifest.permission.READ_MEDIA_IMAGES);
permissons.add(Manifest.permission.READ_MEDIA_VIDEO);
permissons.add(Manifest.permission.READ_MEDIA_AUDIO);
permissons.add(Manifest.permission.WRITE_EXTERNAL_STORAGE);
} else if ((Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && activity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
permissons.add(Manifest.permission.READ_EXTERNAL_STORAGE);

View file

@ -3681,57 +3681,38 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
if (!TextUtils.isEmpty(botAppMaybe)) {
TLRPC.User user = MessagesController.getInstance(intentAccount).getUser(peerId);
if (user != null && user.bot) {
if (user.bot_attach_menu) {
if (user.bot_attach_menu && !MediaDataController.getInstance(intentAccount).botInAttachMenu(user.id)) {
TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot();
getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId);
ConnectionsManager.getInstance(intentAccount).sendRequest(getAttachMenuBot, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> {
if (response1 instanceof TLRPC.TL_attachMenuBotsBot) {
processAttachMenuBot(intentAccount, peerId, attachMenuBotChoose, user, setAsAttachBot);
if (progress != null) {
progress.end();
}
AndroidUtilities.runOnUIThread(() -> {
try {
if (dismissLoading != null) {
dismissLoading.run();
});
}
} catch (Exception e) {
FileLog.e(e);
}
if (response1 instanceof TLRPC.TL_attachMenuBotsBot) {
WebAppDisclaimerAlert.show(this, ignore -> {
user.inactive = false;
MediaDataController.getInstance(currentAccount).applyAttachMenuBot((TLRPC.TL_attachMenuBotsBot) response1);
processWebAppBot(intentAccount, username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, folderSlug, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, state, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, botAppMaybe, botAppStartParam, progress, false, storyId, true, user, dismissLoading);
TLRPC.TL_messages_toggleBotInAttachMenu botRequest = new TLRPC.TL_messages_toggleBotInAttachMenu();
botRequest.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId);
botRequest.enabled = true;
botRequest.write_allowed = true;
ConnectionsManager.getInstance(intentAccount).sendRequest(botRequest, (response2, error2) -> AndroidUtilities.runOnUIThread(() -> {
if (response2 instanceof TLRPC.TL_boolTrue) {
MediaDataController.getInstance(intentAccount).loadAttachMenuBots(false, true, null);
}
}), ConnectionsManager.RequestFlagInvokeAfter | ConnectionsManager.RequestFlagFailOnServerErrors);
}, null);
}
}));
} else {
TLRPC.TL_messages_getBotApp getBotApp = new TLRPC.TL_messages_getBotApp();
TLRPC.TL_inputBotAppShortName app = new TLRPC.TL_inputBotAppShortName();
app.bot_id = MessagesController.getInstance(intentAccount).getInputUser(user);
app.short_name = botAppMaybe;
getBotApp.app = app;
ConnectionsManager.getInstance(intentAccount).sendRequest(getBotApp, (response1, error1) -> {
if (progress != null) {
progress.end();
}
if (error1 != null) {
AndroidUtilities.runOnUIThread(() -> runLinkRequest(intentAccount, username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, folderSlug, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, state, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, null, null, progress, forceNotInternalForApps, storyId));
} else {
TLRPC.TL_messages_botApp botApp = (TLRPC.TL_messages_botApp) response1;
AndroidUtilities.runOnUIThread(() -> {
dismissLoading.run();
AtomicBoolean allowWrite = new AtomicBoolean();
BaseFragment lastFragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
Runnable loadBotSheet = () -> {
BotWebViewSheet sheet = new BotWebViewSheet(LaunchActivity.this, lastFragment.getResourceProvider());
sheet.setParentActivity(LaunchActivity.this);
sheet.requestWebView(intentAccount, user.id, user.id, null, null, BotWebViewSheet.TYPE_WEB_VIEW_BOT_APP, 0, false, lastFragment, botApp.app, allowWrite.get(), botAppStartParam, user);
sheet.show();
if (botApp.inactive || forceNotInternalForApps) {
sheet.showJustAddedBulletin();
}
};
if (botApp.inactive || forceNotInternalForApps) {
AlertsCreator.createBotLaunchAlert(lastFragment, botApp, user, allowWrite, loadBotSheet);
} else {
loadBotSheet.run();
}
});
}
});
processWebAppBot(intentAccount, username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, folderSlug, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, state, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, botAppMaybe, botAppStartParam, progress, false, storyId, false, user, dismissLoading);
}
return;
}
@ -4656,6 +4637,87 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
}
}
private void processWebAppBot(final int intentAccount,
final String username,
final String group,
final String sticker,
final String emoji,
final String botUser,
final String botChat,
final String botChannel,
final String botChatAdminParams,
final String message,
final String contactToken,
final String folderSlug,
final boolean hasUrl,
final Integer messageId,
final Long channelId,
final Integer threadId,
final Integer commentId,
final String game,
final HashMap<String, String> auth,
final String lang,
final String unsupportedUrl,
final String code,
final String loginToken,
final TLRPC.TL_wallPaper wallPaper,
final String inputInvoiceSlug,
final String theme,
final String voicechat,
final String livestream,
final int state,
final int videoTimestamp,
final String setAsAttachBot,
final String attachMenuBotToOpen,
final String attachMenuBotChoose,
final String botAppMaybe,
final String botAppStartParam,
final Browser.Progress progress,
final boolean forceNotInternalForApps,
final int storyId,
boolean justAdded,
TLRPC.User user,
Runnable dismissLoading) {
TLRPC.TL_messages_getBotApp getBotApp = new TLRPC.TL_messages_getBotApp();
TLRPC.TL_inputBotAppShortName app = new TLRPC.TL_inputBotAppShortName();
app.bot_id = MessagesController.getInstance(intentAccount).getInputUser(user);
app.short_name = botAppMaybe;
getBotApp.app = app;
ConnectionsManager.getInstance(intentAccount).sendRequest(getBotApp, (response1, error1) -> {
if (progress != null) {
progress.end();
}
if (error1 != null) {
AndroidUtilities.runOnUIThread(() -> runLinkRequest(intentAccount, username, group, sticker, emoji, botUser, botChat, botChannel, botChatAdminParams, message, contactToken, folderSlug, hasUrl, messageId, channelId, threadId, commentId, game, auth, lang, unsupportedUrl, code, loginToken, wallPaper, inputInvoiceSlug, theme, voicechat, livestream, state, videoTimestamp, setAsAttachBot, attachMenuBotToOpen, attachMenuBotChoose, null, null, progress, forceNotInternalForApps, storyId));
} else {
TLRPC.TL_messages_botApp botApp = (TLRPC.TL_messages_botApp) response1;
AndroidUtilities.runOnUIThread(() -> {
dismissLoading.run();
AtomicBoolean allowWrite = new AtomicBoolean();
BaseFragment lastFragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1);
Runnable loadBotSheet = () -> {
BotWebViewSheet sheet = new BotWebViewSheet(LaunchActivity.this, lastFragment.getResourceProvider());
sheet.setParentActivity(LaunchActivity.this);
sheet.requestWebView(intentAccount, user.id, user.id, null, null, BotWebViewSheet.TYPE_WEB_VIEW_BOT_APP, 0, false, lastFragment, botApp.app, allowWrite.get(), botAppStartParam, user);
sheet.show();
if (justAdded) {
sheet.showJustAddedBulletin();
}
};
if (!user.bot_attach_menu && (botApp.inactive || forceNotInternalForApps)) {
AlertsCreator.createBotLaunchAlert(lastFragment, botApp, user, allowWrite, loadBotSheet);
} else {
loadBotSheet.run();
}
});
}
});
}
private void processAttachMenuBot(int intentAccount, long peerId, String attachMenuBotChoose, TLRPC.User user, String setAsAttachBot) {
TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot();
getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId);

View file

@ -14680,15 +14680,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
photosCounterView.setTranslationY(-dp(32));
photosCounterView.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
pickerView.setTranslationY(dp(32));
pickerView.animate().alpha(1).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
pickerViewSendButton.setTranslationY(dp(32));
pickerViewSendButton.setAlpha(0f);
pickerViewSendButton.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
captionEdit.setAddPhotoVisible(true, true);
videoPreviewFrame.setTranslationY(dp(32));
videoPreviewFrame.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();

View file

@ -305,6 +305,7 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
view = new View(getContext());
} else {
ContextLinkCell cell = new ContextLinkCell(getContext());
cell.getPhotoImage().setLayerNum(7);
cell.allowButtonBounce(true);
cell.setIsKeyboard(true);
cell.setCanPreviewGif(true);
@ -825,8 +826,10 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
packs.clear();
int i = 0;
if (currentType == PAGE_TYPE_STICKERS) {
if (hasWidgets()) {
documents.add(widgets);
itemsCount++;
}
ArrayList<TLRPC.Document> favorites = mediaDataController.getRecentStickers(MediaDataController.TYPE_FAVE);
if (favorites != null && !favorites.isEmpty()) {
@ -1268,6 +1271,10 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
return true;
}
public boolean hasWidgets() {
return canShowWidget(WIDGET_LOCATION) || canShowWidget(WIDGET_PHOTO);
}
@Override
public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.stickersDidLoad || id == NotificationCenter.groupStickersDidLoad) {
@ -2577,7 +2584,9 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
super(context);
setPadding(dp(0), 0, dp(0), 0);
if (canShowWidget(WIDGET_LOCATION))
widgets.add(new Button(WIDGET_LOCATION, R.drawable.map_pin3, LocaleController.getString(R.string.StoryWidgetLocation)));
if (canShowWidget(WIDGET_PHOTO))
widgets.add(new Button(WIDGET_PHOTO, R.drawable.files_gallery, LocaleController.getString(R.string.StoryWidgetPhoto)));
}

View file

@ -3259,6 +3259,8 @@ public class StoryRecorder implements NotificationCenter.NotificationCenterDeleg
previewView.updatePauseReason(5, false);
previewView.updatePauseReason(7, false);
videoTimeView.setVisibility(outputEntry != null && outputEntry.duration >= 30_000 ? View.VISIBLE : View.GONE);
captionContainer.setAlpha(1f);
captionContainer.setTranslationY(0);
}
if (toPage == PAGE_CAMERA && showSavedDraftHint) {
getDraftSavedHint().setVisibility(View.VISIBLE);

View file

@ -5752,6 +5752,7 @@
<string name="BotCantAddToAttachMenu">This bot can\'t be added to the attachment menu.</string>
<string name="BotAlreadyAddedToAttachMenu">This bot is already in your attachment menu.</string>
<string name="BotRemoveFromMenu">This will remove **%1$s** shortcuts from all menus.</string>
<string name="BotRemoveFromMenuAll">This will remove **%1$s** shortcuts from all menus.</string>
<string name="BotRemoveInlineFromMenu">Remove **%1$s** from suggestions?</string>
<string name="BotWebViewRequestGeolocationPermission">Allow **%1$s** to access to your location?\n\nThe developer of **%1$s** will be able to access your location when this web app is open.</string>
<string name="BotWebViewRequestGeolocationPermissionWithHint">Allow **%1$s** to access to your location?\n\nThe developer of **%1$s** will be able to access your location when this web app is open.\n\nGo to Settings > Permissions and turn **Location** on to share location data.</string>

View file

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