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 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 = 3867; public static int BUILD_VERSION = 3872;
public static String BUILD_VERSION_STRING = "10.0.8"; public static String BUILD_VERSION_STRING = "10.0.9";
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

@ -2994,10 +2994,10 @@ public class MediaDataController extends BaseController {
* @param toggle 0 - remove, 1 - archive, 2 - add * @param toggle 0 - remove, 1 - archive, 2 - add
*/ */
public void toggleStickerSet(Context context, TLObject stickerSetObject, int toggle, BaseFragment baseFragment, boolean showSettings, boolean showTooltip) { 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.StickerSet stickerSet;
TLRPC.TL_messages_stickerSet messages_stickerSet; TLRPC.TL_messages_stickerSet messages_stickerSet;
@ -3036,7 +3036,7 @@ public class MediaDataController extends BaseController {
stickerSets[type].remove(a); stickerSets[type].remove(a);
if (toggle == 2) { if (toggle == 2) {
stickerSets[type].add(0, set); stickerSets[type].add(0, set);
} else { } else if (forget) {
stickerSetsById.remove(set.set.id); stickerSetsById.remove(set.set.id);
installedStickerSetsById.remove(set.set.id); installedStickerSetsById.remove(set.set.id);
stickerSetsByName.remove(set.set.short_name); 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 ---------------- //---------------- BOT END ----------------
//---------------- EMOJI START ---------------- //---------------- EMOJI START ----------------

View file

@ -3604,7 +3604,15 @@ public class MessageObject {
} }
if (object == null && chats != null) { if (object == null && chats != null) {
object = chats.get(action.auto_setting_from); 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 { } else {
object = MessagesController.getInstance(currentAccount).getChat(-action.auto_setting_from);
}
}
if (object == null) {
object = fromObject; object = fromObject;
} }
messageText = replaceWithLink(AndroidUtilities.replaceTags(LocaleController.formatString("AutoDeleteGlobalAction", R.string.AutoDeleteGlobalAction, LocaleController.formatTTLString(action.period))), "un1", object); 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); startY = textY + currentMessageObject.textHeight + AndroidUtilities.dp(8);
linkX = unmovedTextX + AndroidUtilities.dp(1); linkX = unmovedTextX + AndroidUtilities.dp(1);
} }
startY += (int) transitionParams.deltaBottom;
int linkPreviewY = startY; int linkPreviewY = startY;
int smallImageStartY = 0; int smallImageStartY = 0;

View file

@ -423,6 +423,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
private SimpleTextView mentiondownButtonCounter; private SimpleTextView mentiondownButtonCounter;
private ImageView mentiondownButtonImage; private ImageView mentiondownButtonImage;
private Bulletin messageSeenPrivacyBulletin; private Bulletin messageSeenPrivacyBulletin;
TextView webBotTitle;
private int reactionsMentionCount; private int reactionsMentionCount;
private FrameLayout reactionsMentiondownButton; 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 { private interface ChatActivityDelegate {
default void openReplyMessage(int mid) { default void openReplyMessage(int mid) {
@ -13460,6 +13472,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
setMeasuredDimension(widthSize, heightSize); setMeasuredDimension(widthSize, heightSize);
heightSize -= getPaddingTop(); 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); measureChildWithMargins(actionBar, widthMeasureSpec, 0, heightMeasureSpec, 0);
int actionBarHeight = actionBar.getMeasuredHeight(); int actionBarHeight = actionBar.getMeasuredHeight();
if (actionBar.getVisibility() == VISIBLE) { if (actionBar.getVisibility() == VISIBLE) {
@ -14762,6 +14778,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not
public boolean canScrollAway() { public boolean canScrollAway() {
return false; return false;
} }
@Override
public boolean canCaptureMorePhotos() {
return false;
}
}, this); }, this);
} else { } else {
fillEditingMediaWithCaption(caption, null); 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); didPressMessageUrl(link, false, selectedObject, v instanceof ChatMessageCell ? (ChatMessageCell) v : null);
return true; 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) { if (selectedObject != null && selectedObject.messageOwner != null && selectedObject.messageOwner.originalLanguage != null) {
waitForLangDetection.set(false); waitForLangDetection.set(false);
String fromLang = selectedObject.messageOwner.originalLanguage; String fromLang = selectedObject.messageOwner.originalLanguage;

View file

@ -49,17 +49,14 @@ 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.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;
@ -1214,7 +1211,14 @@ public abstract class BotWebViewContainer extends FrameLayout implements Notific
case "web_app_set_header_color": { case "web_app_set_header_color": {
try { try {
JSONObject jsonObject = new JSONObject(eventData); 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; int themeKey = -1;
switch (key) { switch (key) {
case "bg_color": { case "bg_color": {
@ -1227,7 +1231,8 @@ public abstract class BotWebViewContainer extends FrameLayout implements Notific
} }
} }
if (themeKey >= 0) { if (themeKey >= 0) {
delegate.onWebAppSetActionBarColor(themeKey); delegate.onWebAppSetActionBarColor(Theme.getColor(themeKey, resourcesProvider), false);
}
} }
} catch (JSONException e) { } catch (JSONException e) {
FileLog.e(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 * Called when WebView requests to set action bar color
* *
* @param colorKey Color theme key * @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 * Called when WebView requests to set background color

View file

@ -1,15 +1,19 @@
package org.telegram.ui.Components; package org.telegram.ui.Components;
import static org.telegram.ui.ActionBar.Theme.key_windowBackgroundWhiteBlackText;
import android.animation.Animator; import android.animation.Animator;
import android.animation.AnimatorListenerAdapter; import android.animation.AnimatorListenerAdapter;
import android.animation.ValueAnimator; import android.animation.ValueAnimator;
import android.annotation.SuppressLint; import android.annotation.SuppressLint;
import android.content.Context; import android.content.Context;
import android.graphics.Canvas; import android.graphics.Canvas;
import android.graphics.Color;
import android.graphics.Paint; import android.graphics.Paint;
import android.os.Build; import android.os.Build;
import android.os.Bundle; import android.os.Bundle;
import android.text.Editable; import android.text.Editable;
import android.util.SparseIntArray;
import android.view.Gravity; import android.view.Gravity;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -106,6 +110,7 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
private boolean overrideBackgroundColor; private boolean overrideBackgroundColor;
private boolean needCloseConfirmation; private boolean needCloseConfirmation;
ActionBarColorsAnimating actionBarColors;
private Runnable pollRunnable = () -> { private Runnable pollRunnable = () -> {
if (!dismissed) { if (!dismissed) {
@ -126,6 +131,8 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
})); }));
} }
}; };
private boolean actionBarIsLight;
private int lineColor;
private void checkBotMenuItem() { private void checkBotMenuItem() {
if (botMenuItem == null) { if (botMenuItem == null) {
@ -139,6 +146,9 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
public BotWebViewMenuContainer(@NonNull Context context, ChatActivityEnterView parentEnterView) { public BotWebViewMenuContainer(@NonNull Context context, ChatActivityEnterView parentEnterView) {
super(context); super(context);
actionBarColors = new ActionBarColorsAnimating();
actionBarColors.setTo(0, null);
actionBarColors.progress = 1;
this.parentEnterView = parentEnterView; this.parentEnterView = parentEnterView;
ChatActivity chatActivity = parentEnterView.getParentFragment(); ChatActivity chatActivity = parentEnterView.getParentFragment();
@ -164,10 +174,15 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
} }
@Override @Override
public void onWebAppSetActionBarColor(int colorKey) { public void onWebAppSetActionBarColor(int color, boolean isOverrideColor) {
int from = overrideActionBarBackground; 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) { if (from == 0) {
overrideActionBarBackground = to; overrideActionBarBackground = to;
} }
@ -175,11 +190,13 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200); ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT); animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> { animator.addUpdateListener(animation -> {
float progress = (float) animation.getAnimatedValue();
if (from != 0) { if (from != 0) {
overrideActionBarBackground = ColorUtils.blendARGB(from, to, (float) animation.getAnimatedValue()); overrideActionBarBackground = ColorUtils.blendARGB(from, to, progress);
} else { } else {
overrideActionBarBackgroundProgress = (float) animation.getAnimatedValue(); overrideActionBarBackgroundProgress = progress;
} }
actionBarColors.progress = progress;
actionBarPaint.setColor(overrideActionBarBackground); actionBarPaint.setColor(overrideActionBarBackground);
invalidateActionBar(); invalidateActionBar();
}); });
@ -393,21 +410,22 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
return; 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(); ActionBar actionBar = chatActivity.getActionBar();
int backgroundColor = ColorUtils.blendARGB(getColor(Theme.key_actionBarDefault), getColor(Theme.key_windowBackgroundWhite), actionBarTransitionProgress); 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.setBackgroundColor(backgroundColor);
actionBar.setItemsColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultIcon), getColor(Theme.key_windowBackgroundWhiteBlackText), actionBarTransitionProgress), false); actionBar.setItemsColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultIcon), actionBarColors.getColor(key_windowBackgroundWhiteBlackText), actionBarTransitionProgress), false);
actionBar.setItemsBackgroundColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultSelector), getColor(Theme.key_actionBarWhiteSelector), actionBarTransitionProgress), false); actionBar.setItemsBackgroundColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultSelector), actionBarColors.getColor(Theme.key_actionBarWhiteSelector), actionBarTransitionProgress), false);
actionBar.setSubtitleColor(subtitleColor);
ChatAvatarContainer chatAvatarContainer = chatActivity.getAvatarContainer(); ChatAvatarContainer chatAvatarContainer = chatActivity.getAvatarContainer();
chatAvatarContainer.getTitleTextView().setTextColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultTitle), getColor(Theme.key_windowBackgroundWhiteBlackText), actionBarTransitionProgress)); chatAvatarContainer.setAlpha(1f - actionBarTransitionProgress);
chatAvatarContainer.getSubtitleTextView().setTextColor(subtitleColor); chatActivity.getOrCreateWebBotTitleView().setAlpha(actionBarTransitionProgress);
chatAvatarContainer.setOverrideSubtitleColor(actionBarTransitionProgress == 0 ? null : subtitleColor); chatActivity.getOrCreateWebBotTitleView().setTextColor(ColorUtils.blendARGB(getColor(Theme.key_actionBarDefaultIcon), actionBarColors.getColor(key_windowBackgroundWhiteBlackText), actionBarTransitionProgress));
updateLightStatusBar(); updateLightStatusBar();
} }
@ -652,7 +670,7 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
float radius = AndroidUtilities.dp(16) * (1f - actionBarTransitionProgress); float radius = AndroidUtilities.dp(16) * (1f - actionBarTransitionProgress);
AndroidUtilities.rectTmp.set(0, AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), getWidth(), swipeContainer.getTranslationY() + AndroidUtilities.dp(24) + radius); AndroidUtilities.rectTmp.set(0, AndroidUtilities.lerp(swipeContainer.getTranslationY(), 0, actionBarTransitionProgress), getWidth(), swipeContainer.getTranslationY() + AndroidUtilities.dp(24) + radius);
canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, actionBarPaint); canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius,actionBarPaint );
AndroidUtilities.rectTmp.set(0, swipeContainer.getTranslationY() + AndroidUtilities.dp(24), getWidth(), getHeight() + radius); AndroidUtilities.rectTmp.set(0, swipeContainer.getTranslationY() + AndroidUtilities.dp(24), getWidth(), getHeight() + radius);
canvas.drawRect(AndroidUtilities.rectTmp, backgroundPaint); canvas.drawRect(AndroidUtilities.rectTmp, backgroundPaint);
@ -672,7 +690,9 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
public void draw(Canvas canvas) { public void draw(Canvas canvas) {
super.draw(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))); linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, actionBarTransitionProgress) / 0.5f)));
canvas.save(); canvas.save();
@ -702,6 +722,8 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
ChatActivity chatActivity = parentEnterView.getParentFragment(); ChatActivity chatActivity = parentEnterView.getParentFragment();
if (chatActivity != null) { if (chatActivity != null) {
chatActivity.hideFieldPanel(true); chatActivity.hideFieldPanel(true);
TextView webViewTitle = chatActivity.getOrCreateWebBotTitleView();
webViewTitle.setText(chatActivity.getCurrentUser().first_name);
} }
if (!isLoaded) { if (!isLoaded) {
@ -752,7 +774,7 @@ public class BotWebViewMenuContainer extends FrameLayout implements Notification
JSONObject jsonObject = new JSONObject(); JSONObject jsonObject = new JSONObject();
jsonObject.put("bg_color", getColor(Theme.key_windowBackgroundWhite)); jsonObject.put("bg_color", getColor(Theme.key_windowBackgroundWhite));
jsonObject.put("secondary_bg_color", getColor(Theme.key_windowBackgroundGray)); 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("hint_color", getColor(Theme.key_windowBackgroundWhiteHintText));
jsonObject.put("link_color", getColor(Theme.key_windowBackgroundWhiteLinkText)); jsonObject.put("link_color", getColor(Theme.key_windowBackgroundWhiteLinkText));
jsonObject.put("button_color", getColor(Theme.key_featuredStickers_addButton)); 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); 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.content.ContextCompat;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.core.math.MathUtils; import androidx.core.math.MathUtils;
import androidx.dynamicanimation.animation.DynamicAnimation;
import androidx.dynamicanimation.animation.SpringAnimation; import androidx.dynamicanimation.animation.SpringAnimation;
import androidx.dynamicanimation.animation.SpringForce; 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_INLINE_SWITCH = 1;
public final static int FLAG_FROM_SIDE_MENU = 2; public final static int FLAG_FROM_SIDE_MENU = 2;
private int lineColor;
public void showJustAddedBulletin() { public void showJustAddedBulletin() {
TLRPC.User user = MessagesController.getInstance(currentAccount).getUser(botId); 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 Paint backgroundPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private int actionBarColor; private int actionBarColor;
private boolean actionBarIsLight;
private Paint actionBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG); private Paint actionBarPaint = new Paint(Paint.ANTI_ALIAS_FLAG);
private boolean overrideBackgroundColor; private boolean overrideBackgroundColor;
@ -202,6 +203,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
public BotWebViewSheet(@NonNull Context context, Theme.ResourcesProvider resourcesProvider) { public BotWebViewSheet(@NonNull Context context, Theme.ResourcesProvider resourcesProvider) {
super(context, R.style.TransparentDialog); super(context, R.style.TransparentDialog);
this.resourcesProvider = resourcesProvider; this.resourcesProvider = resourcesProvider;
lineColor = Theme.getColor(Theme.key_sheet_scrollUp);
swipeContainer = new ChatAttachAlertBotWebViewLayout.WebViewSwipeContainer(context) { swipeContainer = new ChatAttachAlertBotWebViewLayout.WebViewSwipeContainer(context) {
@Override @Override
@ -279,28 +281,40 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
} }
@Override @Override
public void onWebAppSetActionBarColor(int colorKey) { public void onWebAppSetActionBarColor(int color, boolean isOverrideColor) {
int from = actionBarColor; 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); ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT); animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> { 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(); frameLayout.invalidate();
}); });
animator.start(); animator.start();
updateLightStatusBar();
} }
@Override @Override
public void onWebAppSetBackgroundColor(int color) { public void onWebAppSetBackgroundColor(int color) {
overrideBackgroundColor = true;
int from = backgroundPaint.getColor(); int from = backgroundPaint.getColor();
ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200); ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT); animator.setInterpolator(CubicBezierInterpolator.DEFAULT);
animator.addUpdateListener(animation -> { animator.addUpdateListener(animation -> {
backgroundPaint.setColor(ColorUtils.blendARGB(from, color, (Float) animation.getAnimatedValue())); backgroundPaint.setColor(ColorUtils.blendARGB(from, color, (Float) animation.getAnimatedValue()));
updateActionBarColors();
frameLayout.invalidate(); frameLayout.invalidate();
}); });
animator.start(); animator.start();
@ -488,7 +502,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight()); AndroidUtilities.rectTmp.set(0, 0, getWidth(), getHeight());
canvas.drawRect(AndroidUtilities.rectTmp, dimPaint); canvas.drawRect(AndroidUtilities.rectTmp, dimPaint);
actionBarPaint.setColor(ColorUtils.blendARGB(actionBarColor, getColor(Theme.key_windowBackgroundWhite), actionBarTransitionProgress)); actionBarPaint.setColor(actionBarColor);
float radius = AndroidUtilities.dp(16) * (AndroidUtilities.isTablet() ? 1f : 1f - actionBarTransitionProgress); 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); 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); canvas.drawRoundRect(AndroidUtilities.rectTmp, radius, radius, actionBarPaint);
@ -503,7 +517,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
super.draw(canvas); super.draw(canvas);
float transitionProgress = AndroidUtilities.isTablet() ? 0 : actionBarTransitionProgress; 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))); linePaint.setAlpha((int) (linePaint.getAlpha() * (1f - Math.min(0.5f, transitionProgress) / 0.5f)));
canvas.save(); canvas.save();
@ -716,6 +730,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
} }
private void updateActionBarColors() { private void updateActionBarColors() {
if (!overrideBackgroundColor) {
actionBar.setTitleColor(getColor(Theme.key_windowBackgroundWhiteBlackText)); actionBar.setTitleColor(getColor(Theme.key_windowBackgroundWhiteBlackText));
actionBar.setItemsColor(getColor(Theme.key_windowBackgroundWhiteBlackText), false); actionBar.setItemsColor(getColor(Theme.key_windowBackgroundWhiteBlackText), false);
actionBar.setItemsBackgroundColor(getColor(Theme.key_actionBarWhiteSelector), 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.setPopupItemsColor(getColor(Theme.key_actionBarDefaultSubmenuItemIcon), true, false);
actionBar.setPopupItemsSelectorColor(getColor(Theme.key_dialogButtonSelector), false); actionBar.setPopupItemsSelectorColor(getColor(Theme.key_dialogButtonSelector), false);
} }
}
private void updateLightStatusBar() { private void updateLightStatusBar() {
boolean lightStatusBar;
if (overrideBackgroundColor) {
lightStatusBar = !actionBarIsLight;
} else {
int color = Theme.getColor(Theme.key_windowBackgroundWhite, null, true); int color = Theme.getColor(Theme.key_windowBackgroundWhite, null, true);
boolean lightStatusBar = !AndroidUtilities.isTablet() && ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f; lightStatusBar = !AndroidUtilities.isTablet() && ColorUtils.calculateLuminance(color) >= 0.9 && actionBarTransitionProgress >= 0.85f;
}
if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) { if (wasLightStatusBar != null && wasLightStatusBar == lightStatusBar) {
return; return;
} }
@ -945,6 +965,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
req.theme_params.data = themeParams; req.theme_params.data = themeParams;
req.flags |= 1; req.flags |= 1;
} }
req.flags |= 8;
req.url = buttonUrl; req.url = buttonUrl;
ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> { ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> AndroidUtilities.runOnUIThread(() -> {
@ -1037,7 +1058,7 @@ public class BotWebViewSheet extends Dialog implements NotificationCenter.Notifi
return; return;
} }
String botName = currentBot.short_name; 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; TLRPC.TL_attachMenuBot finalCurrentBot = currentBot;
new AlertDialog.Builder(LaunchActivity.getLastFragment().getContext()) new AlertDialog.Builder(LaunchActivity.getLastFragment().getContext())
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle)) .setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))

View file

@ -142,6 +142,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
public boolean allowEnterCaption; public boolean allowEnterCaption;
private ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate documentsDelegate; private ChatAttachAlertDocumentLayout.DocumentSelectActivityDelegate documentsDelegate;
private long dialogId; private long dialogId;
private boolean overrideBackgroundColor;
public void setCanOpenPreview(boolean canOpenPreview) { public void setCanOpenPreview(boolean canOpenPreview) {
this.canOpenPreview = canOpenPreview; this.canOpenPreview = canOpenPreview;
@ -187,13 +188,26 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
} }
@Override @Override
public void onWebAppSetActionBarColor(int colorKey) { public void onWebAppSetActionBarColor(int color, boolean isOverrideColor) {
int from = ((ColorDrawable) actionBar.getBackground()).getColor(); 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); ValueAnimator animator = ValueAnimator.ofFloat(0, 1).setDuration(200);
animator.setInterpolator(CubicBezierInterpolator.DEFAULT); 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(); animator.start();
} }
@ -583,6 +597,15 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
return 0; return 0;
} }
boolean hasCustomActionBarBackground() {
return false;
}
int getCustomActionBarBackground() {
return 0;
}
void onButtonsTranslationYUpdated() { void onButtonsTranslationYUpdated() {
} }
@ -1617,8 +1640,8 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
canvas.restore(); canvas.restore();
} }
if (rad != 1.0f && actionBarType != 2) { if ((rad != 1.0f && actionBarType != 2) || currentAttachLayout.hasCustomActionBarBackground()) {
Theme.dialogs_onlineCirclePaint.setColor(backgroundColor); Theme.dialogs_onlineCirclePaint.setColor(currentAttachLayout.hasCustomActionBarBackground() ? currentAttachLayout.getCustomActionBarBackground() : backgroundColor);
Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha); Theme.dialogs_onlineCirclePaint.setAlpha(viewAlpha);
rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24)); rect.set(backgroundPaddingLeft, backgroundPaddingTop + top, getMeasuredWidth() - backgroundPaddingLeft, backgroundPaddingTop + top + AndroidUtilities.dp(24));
canvas.save(); canvas.save();
@ -1627,6 +1650,19 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
canvas.restore(); 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) { if ((headerView == null || headerView.getAlpha() != 1.0f) && rad != 0) {
int w = AndroidUtilities.dp(36); int w = AndroidUtilities.dp(36);
rect.set((getMeasuredWidth() - w) / 2, y, (getMeasuredWidth() + w) / 2, y + AndroidUtilities.dp(4)); 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) { if (actionBarType == 2) {
color = 0x20000000; color = 0x20000000;
alphaProgress = rad; 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 { } else {
color = getThemedColor(Theme.key_sheet_scrollUp); color = getThemedColor(Theme.key_sheet_scrollUp);
alphaProgress = headerView == null ? 1.0f : 1.0f - headerView.getAlpha(); alphaProgress = headerView == null ? 1.0f : 1.0f - headerView.getAlpha();
@ -1777,10 +1818,6 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
if (inBubbleMode) { if (inBubbleMode) {
return; 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() { private int getCurrentTop() {
@ -2801,7 +2838,7 @@ public class ChatAttachAlert extends BottomSheet implements NotificationCenter.N
break; break;
} }
} }
description = LocaleController.formatString("BotRemoveFromMenu", R.string.BotRemoveFromMenu, botName); description = LocaleController.formatString("BotRemoveFromMenuAll", R.string.BotRemoveFromMenuAll, botName);
new AlertDialog.Builder(getContext()) new AlertDialog.Builder(getContext())
.setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle)) .setTitle(LocaleController.getString(R.string.BotRemoveFromMenuTitle))
.setMessage(AndroidUtilities.replaceTags(attachMenuBot != null ? description : LocaleController.formatString("BotRemoveInlineFromMenu", R.string.BotRemoveInlineFromMenu, botName))) .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) { public ChatAttachAlertBotWebViewLayout(ChatAttachAlert alert, Context context, Theme.ResourcesProvider resourcesProvider) {
super(alert, context, resourcesProvider); super(alert, context, resourcesProvider);
@ -279,6 +281,21 @@ public class ChatAttachAlertBotWebViewLayout extends ChatAttachAlert.AttachAlert
return customBackground; 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() { public boolean canExpandByRequest() {
return /* System.currentTimeMillis() - lastSwipeTime > 1000 && */ !swipeContainer.isSwipeInProgress(); return /* System.currentTimeMillis() - lastSwipeTime > 1000 && */ !swipeContainer.isSwipeInProgress();
} }

View file

@ -3072,16 +3072,22 @@ public class ChatAttachAlertPhotoLayout extends ChatAttachAlert.AttachAlertLayou
if (count == 0) { if (count == 0) {
parentAlert.selectedMenuItem.showSubItem(open_in); parentAlert.selectedMenuItem.showSubItem(open_in);
parentAlert.selectedMenuItem.hideSubItem(compress); parentAlert.selectedMenuItem.hideSubItem(compress);
} else { } else if (documentsEnabled) {
parentAlert.selectedMenuItem.showSubItem(compress); parentAlert.selectedMenuItem.showSubItem(compress);
} else {
parentAlert.selectedMenuItem.hideSubItem(compress);
} }
} else { } else {
parentAlert.selectedMenuItem.showSubItem(group); parentAlert.selectedMenuItem.showSubItem(group);
if (documentsEnabled) {
parentAlert.selectedMenuItem.showSubItem(compress);
} else {
parentAlert.selectedMenuItem.hideSubItem(compress);
}
} }
if (count != 0) { if (count != 0) {
parentAlert.selectedMenuItem.hideSubItem(open_in); parentAlert.selectedMenuItem.hideSubItem(open_in);
} }
compressItem.setVisibility(documentsEnabled ? View.VISIBLE : View.GONE);
if (count > 1) { if (count > 1) {
parentAlert.selectedMenuItem.showSubItem(preview_gap); parentAlert.selectedMenuItem.showSubItem(preview_gap);
parentAlert.selectedMenuItem.showSubItem(preview); 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) { if (fragment == null || set == null || fragment.getFragmentView() == null) {
return; 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) { public static void uninstallSet(Context context, TLRPC.TL_messages_stickerSet set, boolean showBulletin, Runnable onUndo) {
if (set == null) { if (set == null) {
return; 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; private ValueAnimator loadAnimator;
@ -1607,7 +1607,7 @@ public class EmojiPacksAlert extends BottomSheet implements NotificationCenter.N
removeButtonView.setOnClickListener(e -> { removeButtonView.setOnClickListener(e -> {
uninstallSet(dummyFragment, set, true, () -> { uninstallSet(dummyFragment, set, true, () -> {
toggle(true, true); toggle(true, true);
}); }, true);
toggle(false, true); toggle(false, true);
}); });
removeButtonView.setClickable(false); removeButtonView.setClickable(false);

View file

@ -25,6 +25,7 @@ import android.widget.LinearLayout;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.collection.LongSparseArray;
import androidx.core.graphics.ColorUtils; import androidx.core.graphics.ColorUtils;
import androidx.core.math.MathUtils; import androidx.core.math.MathUtils;
@ -108,7 +109,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
contentView = new LinearLayout(context) { contentView = new LinearLayout(context) {
HashMap<Integer, Integer> lastX = new HashMap<>(); private final LongSparseArray<Integer> lastX = new LongSparseArray<>();
@Override @Override
protected void onLayout(boolean changed, int l, int t, int r, int b) { 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) { if (child != null) {
child.layout(x, cy - child.getMeasuredHeight() / 2, x + child.getMeasuredWidth(), cy + child.getMeasuredHeight() / 2); 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) { if (animateAppear && child instanceof EmojiTabButton && ((EmojiTabButton) child).newly) {
((EmojiTabButton) child).newly = false; ((EmojiTabButton) child).newly = false;
child.setScaleX(0); 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(); child.animate().scaleX(1f).scaleY(1f).alpha(1f).setDuration(HwEmojis.isHwEnabledOrPreparing() ? 0 : 200).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).start();
} }
if (id != null) { if (id != null) {
if (lastX.get(id) != null && lastX.get(id) != x) { Integer lx = lastX.get(id);
child.setTranslationX(lastX.get(id) - x); 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(); child.animate().translationX(0).setDuration(250).setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT).start();
} }
lastX.put(id, x); lastX.put(id, x);
@ -142,7 +144,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} }
if (settingsTab != null) { if (settingsTab != null) {
x += (!recentIsShown ? AndroidUtilities.dp(30 + 3) : 0); x += (!recentIsShown ? AndroidUtilities.dp(30 + 3) : 0);
Integer id = settingsTab.id; Long id = settingsTab.id;
if (x + settingsTab.getMeasuredWidth() + getPaddingRight() <= EmojiTabsStrip.this.getMeasuredWidth()) { 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); settingsTab.layout(x = (r - l - getPaddingRight() - settingsTab.getMeasuredWidth()), cy - settingsTab.getMeasuredHeight() / 2, r - l - getPaddingRight(), cy + settingsTab.getMeasuredHeight() / 2);
} else { } else {
@ -292,7 +294,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} }
if (includeRecent) { if (includeRecent) {
contentView.addView(recentTab = new EmojiTabButton(context, recentDrawableId, false, false)); contentView.addView(recentTab = new EmojiTabButton(context, recentDrawableId, false, false));
recentTab.id = "recent".hashCode(); recentTab.id = (long) "recent".hashCode();
} }
if (!includeAnimated) { if (!includeAnimated) {
for (int i = 0; i < emojiTabsDrawableIds.length; ++i) { for (int i = 0; i < emojiTabsDrawableIds.length; ++i) {
@ -302,12 +304,12 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} else { } else {
if (includeStandard) { if (includeStandard) {
contentView.addView(emojiTabs = new EmojiTabsView(context)); contentView.addView(emojiTabs = new EmojiTabsView(context));
emojiTabs.id = "tabs".hashCode(); emojiTabs.id = (long) "tabs".hashCode();
} }
packsIndexStart = contentView.getChildCount(); packsIndexStart = contentView.getChildCount();
if (onSettingsOpen != null) { if (onSettingsOpen != null) {
contentView.addView(settingsTab = new EmojiTabButton(context, settingsDrawableId, false, true)); contentView.addView(settingsTab = new EmojiTabButton(context, settingsDrawableId, false, true));
settingsTab.id = "settings".hashCode(); settingsTab.id = (long) "settings".hashCode();
settingsTab.setAlpha(0); settingsTab.setAlpha(0);
} }
updateClickListeners(); 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) { protected boolean isInstalled(EmojiView.EmojiPack pack) {
return pack.installed; return pack.installed;
} }
@ -596,19 +482,14 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
currentPackButton.setLock(null); currentPackButton.setLock(null);
} }
} else { } else {
final boolean free = newPack.free; // isFreeEmojiPack(newPack.set, newPack.documents); final boolean free = newPack.free;
DelayedAnimatedEmojiDrawable drawable = currentPackButton == null || !(currentPackButton.getDrawable() instanceof DelayedAnimatedEmojiDrawable) ? null : (DelayedAnimatedEmojiDrawable) currentPackButton.getDrawable();
TLRPC.Document thumbDocument = getThumbDocument(newPack.set, newPack.documents); 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) { if (currentPackButton == null) {
currentPackButton = new EmojiTabButton(getContext(), drawable, free, false, false); currentPackButton = new EmojiTabButton(getContext(), thumbDocument, free, false, false);
currentPackButton.setDrawable(drawable);
onTabCreate(currentPackButton); onTabCreate(currentPackButton);
contentView.addView(currentPackButton, packsIndexStart + i); contentView.addView(currentPackButton, packsIndexStart + i);
} else if (currentPackButton.getDrawable() != drawable) { } else {
currentPackButton.setDrawable(drawable); currentPackButton.setAnimatedEmojiDocument(thumbDocument);
} }
currentPackButton.updateSelect(selected == i, false); currentPackButton.updateSelect(selected == i, false);
if (currentType == SelectAnimatedEmojiDialog.TYPE_AVATAR_CONSTRUCTOR) { 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) { if (settingsTab != null) {
settingsTab.bringToFront(); settingsTab.bringToFront();
if (settingsTab.getAlpha() < 1) { if (settingsTab.getAlpha() < 1) {
settingsTab.animate().alpha(1f).setDuration(HwEmojis.isHwEnabledOrPreparing() ? 0 : 200).setInterpolator(CubicBezierInterpolator.DEFAULT).start(); 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++) { for (int i = 0; i < attachedEmojiPacks.size(); i++) {
attachedEmojiPacks.get(i).keepAttached = false; attachedEmojiPacks.get(i).keepAttached = false;
attachedEmojiPacks.get(i).updateAttachState(); attachedEmojiPacks.get(i).updateAttachState();
@ -912,7 +658,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
public class EmojiTabButton extends ViewGroup { public class EmojiTabButton extends ViewGroup {
public boolean shown = true; public boolean shown = true;
public Integer id; public Long id;
public boolean newly; public boolean newly;
public boolean keepAttached; public boolean keepAttached;
private boolean isAnimatedEmoji; private boolean isAnimatedEmoji;
@ -921,9 +667,20 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
private RLottieDrawable lottieDrawable; private RLottieDrawable lottieDrawable;
private PremiumLockIconView lockView; private PremiumLockIconView lockView;
private boolean round, forceSelector; private boolean round, forceSelector;
DelayedAnimatedEmojiDrawable animatedEmoji; TLRPC.Document animatedEmojiDocument;
AnimatedEmojiDrawable animatedEmoji;
boolean attached; 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) { public EmojiTabButton(Context context, int drawableId, int lottieId, boolean roundSelector, boolean forceSelector) {
super(context); super(context);
this.round = roundSelector; this.round = roundSelector;
@ -965,7 +722,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
addView(imageView); 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); super(context);
this.newly = true; this.newly = true;
this.round = roundSelector; this.round = roundSelector;
@ -1014,11 +771,9 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
super.setImageDrawable(drawable); super.setImageDrawable(drawable);
} }
}; };
imageView.setImageDrawable(drawable); animatedEmojiDocument = emojiDocument;
if (drawable instanceof AnimatedEmojiDrawable || drawable instanceof DelayedAnimatedEmojiDrawable) {
isAnimatedEmoji = true; isAnimatedEmoji = true;
imageView.setColorFilter(getEmojiColorFilter()); imageView.setColorFilter(getEmojiColorFilter());
}
addView(imageView); addView(imageView);
lockView = new PremiumLockIconView(context, PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED, resourcesProvider) { lockView = new PremiumLockIconView(context, PremiumLockIconView.TYPE_STICKERS_PREMIUM_LOCKED, resourcesProvider) {
@ -1093,9 +848,26 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
return super.performClick(); 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() { private void playAnimation() {
if (animatedEmoji != null && animatedEmoji.drawable != null) { if (animatedEmoji != null) {
ImageReceiver imageReceiver = animatedEmoji.drawable.getImageReceiver(); ImageReceiver imageReceiver = animatedEmoji.getImageReceiver();
if (imageReceiver != null) { if (imageReceiver != null) {
if (imageReceiver.getAnimation() != null) { if (imageReceiver.getAnimation() != null) {
imageReceiver.getAnimation().seekTo(0, true); imageReceiver.getAnimation().seekTo(0, true);
@ -1106,8 +878,8 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} }
private void stopAnimation() { private void stopAnimation() {
if (animatedEmoji != null && animatedEmoji.drawable != null) { if (animatedEmoji != null) {
ImageReceiver imageReceiver = animatedEmoji.drawable.getImageReceiver(); ImageReceiver imageReceiver = animatedEmoji.getImageReceiver();
if (imageReceiver != null) { if (imageReceiver != null) {
if (imageReceiver.getLottieAnimation() != null) { if (imageReceiver.getLottieAnimation() != null) {
imageReceiver.getLottieAnimation().setCurrentFrame(0); imageReceiver.getLottieAnimation().setCurrentFrame(0);
@ -1135,9 +907,6 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
if (lockView != null) { if (lockView != null) {
lockView.invalidate(); lockView.invalidate();
} }
if (imageView != null && imageView.getDrawable() instanceof DelayedAnimatedEmojiDrawable) {
((DelayedAnimatedEmojiDrawable) imageView.getDrawable()).load();
}
initLock(); initLock();
if (imageView != null) { if (imageView != null) {
imageView.invalidate(); imageView.invalidate();
@ -1150,8 +919,8 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} }
private void initLock() { private void initLock() {
if (lockView != null && animatedEmoji != null && animatedEmoji.drawable != null) { if (lockView != null && animatedEmoji != null) {
ImageReceiver imageReceiver = animatedEmoji.drawable.getImageReceiver(); ImageReceiver imageReceiver = animatedEmoji.getImageReceiver();
if (imageReceiver != null) { if (imageReceiver != null) {
lockView.setImageReceiver(imageReceiver); lockView.setImageReceiver(imageReceiver);
} }
@ -1249,29 +1018,6 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
return imageView != null ? imageView.getDrawable() : null; 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 @Override
protected void onAttachedToWindow() { protected void onAttachedToWindow() {
super.onAttachedToWindow(); super.onAttachedToWindow();
@ -1287,13 +1033,27 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} }
private void updateAttachState() { private void updateAttachState() {
if (animatedEmoji != null) { if (imageView == null) {
if ((keepAttached || attached) && isVisible) { return;
animatedEmoji.updateView(imageView); }
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 { } else {
animatedEmoji.removeView(); if (animatedEmoji != null) {
animatedEmoji.removeView(imageView);
animatedEmoji = null;
imageView.setImageDrawable(null);
} }
} }
updateLockImageReceiver();
} }
private float selectT; private float selectT;
@ -1371,7 +1131,7 @@ public class EmojiTabsStrip extends ScrollableHorizontalScrollView {
} }
private class EmojiTabsView extends ScrollableHorizontalScrollView { private class EmojiTabsView extends ScrollableHorizontalScrollView {
public int id; public long id;
public EmojiTabsView(Context context) { public EmojiTabsView(Context context) {
super(context); super(context);

View file

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

View file

@ -6,7 +6,11 @@ import android.view.ScaleGestureDetector;
import android.view.View; import android.view.View;
import android.widget.FrameLayout; 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 { public interface EntitiesContainerViewDelegate {
boolean shouldReceiveTouches(); boolean shouldReceiveTouches();
@ -15,17 +19,12 @@ public class EntitiesContainerView extends FrameLayout implements ScaleGestureDe
} }
private EntitiesContainerViewDelegate delegate; private EntitiesContainerViewDelegate delegate;
private ScaleGestureDetector gestureDetector;
private RotationGestureDetector rotationGestureDetector;
private float previousScale = 1.0f; private float previousScale = 1.0f;
private float previousAngle; private float previousAngle;
private boolean hasTransformed; private boolean hasTransformed;
public EntitiesContainerView(Context context, EntitiesContainerViewDelegate entitiesContainerViewDelegate) { public EntitiesContainerView(Context context, EntitiesContainerViewDelegate entitiesContainerViewDelegate) {
super(context); super(context);
gestureDetector = new ScaleGestureDetector(context, this);
rotationGestureDetector = new RotationGestureDetector(this);
delegate = entitiesContainerViewDelegate; delegate = entitiesContainerViewDelegate;
} }
@ -41,6 +40,9 @@ public class EntitiesContainerView extends FrameLayout implements ScaleGestureDe
return count; return count;
} }
private float px, py;
private boolean cancelled;
@Override @Override
public boolean onTouchEvent(MotionEvent event) { public boolean onTouchEvent(MotionEvent event) {
EntityView selectedEntity = delegate.onSelectedEntityRequest(); EntityView selectedEntity = delegate.onSelectedEntityRequest();
@ -52,64 +54,40 @@ public class EntitiesContainerView extends FrameLayout implements ScaleGestureDe
int action = event.getActionMasked(); int action = event.getActionMasked();
if (action == MotionEvent.ACTION_DOWN) { if (action == MotionEvent.ACTION_DOWN) {
hasTransformed = false; 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) { if (!hasTransformed && delegate != null) {
delegate.onEntityDeselect(); delegate.onEntityDeselect();
} }
invalidate();
return false; return false;
} }
} else {
selectedEntity.hasPanned = false;
selectedEntity.hasReleased = true;
hasTransformed = false;
cancelled = true;
invalidate();
} }
// gestureDetector.onTouchEvent(event);
// rotationGestureDetector.onTouchEvent(event);
return true; 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 @Override
protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) { protected void measureChildWithMargins(View child, int parentWidthMeasureSpec, int widthUsed, int parentHeightMeasureSpec, int heightUsed) {
if (child instanceof TextPaintView) { if (child instanceof TextPaintView) {

View file

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

View file

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

View file

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

View file

@ -3681,57 +3681,38 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
if (!TextUtils.isEmpty(botAppMaybe)) { if (!TextUtils.isEmpty(botAppMaybe)) {
TLRPC.User user = MessagesController.getInstance(intentAccount).getUser(peerId); TLRPC.User user = MessagesController.getInstance(intentAccount).getUser(peerId);
if (user != null && user.bot) { 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(); TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot();
getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId); getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId);
ConnectionsManager.getInstance(intentAccount).sendRequest(getAttachMenuBot, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> { ConnectionsManager.getInstance(intentAccount).sendRequest(getAttachMenuBot, (response1, error1) -> AndroidUtilities.runOnUIThread(() -> {
if (response1 instanceof TLRPC.TL_attachMenuBotsBot) { try {
processAttachMenuBot(intentAccount, peerId, attachMenuBotChoose, user, setAsAttachBot); if (dismissLoading != null) {
if (progress != null) {
progress.end();
}
AndroidUtilities.runOnUIThread(() -> {
dismissLoading.run(); 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 { } else {
TLRPC.TL_messages_getBotApp getBotApp = new TLRPC.TL_messages_getBotApp(); 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);
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();
}
});
}
});
} }
return; 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) { private void processAttachMenuBot(int intentAccount, long peerId, String attachMenuBotChoose, TLRPC.User user, String setAsAttachBot) {
TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot(); TLRPC.TL_messages_getAttachMenuBot getAttachMenuBot = new TLRPC.TL_messages_getAttachMenuBot();
getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId); getAttachMenuBot.bot = MessagesController.getInstance(intentAccount).getInputUser(peerId);

View file

@ -14680,15 +14680,12 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat
photosCounterView.setTranslationY(-dp(32)); photosCounterView.setTranslationY(-dp(32));
photosCounterView.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start(); photosCounterView.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
pickerView.setTranslationY(dp(32)); pickerView.setTranslationY(dp(32));
pickerView.animate().alpha(1).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start(); pickerView.animate().alpha(1).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
pickerViewSendButton.setTranslationY(dp(32)); pickerViewSendButton.setTranslationY(dp(32));
pickerViewSendButton.setAlpha(0f); pickerViewSendButton.setAlpha(0f);
pickerViewSendButton.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start(); pickerViewSendButton.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start();
captionEdit.setAddPhotoVisible(true, true);
videoPreviewFrame.setTranslationY(dp(32)); videoPreviewFrame.setTranslationY(dp(32));
videoPreviewFrame.animate().alpha(1).translationY(0).setDuration(150).setInterpolator(CubicBezierInterpolator.DEFAULT).start(); 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()); view = new View(getContext());
} else { } else {
ContextLinkCell cell = new ContextLinkCell(getContext()); ContextLinkCell cell = new ContextLinkCell(getContext());
cell.getPhotoImage().setLayerNum(7);
cell.allowButtonBounce(true); cell.allowButtonBounce(true);
cell.setIsKeyboard(true); cell.setIsKeyboard(true);
cell.setCanPreviewGif(true); cell.setCanPreviewGif(true);
@ -825,8 +826,10 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
packs.clear(); packs.clear();
int i = 0; int i = 0;
if (currentType == PAGE_TYPE_STICKERS) { if (currentType == PAGE_TYPE_STICKERS) {
if (hasWidgets()) {
documents.add(widgets); documents.add(widgets);
itemsCount++; itemsCount++;
}
ArrayList<TLRPC.Document> favorites = mediaDataController.getRecentStickers(MediaDataController.TYPE_FAVE); ArrayList<TLRPC.Document> favorites = mediaDataController.getRecentStickers(MediaDataController.TYPE_FAVE);
if (favorites != null && !favorites.isEmpty()) { if (favorites != null && !favorites.isEmpty()) {
@ -1268,6 +1271,10 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
return true; return true;
} }
public boolean hasWidgets() {
return canShowWidget(WIDGET_LOCATION) || canShowWidget(WIDGET_PHOTO);
}
@Override @Override
public void didReceivedNotification(int id, int account, Object... args) { public void didReceivedNotification(int id, int account, Object... args) {
if (id == NotificationCenter.stickersDidLoad || id == NotificationCenter.groupStickersDidLoad) { if (id == NotificationCenter.stickersDidLoad || id == NotificationCenter.groupStickersDidLoad) {
@ -2577,7 +2584,9 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter.
super(context); super(context);
setPadding(dp(0), 0, dp(0), 0); 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))); 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))); 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(5, false);
previewView.updatePauseReason(7, false); previewView.updatePauseReason(7, false);
videoTimeView.setVisibility(outputEntry != null && outputEntry.duration >= 30_000 ? View.VISIBLE : View.GONE); videoTimeView.setVisibility(outputEntry != null && outputEntry.duration >= 30_000 ? View.VISIBLE : View.GONE);
captionContainer.setAlpha(1f);
captionContainer.setTranslationY(0);
} }
if (toPage == PAGE_CAMERA && showSavedDraftHint) { if (toPage == PAGE_CAMERA && showSavedDraftHint) {
getDraftSavedHint().setVisibility(View.VISIBLE); 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="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="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="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="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="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> <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 # 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=3867 APP_VERSION_CODE=3872
APP_VERSION_NAME=10.0.8 APP_VERSION_NAME=10.0.9
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