diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/GiftAuctionController.java b/TMessagesProj/src/main/java/org/telegram/messenger/GiftAuctionController.java index 8a3562e2b..933d1fc0d 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/GiftAuctionController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/GiftAuctionController.java @@ -59,7 +59,7 @@ public class GiftAuctionController extends BaseController { return; } - auction.subscription = false; + auction.subscription = listeners.has(giftId); if (auction.resubscribe != null) { AndroidUtilities.cancelRunOnUIThread(auction.resubscribe); auction.resubscribe = null; @@ -151,13 +151,6 @@ public class GiftAuctionController extends BaseController { } final boolean hasBid = auction.hasBid(); - if (!hasBid && params == null) { - if (whenDone != null) { - whenDone.run(false, "NO_PARAMS"); - } - return; - } - auction.pendingBid = true; @@ -175,6 +168,10 @@ public class GiftAuctionController extends BaseController { } invoice.message = params.message; invoice.hide_name = params.hideName; + } else if (!hasBid) { + // default params + invoice.peer = new TLRPC.TL_inputPeerSelf(); + invoice.hide_name = false; } req.invoice = invoice; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java b/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java index d99ce71f0..bb17a1944 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/LiteMode.java @@ -209,7 +209,7 @@ public class LiteMode { if (!preferences.contains("lite_mode5")) { if (preferences.contains("lite_mode4")) { defaultValue = preferences.getInt("lite_mode4", defaultValue); - if (BuildVars.DEBUG_VERSION && SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_HIGH) { + if (SharedConfig.getDevicePerformanceClass() == SharedConfig.PERFORMANCE_CLASS_HIGH) { defaultValue |= FLAG_LIQUID_GLASS; } preferences.edit().putInt("lite_mode5", defaultValue).apply(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java index 3e098f3a4..54de18f80 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessageObject.java @@ -4712,7 +4712,7 @@ public class MessageObject { messageText = replaceWithLink(AndroidUtilities.replaceTags(getString(R.string.ActionPrepaidGiftInbound)), "un1", obj); } } else if (UserObject.isService(getDialogId()) && action.from_id == null) { - messageText = AndroidUtilities.replaceTags(getString(R.string.ActionGiftSomeone)); + messageText = AndroidUtilities.replaceTags(getString(action.auction_acquired ? R.string.ActionGiftAuctionSelf : R.string.ActionGiftSomeone)); messageTextShort = getString(R.string.ActionStarGift); } else if (isForChannel) { messageText = AndroidUtilities.replaceTags(formatPluralStringComma("ActionGiftChannel", stars)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ActiveGiftAuctionsHintCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ActiveGiftAuctionsHintCell.java index a32c17498..d05235e90 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ActiveGiftAuctionsHintCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ActiveGiftAuctionsHintCell.java @@ -238,7 +238,11 @@ public class ActiveGiftAuctionsHintCell extends BlurredFrameLayout implements Gi } private void updateTimer(long value) { - textView.setText(AndroidUtilities.formatDurationNoHours((int) value, false), isAttachedToWindow()); + if (value == 0) { + textView.setText(getString(R.string.Gift2AuctionPriceView)); + } else { + textView.setText(AndroidUtilities.formatDurationNoHours((int) value, false), isAttachedToWindow()); + } } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java index 54cf00ec2..e504e04ff 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatActionCell.java @@ -9,6 +9,7 @@ package org.telegram.ui.Cells; import static org.telegram.messenger.AndroidUtilities.dp; +import static org.telegram.messenger.LocaleController.formatNumber; import static org.telegram.messenger.LocaleController.formatPluralStringComma; import static org.telegram.messenger.LocaleController.formatString; import static org.telegram.messenger.LocaleController.getString; @@ -1976,8 +1977,19 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD } final SpannableStringBuilder sb = new SpannableStringBuilder(); final TLObject sender = MessagesController.getInstance(currentAccount).getUserOrChat(fromId); + long toId = DialogObject.getPeerDialogId(action.to_id); + final TLObject recipient = MessagesController.getInstance(currentAccount).getUserOrChat(toId); final boolean freeUpgrade = action.can_upgrade && !action.converted && action.upgrade_stars > 0 && !action.upgraded; - if (self) { + if (toId != 0 && action.auction_acquired && recipient != null) { + sb.append(getString(R.string.Gift2ActionTitleTo)).append(" "); + if (DialogObject.hasPhoto(recipient)) { + sb.append("a "); + final AvatarSpan avatarSpan = new AvatarSpan(this, currentAccount, 18); + avatarSpan.setObject(recipient); + sb.setSpan(avatarSpan, sb.length() - 2, sb.length() - 1, Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); + } + sb.append(DialogObject.getShortName(recipient)); + } else if (self) { sb.append(getString(R.string.Gift2ActionSelfTitle)); } else { sb.append(LocaleController.getString(action.prepaid_upgrade ? R.string.Gift2ActionUpgradeTitle : R.string.Gift2ActionTitle)).append(" "); @@ -2000,7 +2012,9 @@ public class ChatActionCell extends BaseCell implements DownloadController.FileD MessageObject.addEntitiesToText(title, action.message.entities, false, false, true, true); title = Emoji.replaceEmoji(title, giftTextPaint.getFontMetricsInt(), false, null); title = MessageObject.replaceAnimatedEmoji(title, action.message.entities, giftTextPaint.getFontMetricsInt()); - } else if (isForChannel) { + } else if (action.auction_acquired) { + title = formatString(R.string.Gift2ActionWonActionText, formatNumber(action.gift.stars, ',')); + } else if (isForChannel) { if (action.converted) { title = formatPluralStringComma("Gift2ActionConvertedInfo", (int) stars); } else if (canConvert && stars > 0) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index d9548c66b..d97c510a4 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -39867,13 +39867,7 @@ public class ChatActivity extends BaseFragment implements @Override public void onDiceFinished() { - if (fireworksOverlay.isStarted()) { - return; - } - fireworksOverlay.start(); - try { - fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); - } catch (Exception ignored) {}; + startFireworks(); } @Override @@ -44280,4 +44274,14 @@ public class ChatActivity extends BaseFragment implements return false; } + + public void startFireworks() { + if (fireworksOverlay == null || fireworksOverlay.isStarted()) { + return; + } + fireworksOverlay.start(); + try { + fireworksOverlay.performHapticFeedback(HapticFeedbackConstants.KEYBOARD_TAP, HapticFeedbackConstants.FLAG_IGNORE_GLOBAL_SETTING); + } catch (Exception ignored) {}; + } } \ No newline at end of file diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/BottomSheetWithRecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/BottomSheetWithRecyclerListView.java index e6a5083ea..9cabae662 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/BottomSheetWithRecyclerListView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/BottomSheetWithRecyclerListView.java @@ -585,6 +585,7 @@ public abstract class BottomSheetWithRecyclerListView extends BottomSheet { return dp(56); } + protected boolean centerTitle; private boolean restore; protected void preDrawInternal(Canvas canvas, View parent) { restore = false; @@ -642,6 +643,9 @@ public abstract class BottomSheetWithRecyclerListView extends BottomSheet { actionBar.backButtonImageView.setScaleY(t); SimpleTextView titleTextView = actionBar.getTitleTextView(); titleTextView.setTranslationX(AndroidUtilities.lerp(dp(21) - titleTextView.getLeft(), 0.0f, t)); + if (centerTitle) { + titleTextView.setTranslationX((actionBar.getMeasuredWidth() - titleTextView.getTextWidth()) / 2f - titleTextView.getLeft()); + } actionBar.setTranslationY(actionBarY); top -= AndroidUtilities.lerp(0, headerTotalHeight - headerHeight - headerPaddingTop - headerPaddingBottom + dp(13), t); actionBar.getBackground().setBounds(0, AndroidUtilities.lerp(actionBar.getHeight(), 0, t), actionBar.getWidth(), actionBar.getHeight()); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/CreateRtmpStreamBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/CreateRtmpStreamBottomSheet.java index a9145740a..27b48dc25 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/CreateRtmpStreamBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/CreateRtmpStreamBottomSheet.java @@ -119,6 +119,13 @@ public class CreateRtmpStreamBottomSheet extends BottomSheetWithRecyclerListView } } + DefaultItemAnimator itemAnimator = new DefaultItemAnimator(); + itemAnimator.setSupportsChangeAnimations(false); + itemAnimator.setDelayAnimations(false); + itemAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT); + itemAnimator.setDurations(350); + recyclerListView.setItemAnimator(itemAnimator); + recyclerListView.setPadding(backgroundPaddingLeft, 0, backgroundPaddingLeft, hasButton ? dp(hasRevokeButton ? 72 + 52 : 72) : 0); fixNavigationBar(); updateTitle(); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AcquiredGiftsSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AcquiredGiftsSheet.java index 0f474a7d4..9d3da07e6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AcquiredGiftsSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AcquiredGiftsSheet.java @@ -56,6 +56,7 @@ public class AcquiredGiftsSheet extends BottomSheetWithRecyclerListView { super(context, null, false, false, false, false, ActionBarType.SLIDING, resourcesProvider); this.auction = auction; this.gifts = gifts; + topPadding = 0.2f; ignoreTouchActionBar = false; headerMoveTop = dp(12); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionBidSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionBidSheet.java index 3929cde76..f04e61f54 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionBidSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionBidSheet.java @@ -36,6 +36,7 @@ import androidx.annotation.Nullable; import androidx.core.graphics.ColorUtils; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.DialogObject; import org.telegram.messenger.Emoji; import org.telegram.messenger.FileLog; import org.telegram.messenger.GiftAuctionController; @@ -52,6 +53,7 @@ import org.telegram.ui.ActionBar.AlertDialog; import org.telegram.ui.ActionBar.BaseFragment; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Cells.HeaderCell; +import org.telegram.ui.ChatActivity; import org.telegram.ui.Components.AnimatedEmojiSpan; import org.telegram.ui.Components.AnimatedTextView; import org.telegram.ui.Components.AvatarDrawable; @@ -63,6 +65,7 @@ import org.telegram.ui.Components.ColoredImageSpan; import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.EditTextCaption; import org.telegram.ui.Components.LayoutHelper; +import org.telegram.ui.Components.LinkSpanDrawable; import org.telegram.ui.Components.RecyclerListView; import org.telegram.ui.Components.ScaleStateListAnimator; import org.telegram.ui.Components.UItem; @@ -121,6 +124,8 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements this.auction = auction; this.params = params; this.giftId = auction.giftId; + centerTitle = true; + topPadding = 0.2f; auction = GiftAuctionController.getInstance(currentAccount).subscribeToGiftAuction(giftId, this); timer = new CountdownTimer(this::updateCountdownCell); @@ -190,10 +195,41 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements horizontalLayout.addView(new View(context), LayoutHelper.createLinear(10, LayoutHelper.MATCH_PARENT, 0f)); horizontalLayout.addView(giftsLeftCell, LayoutHelper.createLinear(0, LayoutHelper.MATCH_PARENT, 1f)); - linearLayout.addView(horizontalLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 56, 16, 0, 16, 0)); + linearLayout.addView(horizontalLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 56, 16, 0, 16, 15)); + if (auction.auctionUserState.acquired_count > 0) { + boolean[] pending = new boolean[1]; + LinkSpanDrawable.LinksTextView itemsBought = new LinkSpanDrawable.LinksTextView(context, resourcesProvider); - selfBidderHeader = new HeaderCell(context, Theme.key_windowBackgroundWhiteBlueHeader, 21, 15, 0, false, true, resourcesProvider); + itemsBought.setGravity(Gravity.CENTER); + itemsBought.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16); + itemsBought.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText, resourcesProvider)); + itemsBought.setLinkTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteLinkText, resourcesProvider)); + itemsBought.setOnClickListener((v) -> { + if (pending[0]) { + return; + } + pending[0] = true; + GiftAuctionController.getInstance(currentAccount).getOrRequestAcquiredGifts(giftId, gifts -> { + pending[0] = false; + new AcquiredGiftsSheet(getContext(), resourcesProvider, this.auction, gifts).show(); + }); + }); + + SpannableStringBuilder emoji = new SpannableStringBuilder("*"); + emoji.setSpan( + new AnimatedEmojiSpan(auction.giftDocumentId, itemsBought.getPaint().getFontMetricsInt()), + 0, emoji.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE + ); + itemsBought.setText(TextUtils.concat(AndroidUtilities.replaceArrows( + LocaleController.formatPluralSpannable("Gift2AuctionsItemsBought", auction.auctionUserState.acquired_count, emoji), + true, dp(8f / 3f), dp(1)))); + + ScaleStateListAnimator.apply(itemsBought, 0.02f, 1.5f); + linearLayout.addView(itemsBought, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 16, 4, 16, 4)); + } + + selfBidderHeader = new HeaderCell(context, Theme.key_windowBackgroundWhiteBlueHeader, 21, 0, 0, false, true, resourcesProvider); linearLayout.addView(selfBidderHeader, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 0, 5, 0, 0)); selfBidderCell = new BidderCell(context, resourcesProvider); @@ -299,9 +335,9 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements } */ minimumBid = 50; // Math.min(5000, minimumBid); - maximumBid = topBid > 30000 ? 100000 : 50000; + maximumBid = topBid > 100_000 ? (((int) topBid * 3 / 2000) * 1000) : (topBid > 30000 ? 100000 : 50000); - int[] steps_arr = new int[] { 50, 100, 500, 1_000, 2_000, 5_000, 7_500, 10_000, 25_000, 50_000, 100_000 }; + int[] steps_arr = new int[] { 50, 100, 500, 1_000, 2_000, 5_000, 7_500, 10_000, 25_000, 50_000, 100_000, 500_000, 1_000_000, 5_000_000, 10_000_000 }; ArrayList steps = new ArrayList<>(); boolean wasSkipped = false; for (int i = 0; i < steps_arr.length; ++i) { @@ -336,6 +372,40 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements slider.setSteps(100, steps_arr); } + private @Nullable Runnable closeParentSheet; + private long lastRecipientDialogId; + private long lastAcquiredCount; + private boolean isFirstCheck = true; + + private void checkAuctionParams() { + final long dialogId = DialogObject.getPeerDialogId(auction.auctionUserState.peer); + final long acquiredCount = auction.auctionUserState.acquired_count; + + if (lastAcquiredCount < acquiredCount && !isFirstCheck) { + final BaseFragment fragment = LaunchActivity.getLastFragment(); + if (fragment != null && lastRecipientDialogId != 0) { + final ChatActivity chatActivity = ChatActivity.of(lastRecipientDialogId); + chatActivity.whenFullyVisible(chatActivity::startFireworks); + fragment.presentFragment(chatActivity); + if (closeParentSheet != null) { + closeParentSheet.run(); + } + dismiss(); + } + } + + if (dialogId != 0) { + lastRecipientDialogId = dialogId; + } + + lastAcquiredCount = acquiredCount; + isFirstCheck = false; + } + + public void setCloseParentSheet(@Nullable Runnable closeParentSheet) { + this.closeParentSheet = closeParentSheet; + } + private final ColoredImageSpan[] refS = new ColoredImageSpan[1]; private AnimatedEmojiSpan animatedEmojiSpan; private void updateTable(boolean animated) { @@ -382,10 +452,10 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements updateSelfBidderHeader(animated); updateButtonText(animated); checkSliderSubText(); + checkAuctionParams(); } private void openProfile(long did) { - dismiss(); final BaseFragment lastFragment = LaunchActivity.getSafeLastFragment(); if (lastFragment != null) { if (UserObject.isService(did)) return; @@ -401,6 +471,10 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements args.putBoolean("open_gifts", true); lastFragment.presentFragment(new ProfileActivity(args)); } + if (closeParentSheet != null) { + closeParentSheet.run(); + } + dismiss(); } private final BoolAnimator winningColor = new BoolAnimator(0, this::onColorFactorChanged, CubicBezierInterpolator.EASE_OUT_QUINT, 380); @@ -656,7 +730,7 @@ public class AuctionBidSheet extends BottomSheetWithRecyclerListView implements editText.setHintText(getString(R.string.Gift2AuctionPlaceACustomBidHint2)); editText.setFocusable(true); editText.setInputType(InputType.TYPE_CLASS_NUMBER); - editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(7)}); + editText.setFilters(new InputFilter[]{new InputFilter.LengthFilter(9)}); editText.setLineColors(Theme.getColor(Theme.key_windowBackgroundWhiteInputField, resourcesProvider), Theme.getColor(Theme.key_windowBackgroundWhiteInputFieldActivated, resourcesProvider), Theme.getColor(Theme.key_text_RedRegular, resourcesProvider)); editText.setImeOptions(EditorInfo.IME_ACTION_DONE | EditorInfo.IME_FLAG_NO_EXTRACT_UI); editText.setBackgroundDrawable(null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionJoinSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionJoinSheet.java index d049a2a23..6b368a93f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionJoinSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/AuctionJoinSheet.java @@ -10,6 +10,7 @@ import static org.telegram.ui.Stars.StarGiftSheet.replaceUnderstood; import android.content.Context; import android.graphics.drawable.ShapeDrawable; import android.graphics.drawable.shapes.OvalShape; +import android.text.Layout; import android.text.SpannableStringBuilder; import android.text.Spanned; import android.text.TextUtils; @@ -31,6 +32,7 @@ import org.telegram.messenger.MessagesController; import org.telegram.messenger.NotificationCenter; import org.telegram.messenger.R; import org.telegram.messenger.UserConfig; +import org.telegram.messenger.Utilities; import org.telegram.tgnet.ConnectionsManager; import org.telegram.tgnet.TLObject; import org.telegram.tgnet.tl.TL_stars; @@ -56,6 +58,7 @@ import org.telegram.ui.PremiumFeatureCell; import org.telegram.ui.Stars.StarGiftSheet; import org.telegram.ui.Stars.StarsIntroActivity; import org.telegram.ui.Stories.recorder.ButtonWithCounterView; +import org.telegram.ui.Stories.recorder.HintView2; import java.util.ArrayList; @@ -71,6 +74,7 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements private final ButtonSpan.TextViewButtons auctionRowCurrentRoundText; private final ButtonSpan.TextViewButtons auctionRowAveragePriceText; private final ButtonSpan.TextViewButtons auctionRowAvailabilityText; + private final Utilities.Callback2 showHint; private final TableRow auctionRowCurrentRound; private final TableRow auctionRowAveragePrice; @@ -87,10 +91,11 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements private CharSequence emojiGiftText; - private AuctionJoinSheet(Context context, Theme.ResourcesProvider resourcesProvider, long dialogId, TL_stars.StarGift starGift) { + private AuctionJoinSheet(Context context, Theme.ResourcesProvider resourcesProvider, long dialogId, TL_stars.StarGift starGift, Runnable closeParentSheet) { super(context, null, false, false, false, false, ActionBarType.FADING, resourcesProvider); this.starGift = starGift; this.giftId = starGift.id; + topPadding = 0.2f; fixNavigationBar(); @@ -156,13 +161,56 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements auctionRowCurrentRound = tableView.addRow(getString(R.string.Gift2AuctionTableCurrentRound), "", ref); auctionRowCurrentRoundText = ref[0]; + final FrameLayout tableLayout = new FrameLayout(getContext()); + tableLayout.setClipChildren(false); + tableLayout.setClipToPadding(false); + tableLayout.addView(tableView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.FILL)); + + final HintView2[] hintView = new HintView2[1]; + showHint = (view, text) -> { + if (hintView[0] != null) { + hintView[0].hide(); + } + text = AndroidUtilities.replaceTags(text); + float x = view.getX() + ((View) view.getParent()).getX() + ((View) ((View) view.getParent()).getParent()).getX(); + float y = view.getY() + ((View) view.getParent()).getY() + ((View) ((View) view.getParent()).getParent()).getY(); + if (view instanceof ButtonSpan.TextViewButtons) { + final ButtonSpan.TextViewButtons textView2 = (ButtonSpan.TextViewButtons) view; + final Layout layout = textView2.getLayout(); + final CharSequence viewText = layout.getText(); + if (viewText instanceof Spanned) { + ButtonSpan[] spans = ((Spanned) viewText).getSpans(0, viewText.length(), ButtonSpan.class); + if (spans.length > 0 && spans[0] != null) { + final int offset = ((Spanned) viewText).getSpanStart(spans[0]); + x += layout.getPrimaryHorizontal(offset) + spans[0].getSize() / 2; + y += layout.getLineTop(layout.getLineForOffset(offset)); + } + } + } + + final HintView2 thisHintView = hintView[0] = new HintView2(getContext(), HintView2.DIRECTION_BOTTOM); + thisHintView.setMultilineText(true); + thisHintView.setInnerPadding(11, 8, 11, 7); + thisHintView.setRounding(10); + thisHintView.setText(text); + thisHintView.setOnHiddenListener(() -> AndroidUtilities.removeFromParent(thisHintView)); + thisHintView.setTranslationY(-dp(100) + y); + thisHintView.setMaxWidthPx(dp(300)); + thisHintView.setPadding(dp(4), dp(4), dp(4), dp(4)); + thisHintView.setJointPx(0, x - dp(4)); + tableLayout.addView(thisHintView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 100, Gravity.TOP | Gravity.FILL_HORIZONTAL)); + thisHintView.show(); + }; + + auctionRowAveragePrice = tableView.addRow(getString(R.string.GiftValueAveragePrice), "", ref); + auctionRowAveragePrice.setOnClickListener(v -> showAveragePriceHint()); auctionRowAveragePriceText = ref[0]; tableView.addRow(getString(R.string.Gift2AuctionTableCurrentAvailability), "", ref); auctionRowAvailabilityText = ref[0]; - linearLayout.addView(tableView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 16, 0, 14, 18)); + linearLayout.addView(tableLayout, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 16, 0, 14, 18)); boolean pending[] = new boolean[1]; itemsBought = new LinkSpanDrawable.LinksTextView(context, resourcesProvider); @@ -200,16 +248,12 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements buttonView = new ButtonWithCounterView(context, resourcesProvider); buttonView.setOnClickListener(v -> { if (auction != null && !auction.isFinished()) { - new SendGiftSheet(context, currentAccount, auction.gift, dialogId, () -> { - dismiss(); - }, false, false) { + new SendGiftSheet(context, currentAccount, auction.gift, dialogId, closeParentSheet, false, false) { @Override protected BulletinFactory getParentBulletinFactory() { return BulletinFactory.of(this.container, this.resourcesProvider); } }.show(); - - // new AuctionBidSheet(context, resourcesProvider, dialogId, auction).show(); } dismiss(); }); @@ -226,11 +270,20 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements updateTable(false); } + private void showAveragePriceHint() { + if (auction != null && auction.auctionStateFinished != null && auction.gift.title != null) { + showHint.run(auctionRowAveragePriceText, formatString(R.string.Gift2AveragePriceHint, auction.auctionStateFinished.average_price, auction.gift.title)); + } + } + private void updateTable(boolean animated) { if (auction != null && auction.auctionStateFinished != null) { auctionRowStartTimeText.setText(LocaleController.formatDateTime(auction.auctionStateFinished.start_date, true)); auctionRowEndTimeText.setText(LocaleController.formatDateTime(auction.auctionStateFinished.end_date, true)); - auctionRowAveragePriceText.setText(StarsIntroActivity.replaceStarsWithPlain("⭐️ " + LocaleController.formatNumber(auction.auctionStateFinished.average_price, ','), .8f)); + + SpannableStringBuilder ssb = new SpannableStringBuilder(StarsIntroActivity.replaceStarsWithPlain("⭐️ " + LocaleController.formatNumber(auction.auctionStateFinished.average_price, ','), .8f)); + ssb.append(" ").append(ButtonSpan.make("?", this::showAveragePriceHint, resourcesProvider)); + auctionRowAveragePriceText.setText(ssb); } else if (auction != null && auction.auctionStateActive != null) { auctionRowStartTimeText.setText(LocaleController.formatDateTime(auction.auctionStateActive.start_date, true)); auctionRowEndTimeText.setText(LocaleController.formatDateTime(auction.auctionStateActive.end_date, true)); @@ -244,7 +297,11 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements buttonView.setSubText(formatString(R.string.Gift2AuctionTimeLeft, LocaleController.formatTTLString(timeLeft)), animated); } - auctionRowAvailabilityText.setText(formatPluralString("Gift2Availability4Value", starGift.availability_remains, + + + auctionRowAvailabilityText.setText(formatPluralString("Gift2Availability4Value", + auction != null ? (auction.isFinished() ? 0 : auction.auctionStateActive != null ? auction.auctionStateActive.gifts_left : starGift.availability_remains): + starGift.availability_remains, formatNumber(starGift.availability_total, ','))); @@ -391,10 +448,11 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements Theme.ResourcesProvider resourcesProvider, int currentAccount, long dialogId, - long giftId) { + long giftId, + Runnable closeParentSheet) { GiftAuctionController.getInstance(currentAccount).getOrRequestAuction(giftId, (auction, err) -> { if (auction != null) { - show(context, resourcesProvider, currentAccount, dialogId, auction); + show(context, resourcesProvider, currentAccount, dialogId, auction, closeParentSheet); } }); } @@ -403,7 +461,8 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements Theme.ResourcesProvider resourcesProvider, int currentAccount, long dialogId, - GiftAuctionController.Auction auction) { + GiftAuctionController.Auction auction, + Runnable closeParentSheet) { if (auction == null) { return; // loading } @@ -412,18 +471,21 @@ public class AuctionJoinSheet extends BottomSheetWithRecyclerListView implements final long bidPeer = DialogObject.getPeerDialogId(auction.auctionUserState.peer); if (dialogId != bidPeer && dialogId != 0 && bidPeer != 0) { openAuctionTransferAlert(context, resourcesProvider, currentAccount, bidPeer, dialogId, () -> { - new SendGiftSheet(context, currentAccount, auction.gift, dialogId, null, false, false) + new SendGiftSheet(context, currentAccount, auction.gift, dialogId, closeParentSheet, false, false) .show(); }); return; } - if (auction.auctionUserState.bid_date > 0) { - new AuctionBidSheet(context, resourcesProvider, null, auction).show(); + if (auction.auctionUserState.bid_date > 0 && !auction.isFinished()) { + AuctionBidSheet auctionBidSheet = new AuctionBidSheet(context, resourcesProvider, null, auction); + auctionBidSheet.setCloseParentSheet(closeParentSheet); + auctionBidSheet.show(); + return; } - new AuctionJoinSheet(context, resourcesProvider, dialogId, auction.gift).show(); + new AuctionJoinSheet(context, resourcesProvider, dialogId, auction.gift, closeParentSheet).show(); } public static void initActionBar(ActionBar actionBar, Context context, Theme.ResourcesProvider resourcesProvider, int currentAccount, TL_stars.StarGift starGift) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/GiftSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/GiftSheet.java index 78b225dbc..249f5e881 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/GiftSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/GiftSheet.java @@ -544,7 +544,12 @@ public class GiftSheet extends BottomSheetWithRecyclerListView implements Notifi return; } if (gift.auction) { - AuctionJoinSheet.show(context, resourcesProvider, currentAccount, dialogId, gift.id); + AuctionJoinSheet.show(context, resourcesProvider, currentAccount, dialogId, gift.id, () -> { + if (closeParentSheet != null) { + closeParentSheet.run(); + } + dismiss(); + }); return; } @@ -935,6 +940,11 @@ public class GiftSheet extends BottomSheetWithRecyclerListView implements Notifi } }).collect(Collectors.toCollection(ArrayList::new)); } + + if (dialogId < 0) { + gifts = gifts.stream().filter(gift -> !gift.auction).collect(Collectors.toCollection(ArrayList::new)); + } + boolean myGiftsHaveUnique = false; if (dialogId != UserConfig.getInstance(currentAccount).getClientUserId()) { if (myGifts != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/SendGiftSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/SendGiftSheet.java index 68046cb12..2780c4534 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Gifts/SendGiftSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Gifts/SendGiftSheet.java @@ -419,9 +419,11 @@ public class SendGiftSheet extends BottomSheetWithRecyclerListView implements No if (auction != null) { final AuctionBidSheet.Params p = new AuctionBidSheet.Params(dialogId, anonymous, getMessage()); - new AuctionBidSheet(context, resourcesProvider, p, auction) - .show(); + AuctionBidSheet auctionSheet = new AuctionBidSheet(context, resourcesProvider, p, auction); + auctionSheet.show(); + auctionSheet.setCloseParentSheet(closeParentSheet); + AndroidUtilities.hideKeyboard(messageEdit); dismiss(); if (!isDismissed) { AndroidUtilities.runOnUIThread(this::dismiss, 500); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index 6f8ea2e68..0b77c732b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -4384,7 +4384,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati .createSimpleBulletin(R.raw.error, getString(R.string.GiftAuctionNotFound)) .show(); } else if (res != null) { - AuctionJoinSheet.show(LaunchActivity.this, null, currentAccount, 0, res.gift.id); + AuctionJoinSheet.show(LaunchActivity.this, null, currentAccount, 0, res.gift.id, null); } try { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/LiveCommentsView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/LiveCommentsView.java index dae7d10e6..aca1ae442 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/LiveCommentsView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/LiveCommentsView.java @@ -112,6 +112,8 @@ import java.util.List; public class LiveCommentsView extends FrameLayout implements NotificationCenter.NotificationCenterDelegate { + public static final int MAX_MESSAGES_COUNT = 2_000; + public static class Message { public int id; public boolean fromAdmin; @@ -1350,6 +1352,9 @@ public class LiveCommentsView extends FrameLayout implements NotificationCenter. } messages.add(position, message); if (!isHistory) { + if (messages.size() > MAX_MESSAGES_COUNT) { + messages.subList(MAX_MESSAGES_COUNT, messages.size()).clear(); + } adapter.update(true); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/LivePlayer.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/LivePlayer.java index ca466be62..03d22fdbf 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/LivePlayer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/LivePlayer.java @@ -563,13 +563,27 @@ public class LivePlayer implements NotificationCenter.NotificationCenterDelegate instance.setOnStateUpdatedListener(new Instance.OnStateUpdatedListener() { @Override public void onStateUpdated(int state, boolean inTransition) { + final boolean wasConnected = isConnected(); connectionState = state; FileLog.d("[LivePlayer] connectionState = " + state); + if (wasConnected != isConnected()) { + AndroidUtilities.runOnUIThread(() -> { + NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.liveStoryUpdated, getCallId()); + }); + } } }); instance.resetGroupInstance(false, false); } + public boolean isConnected() { + return ( + connectionState == Instance.STATE_ESTABLISHED || + connectionState == Instance.STATE_WAIT_INIT || + connectionState == Instance.STATE_WAIT_INIT_ACK + ); + } + private final HashSet srcs = new HashSet<>(); private float volume = 1.0f; public void setVolume(float volume) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/MuteButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/MuteButton.java index c0f6747ae..44b4a3100 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/MuteButton.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/MuteButton.java @@ -4,13 +4,16 @@ import static org.telegram.messenger.AndroidUtilities.dp; import android.animation.ValueAnimator; import android.content.Context; +import android.graphics.Canvas; import android.graphics.PorterDuff; import android.graphics.PorterDuffColorFilter; import android.graphics.PorterDuffXfermode; import android.view.Gravity; +import android.view.View; import android.widget.FrameLayout; import android.widget.ImageView; +import androidx.annotation.NonNull; import androidx.core.graphics.ColorUtils; import org.telegram.messenger.AndroidUtilities; @@ -18,6 +21,7 @@ import org.telegram.messenger.R; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.Components.AnimatedTextView; import org.telegram.ui.Components.BackupImageView; +import org.telegram.ui.Components.CircularProgressDrawable; import org.telegram.ui.Components.CubicBezierInterpolator; import org.telegram.ui.Components.LayoutHelper; import org.telegram.ui.Components.RLottieDrawable; @@ -28,8 +32,10 @@ import org.telegram.ui.Components.blur3.drawable.color.BlurredBackgroundColorPro public class MuteButton extends FrameLayout { private final FrameLayout layout; + private final View filledBackgroundView; private final ImageView image; private final StrokeDrawable background; + private final View loadingView; public MuteButton(Context context, BlurredBackgroundColorProvider colorProvider) { super(context); @@ -43,6 +49,25 @@ public class MuteButton extends FrameLayout { layout.setBackground(background); addView(layout, LayoutHelper.createFrame(40, 40, Gravity.CENTER)); + filledBackgroundView = new View(context); + filledBackgroundView.setBackground(Theme.createCircleDrawable(dp(40), 0xFF31AA28)); + layout.addView(filledBackgroundView, LayoutHelper.createFrame(38, 38, Gravity.CENTER)); + filledBackgroundView.setAlpha(0); + filledBackgroundView.setScaleX(0); + filledBackgroundView.setScaleY(0); + + loadingView = new View(context) { + private final CircularProgressDrawable progressDrawable = new CircularProgressDrawable(dp(36), dp(2), 0xFF31AA28); + @Override + protected void onDraw(@NonNull Canvas canvas) { + final int p = dp(1); + progressDrawable.setBounds(p, p, getWidth()-p-p, getHeight()-p-p); + progressDrawable.draw(canvas); + invalidate(); + } + }; + addView(loadingView, LayoutHelper.createFrame(42, 42, Gravity.CENTER)); + image = new ImageView(context); image.setScaleType(ImageView.ScaleType.CENTER); image.setScaleX(0.75f); @@ -53,13 +78,40 @@ public class MuteButton extends FrameLayout { setMuted(false, false); } + private boolean connected; + private ValueAnimator loadingViewAnimator; + public void setConnected(boolean connected, boolean animated) { + if (this.connected == connected && animated) return; + this.connected = connected; + if (loadingViewAnimator != null) { + loadingViewAnimator.cancel(); + loadingViewAnimator = null; + } + if (!animated) { + loadingView.setAlpha(connected ? 0f : 1f); + loadingView.setVisibility(connected ? View.GONE : View.VISIBLE); + } else { + loadingView.setVisibility(View.VISIBLE); + loadingViewAnimator = ValueAnimator.ofFloat(loadingView.getAlpha(), connected ? 0f : 1f); + loadingViewAnimator.addUpdateListener(a -> { + loadingView.setAlpha((float) a.getAnimatedValue()); + }); + loadingViewAnimator.setDuration(320); + loadingViewAnimator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT); + loadingViewAnimator.start(); + } + updateFill(muted || !connected, animated); + } + + private boolean muted; public void setMuted(boolean muted, boolean animated) { + this.muted = muted; if (!animated) { AndroidUtilities.updateImageViewImageAnimated(image, muted ? R.drawable.msg_voice_muted : R.drawable.msg_voice_unmuted); } else { image.setImageResource(muted ? R.drawable.msg_voice_muted : R.drawable.msg_voice_unmuted); } - updateFill(muted, animated); + updateFill(muted || !connected, animated); } private float mutedT; @@ -71,19 +123,25 @@ public class MuteButton extends FrameLayout { } if (!animated) { mutedT = muted ? 1.0f : 0.0f; - background.setBackgroundColor(ColorUtils.blendARGB(0xFF31AA28, 0xFF20242A, mutedT)); +// background.setBackgroundColor(ColorUtils.blendARGB(0xFF31AA28, 0xFF20242A, mutedT)); + filledBackgroundView.setAlpha(1.0f - mutedT); + filledBackgroundView.setScaleX(1.0f - mutedT); + filledBackgroundView.setScaleY(1.0f - mutedT); image.setColorFilter(new PorterDuffColorFilter(ColorUtils.blendARGB(0xFFFFFFFF, 0xFFD2D3D4, mutedT), PorterDuff.Mode.SRC_IN)); layout.invalidate(); } else { animator = ValueAnimator.ofFloat(mutedT, muted ? 1.0f : 0.0f); animator.addUpdateListener(a -> { mutedT = (float) a.getAnimatedValue(); - background.setBackgroundColor(ColorUtils.blendARGB(0xFF31AA28, 0xFF20242A, mutedT)); +// background.setBackgroundColor(ColorUtils.blendARGB(0xFF31AA28, 0xFF20242A, mutedT)); + filledBackgroundView.setAlpha(1.0f - mutedT); + filledBackgroundView.setScaleX(1.0f - mutedT); + filledBackgroundView.setScaleY(1.0f - mutedT); image.setColorFilter(new PorterDuffColorFilter(ColorUtils.blendARGB(0xFFFFFFFF, 0xFFD2D3D4, mutedT), PorterDuff.Mode.SRC_IN)); layout.invalidate(); }); animator.setInterpolator(CubicBezierInterpolator.EASE_OUT_QUINT); - animator.setDuration(200); + animator.setDuration(420); animator.start(); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java index 047b31542..01f64e182 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java @@ -223,6 +223,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica public static final float SHARE_BUTTON_OFFSET = 46; private final static long IMAGE_LIVE_TIME = 10_000; private final ImageView optionsIconView; + private final ImageView pipIconView; private final FrameLayout muteIconContainer; private final RLottieImageView muteIconView; private final ImageView noSoundIconView; @@ -1271,6 +1272,17 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica optionsIconView.setBackground(Theme.createSelectorDrawable(Color.WHITE)); storyContainer.addView(optionsIconView, LayoutHelper.createFrame(40, 40, Gravity.RIGHT | Gravity.TOP, 2, 15, 2, 0)); + pipIconView = new ImageView(context); + pipIconView.setImageDrawable(sharedResources.pipDrawable); + pipIconView.setPadding(dp(8), dp(8), dp(8), dp(8)); + pipIconView.setBackground(Theme.createSelectorDrawable(Color.WHITE)); + storyContainer.addView(pipIconView, LayoutHelper.createFrame(40, 40, Gravity.RIGHT | Gravity.TOP, 2, 15, 2 + 40, 0)); + pipIconView.setOnClickListener(v -> { + if (storyViewer != null) { + storyViewer.switchToPip(); + } + }); + optionsIconView.setOnClickListener(v -> { delegate.setPopupIsVisible(true); editStoryItem = null; @@ -2335,6 +2347,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica muteIconContainer.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(20), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 100))); optionsIconView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(20), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 100))); + pipIconView.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(20), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 100))); shareButton.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(20), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 100))); likeButtonContainer.setBackground(Theme.createSimpleSelectorRoundRectDrawable(dp(20), Color.TRANSPARENT, ColorUtils.setAlphaComponent(Color.WHITE, 100))); if (repostButtonContainer != null) { @@ -2994,6 +3007,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica muteButton.setMuted(!muted, true); }); muteButton.setMuted(LivePlayer.recording != null && LivePlayer.recording.isMuted(), false); + muteButton.setConnected(LivePlayer.recording == null || LivePlayer.recording.isConnected(), false); addView(muteButton, LayoutHelper.createFrame(38 + 8, 38 + 4, Gravity.RIGHT | Gravity.BOTTOM, 7, 0, 7, 3)); } @@ -5389,6 +5403,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica if (muteButton != null) { muteButton.setVisibility(!unsupported && currentStory.isLive && LivePlayer.recording != null && currentStory.isThisCall(LivePlayer.recording.getCallId()) ? View.VISIBLE : View.GONE); muteButton.setMuted(LivePlayer.recording != null && LivePlayer.recording.isMuted(), true); + muteButton.setConnected(LivePlayer.recording == null || LivePlayer.recording.isConnected(), true); } if (starsButton != null) { starsButtonEffectsView.setVisibility(!unsupported && currentStory.isLive ? View.VISIBLE : View.GONE); @@ -5571,6 +5586,9 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica if (optionsIconView != null) { optionsIconView.setVisibility(isBotsPreview() && !isEditBotsPreview() && (currentStory == null || !currentStory.isVideo) ? View.GONE : View.VISIBLE); } + if (pipIconView != null) { + pipIconView.setVisibility(currentStory.isLive && !privacyButton.draw ? View.VISIBLE : View.GONE); + } } private boolean isEditBotsPreview() { @@ -7479,7 +7497,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica if (child == null || child == liveCommentsShadowView) { continue; } - if (child == headerView || child == optionsIconView || child == muteIconContainer || child == selfView || child == storyCaptionView || child == privacyButton) { + if (child == headerView || child == optionsIconView || child == pipIconView || child == muteIconContainer || child == selfView || child == storyCaptionView || child == privacyButton) { float alpha = 1f; if (child == muteIconContainer) { alpha = muteIconViewAlpha; @@ -8084,6 +8102,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica public Drawable likeDrawable; public Drawable likeDrawableFilled; public Drawable optionsDrawable; + public Drawable pipDrawable; public Drawable deleteDrawable; public RLottieDrawable noSoundDrawable; // public ReplaceableIconDrawable muteDrawable; @@ -8096,6 +8115,7 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica likeDrawableFilled = ContextCompat.getDrawable(context, R.drawable.media_like_active); likeDrawableFilled.setColorFilter(new PorterDuffColorFilter(0xFFFF2E38, PorterDuff.Mode.MULTIPLY)); optionsDrawable = ContextCompat.getDrawable(context, R.drawable.media_more); + pipDrawable = ContextCompat.getDrawable(context, R.drawable.menu_stream_pip); deleteDrawable = ContextCompat.getDrawable(context, R.drawable.msg_delete); muteDrawable = new RLottieDrawable(R.raw.media_mute_unmute, "media_mute_unmute", AndroidUtilities.dp(28), AndroidUtilities.dp(28), true, null); // muteDrawable = new ReplaceableIconDrawable(context); @@ -8235,6 +8255,8 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica headerView.setAlpha(1f - outT); optionsIconView.setTranslationY(-AndroidUtilities.dp(8) * outT); optionsIconView.setAlpha(1f - outT); + pipIconView.setTranslationY(-AndroidUtilities.dp(8) * outT); + pipIconView.setAlpha(1f - outT); muteIconContainer.setTranslationY(-AndroidUtilities.dp(8) * outT); muteIconContainer.setAlpha(muteIconViewAlpha * (1f - outT)); if (selfView != null) { @@ -8271,6 +8293,8 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica headerView.setAlpha(1f - outT); optionsIconView.setTranslationY(-AndroidUtilities.dp(8) * outT); optionsIconView.setAlpha(1f - outT); + pipIconView.setTranslationY(-AndroidUtilities.dp(8) * outT); + pipIconView.setAlpha(1f - outT); muteIconContainer.setTranslationY(-AndroidUtilities.dp(8) * outT); muteIconContainer.setAlpha(muteIconViewAlpha * (1f - outT)); if (selfView != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesController.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesController.java index 2a4ee732d..b2ada4873 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesController.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesController.java @@ -469,7 +469,7 @@ public class StoriesController { for (int j = 0; j < userStories.stories.size(); j++) { TL_stories.StoryItem story = userStories.stories.get(j); if (story instanceof TL_stories.TL_storyItemDeleted || - story instanceof TL_stories.TL_storyItem && now > story.expire_date) { + story instanceof TL_stories.TL_storyItem && now > story.expire_date && !(story.media instanceof TLRPC.TL_messageMediaVideoStream)) { NotificationsController.getInstance(currentAccount).processDeleteStory(dialogId, story.id); userStories.stories.remove(j); j--; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesUtilities.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesUtilities.java index e6030f32c..bc63adf18 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesUtilities.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesUtilities.java @@ -1049,6 +1049,7 @@ public class StoriesUtilities { } public static boolean isExpired(int currentAccount, TL_stories.StoryItem storyItem) { + if (storyItem.media instanceof TLRPC.TL_messageMediaVideoStream) return false; return ConnectionsManager.getInstance(currentAccount).getCurrentTime() > storyItem.expire_date; } diff --git a/TMessagesProj/src/main/res/drawable/menu_stream_pip.xml b/TMessagesProj/src/main/res/drawable/menu_stream_pip.xml new file mode 100644 index 000000000..6d405635a --- /dev/null +++ b/TMessagesProj/src/main/res/drawable/menu_stream_pip.xml @@ -0,0 +1,12 @@ + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values/strings.xml b/TMessagesProj/src/main/res/values/strings.xml index 9b1f3a925..665d951e0 100644 --- a/TMessagesProj/src/main/res/values/strings.xml +++ b/TMessagesProj/src/main/res/values/strings.xml @@ -8630,6 +8630,9 @@ Your balance is %d Star Your balance is %d Stars Gift from + Gift for + **%d Stars** is the average sale price for **%s** gifts. + You bought this gift at auction for %s Stars. Upgrade from Upgrade from unknown Saved Gift diff --git a/gradle.properties b/gradle.properties index 34856aa97..6ac319f51 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,8 +13,8 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Sat Mar 12 05:53:50 MSK 2016 -APP_VERSION_CODE=6289 -APP_VERSION_NAME=12.2.0 +APP_VERSION_CODE=6292 +APP_VERSION_NAME=12.2.1 APP_PACKAGE=org.telegram.messenger IS_PRIVATE=false RELEASE_KEY_PASSWORD=android