From a906f12aaec2768969c77650a7e4b377baa6cf2a Mon Sep 17 00:00:00 2001 From: dkaraush Date: Mon, 1 Apr 2024 11:45:21 +0400 Subject: [PATCH] update to 10.10.1 (4583) --- .../messenger/DatabaseMigrationHelper.java | 7 + .../messenger/FileUploadOperation.java | 2 +- .../telegram/messenger/MediaController.java | 20 +- .../messenger/MessagesController.java | 18 +- .../telegram/messenger/MessagesStorage.java | 4 +- .../org/telegram/messenger/SegmentTree.java | 30 +-- .../telegram/messenger/video/WebmEncoder.java | 3 + .../org/telegram/tgnet/tl/TL_stories.java | 22 ++ .../ui/ActionBar/ActionBarMenuItem.java | 7 + .../ui/Cells/UnconfirmedAuthHintCell.java | 3 +- .../ui/ChannelMonetizationLayout.java | 46 ++-- .../org/telegram/ui/Charts/BarChartView.java | 4 +- .../org/telegram/ui/Charts/BaseChartView.java | 50 ++-- .../ui/Charts/DoubleLinearChartView.java | 28 +-- .../ui/Charts/LinearBarChartView.java | 216 ++++++++++++++++++ .../telegram/ui/Charts/LinearChartView.java | 6 +- .../org/telegram/ui/Charts/PieChartView.java | 2 +- .../telegram/ui/Charts/StackBarChartView.java | 20 +- .../ui/Charts/StackLinearChartView.java | 6 +- .../telegram/ui/Charts/data/ChartData.java | 14 +- .../ui/Charts/data/DoubleLinearChartData.java | 6 +- .../ui/Charts/data/StackBarChartData.java | 6 +- .../ui/Charts/data/StackLinearChartData.java | 14 +- .../ui/Charts/view_data/BarViewData.java | 2 +- .../view_data/ChartHorizontalLinesData.java | 40 ++-- .../Charts/view_data/LegendSignatureView.java | 70 +++--- .../ui/Charts/view_data/LineViewData.java | 10 +- .../ui/Charts/view_data/StackBarViewData.java | 2 +- .../Charts/view_data/StackLinearViewData.java | 2 +- .../java/org/telegram/ui/ChatActivity.java | 105 ++++----- .../telegram/ui/Components/AlertsCreator.java | 1 + .../ui/Components/ChatActivityEnterView.java | 4 +- .../ui/Components/ColoredImageSpan.java | 28 ++- .../ui/Components/GroupCreateSpan.java | 2 +- .../ui/Components/LinkSpanDrawable.java | 29 ++- .../Paint/Views/LPhotoPaintView.java | 2 +- .../Paint/Views/StickerMakerView.java | 7 +- .../Reactions/ReactionsLayoutInBubble.java | 11 + .../Components/ReactionsContainerLayout.java | 24 +- .../ui/Components/SharedMediaLayout.java | 2 +- .../telegram/ui/Components/StickersAlert.java | 3 +- .../org/telegram/ui/Components/UItem.java | 2 +- .../ui/Components/UniversalAdapter.java | 46 ++-- .../java/org/telegram/ui/DialogsActivity.java | 16 +- .../java/org/telegram/ui/LaunchActivity.java | 4 + .../java/org/telegram/ui/PhotoViewer.java | 2 +- .../telegram/ui/PrivacyControlActivity.java | 2 +- .../java/org/telegram/ui/ProfileActivity.java | 10 + .../ui/RevenueSharingAdsInfoBottomSheet.java | 6 +- .../org/telegram/ui/StatisticActivity.java | 20 +- .../telegram/ui/Stories/PeerStoriesView.java | 4 + .../ui/Stories/StoriesController.java | 24 +- .../ui/Stories/recorder/EmojiBottomSheet.java | 8 + .../ui/Stories/recorder/StoryEntry.java | 6 + .../org/telegram/ui/bots/BotBiometry.java | 3 + .../menu_feature_withdrawals.png | Bin 1161 -> 925 bytes .../menu_feature_withdrawals.png | Bin 746 -> 714 bytes .../menu_feature_withdrawals.png | Bin 1727 -> 1226 bytes .../menu_feature_withdrawals.png | Bin 2435 -> 1592 bytes TMessagesProj/src/main/res/drawable/ton.xml | 20 ++ .../src/main/res/values-night/styles.xml | 2 +- .../src/main/res/values-v21/styles.xml | 6 +- .../src/main/res/values-v31/styles.xml | 6 +- TMessagesProj/src/main/res/values/strings.xml | 7 +- TMessagesProj/src/main/res/values/styles.xml | 6 +- gradle.properties | 4 +- 66 files changed, 782 insertions(+), 300 deletions(-) create mode 100644 TMessagesProj/src/main/java/org/telegram/ui/Charts/LinearBarChartView.java create mode 100644 TMessagesProj/src/main/res/drawable/ton.xml diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java b/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java index ddda0e101..f0d9c0584 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/DatabaseMigrationHelper.java @@ -1490,6 +1490,13 @@ public class DatabaseMigrationHelper { version = 151; } + if (version == 151) { + database.executeFast("ALTER TABLE profile_stories ADD COLUMN seen INTEGER default 0;").stepThis().dispose(); + + database.executeFast("PRAGMA user_version = 152").stepThis().dispose(); + version = 152; + } + return version; } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java b/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java index a3a075a31..69a07c03a 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/FileUploadOperation.java @@ -673,7 +673,7 @@ public class FileUploadOperation { } }), forceSmallFile ? ConnectionsManager.RequestFlagCanCompress : 0, ConnectionsManager.DEFAULT_DATACENTER_ID, connectionType, true); if (BuildVars.LOGS_ENABLED) { - FileLog.d("debug_uploading: " + " send reqId " + requestToken[0] + " " + uploadingFilePath); + FileLog.d("debug_uploading: " + " send reqId " + requestToken[0] + " " + uploadingFilePath + " file_part=" + currentRequestPartNum + " isBig=" + isBigFile + " file_id=" + currentFileId); } requestTokens.put(requestNumFinal, requestToken[0]); } diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java index 5cc54f1e4..e8bc153a5 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MediaController.java @@ -3836,8 +3836,8 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, } } - public void prepareResumedRecording(int currentAccount, MediaDataController.DraftVoice draft, long dialogId, MessageObject replyToMsg, MessageObject replyToTopMsg, TL_stories.StoryItem replyStory, int guid, boolean manual, String query_shortcut, int query_shortcut_id) { - manualRecording = manual; + public void prepareResumedRecording(int currentAccount, MediaDataController.DraftVoice draft, long dialogId, MessageObject replyToMsg, MessageObject replyToTopMsg, TL_stories.StoryItem replyStory, int guid, String query_shortcut, int query_shortcut_id) { + manualRecording = false; requestAudioFocus(true); recordQueue.cancelRunnable(recordStartRunnable); recordQueue.postRunnable(() -> { @@ -4151,6 +4151,22 @@ public class MediaController implements AudioManager.OnAudioFocusChangeListener, }); } + public void cleanRecording(boolean delete) { + recordingAudio = null; + AutoDeleteMediaTask.unlockFile(recordingAudioFile); + if (delete && recordingAudioFile != null) { + try { + recordingAudioFile.delete(); + } catch (Exception e) { + FileLog.e(e); + } + } + recordingAudioFile = null; + manualRecording = false; + raiseToEarRecord = false; + ignoreOnPause = false; + } + private void stopRecordingInternal(final int send, boolean notify, int scheduleDate, boolean once) { if (send != 0) { final TLRPC.TL_document audioToSend = recordingAudio; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java index bc8dc9de1..f3cc6fb46 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesController.java @@ -242,7 +242,7 @@ public class MessagesController extends BaseController implements NotificationCe public boolean dialogFiltersLoaded; public ArrayList suggestedFilters = new ArrayList<>(); - private LongSparseArray> updatesQueueChannels = new LongSparseArray<>(); + private final LongSparseArray> updatesQueueChannels = new LongSparseArray<>(); private LongSparseLongArray updatesStartWaitTimeChannels = new LongSparseLongArray(); private LongSparseIntArray channelsPts = new LongSparseIntArray(); private LongSparseArray gettingDifferenceChannels = new LongSparseArray<>(); @@ -13485,9 +13485,11 @@ public class MessagesController extends BaseController implements NotificationCe }); return; } - if (processInvitedUsers != null) { - processInvitedUsers.run(null); - } + AndroidUtilities.runOnUIThread(() -> { + if (processInvitedUsers != null) { + processInvitedUsers.run(null); + } + }); if ("USER_ALREADY_PARTICIPANT".equals(error.text) && ignoreIfAlreadyExists) { if (onFinishRunnable != null) { AndroidUtilities.runOnUIThread(onFinishRunnable); @@ -13523,9 +13525,11 @@ public class MessagesController extends BaseController implements NotificationCe updates = (TLRPC.Updates) response; } else { FileLog.e("unexpected " + response + " in addUserToChat"); - if (processInvitedUsers != null) { - processInvitedUsers.run(null); - } + AndroidUtilities.runOnUIThread(() -> { + if (processInvitedUsers != null) { + processInvitedUsers.run(null); + } + }); return; } for (int a = 0; a < updates.updates.size(); a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java index cd7b54b56..39bd7203b 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/MessagesStorage.java @@ -104,7 +104,7 @@ public class MessagesStorage extends BaseController { } } - public final static int LAST_DB_VERSION = 151; + public final static int LAST_DB_VERSION = 152; private boolean databaseMigrationInProgress; public boolean showClearDatabaseAlert; private LongSparseIntArray dialogIsForum = new LongSparseIntArray(); @@ -698,7 +698,7 @@ public class MessagesStorage extends BaseController { database.executeFast("CREATE TABLE stories (dialog_id INTEGER, story_id INTEGER, data BLOB, custom_params BLOB, PRIMARY KEY (dialog_id, story_id));").stepThis().dispose(); database.executeFast("CREATE TABLE stories_counter (dialog_id INTEGER PRIMARY KEY, count INTEGER, max_read INTEGER);").stepThis().dispose(); - database.executeFast("CREATE TABLE profile_stories (dialog_id INTEGER, story_id INTEGER, data BLOB, type INTEGER, PRIMARY KEY(dialog_id, story_id));").stepThis().dispose(); + database.executeFast("CREATE TABLE profile_stories (dialog_id INTEGER, story_id INTEGER, data BLOB, type INTEGER, seen INTEGER, PRIMARY KEY(dialog_id, story_id));").stepThis().dispose(); database.executeFast("CREATE TABLE story_drafts (id INTEGER PRIMARY KEY, date INTEGER, data BLOB, type INTEGER);").stepThis().dispose(); diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/SegmentTree.java b/TMessagesProj/src/main/java/org/telegram/messenger/SegmentTree.java index cc78ff746..71be5ff63 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/SegmentTree.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/SegmentTree.java @@ -3,9 +3,9 @@ package org.telegram.messenger; public class SegmentTree { private Node[] heap; - private int[] array; + private long[] array; - public SegmentTree(int[] array) { + public SegmentTree(long[] array) { this.array = array; if (array.length < 30) { return; @@ -37,9 +37,9 @@ public class SegmentTree { } } - public int rMaxQ(int from, int to) { + public long rMaxQ(int from, int to) { if (array.length < 30) { - int max = Integer.MIN_VALUE; + long max = Long.MIN_VALUE; if (from < 0) from = 0; if (to > array.length - 1) to = array.length - 1; for (int i = from; i <= to; i++) { @@ -50,7 +50,7 @@ public class SegmentTree { return rMaxQ(1, from, to); } - private int rMaxQ(int v, int from, int to) { + private long rMaxQ(int v, int from, int to) { Node n = heap[v]; //If you did a range update that contained this node, you can infer the Min value without going down the tree if (n.pendingVal != null && contains(n.from, n.to, from, to)) { @@ -63,8 +63,8 @@ public class SegmentTree { if (intersects(from, to, n.from, n.to)) { propagate(v); - int leftMin = rMaxQ(2 * v, from, to); - int rightMin = rMaxQ(2 * v + 1, from, to); + final long leftMin = rMaxQ(2 * v, from, to); + final long rightMin = rMaxQ(2 * v + 1, from, to); return Math.max(leftMin, rightMin); } @@ -72,9 +72,9 @@ public class SegmentTree { return 0; } - public int rMinQ(int from, int to) { + public long rMinQ(int from, int to) { if (array.length < 30) { - int min = Integer.MAX_VALUE; + long min = Long.MAX_VALUE; if (from < 0) from = 0; if (to > array.length - 1) to = array.length - 1; for (int i = from; i <= to; i++) { @@ -85,7 +85,7 @@ public class SegmentTree { return rMinQ(1, from, to); } - private int rMinQ(int v, int from, int to) { + private long rMinQ(int v, int from, int to) { Node n = heap[v]; //If you did a range update that contained this node, you can infer the Min value without going down the tree if (n.pendingVal != null && contains(n.from, n.to, from, to)) { @@ -98,8 +98,8 @@ public class SegmentTree { if (intersects(from, to, n.from, n.to)) { propagate(v); - int leftMin = rMinQ(2 * v, from, to); - int rightMin = rMinQ(2 * v + 1, from, to); + long leftMin = rMinQ(2 * v, from, to); + long rightMin = rMinQ(2 * v + 1, from, to); return Math.min(leftMin, rightMin); } @@ -136,9 +136,9 @@ public class SegmentTree { } static class Node { - int sum; - int max; - int min; + long sum; + long max; + long min; Integer pendingVal = null; int from; diff --git a/TMessagesProj/src/main/java/org/telegram/messenger/video/WebmEncoder.java b/TMessagesProj/src/main/java/org/telegram/messenger/video/WebmEncoder.java index d7d3feddf..3dce8ec35 100644 --- a/TMessagesProj/src/main/java/org/telegram/messenger/video/WebmEncoder.java +++ b/TMessagesProj/src/main/java/org/telegram/messenger/video/WebmEncoder.java @@ -445,6 +445,9 @@ public class WebmEncoder { if (bitmap != null) { entity.matrix.postScale(1f / bitmap.getWidth(), 1f / bitmap.getHeight()); } + if ((entity.subType & 2) != 0) { + entity.matrix.postScale(-1, 1, .5f, .5f); + } entity.matrix.postScale(entity.width * W, entity.height * H); entity.matrix.postTranslate(entity.x * W, entity.y * H); entity.matrix.postRotate((float) (-entity.rotation / Math.PI * 180), (entity.x + entity.width) * W, (entity.x + entity.height) * H); diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/tl/TL_stories.java b/TMessagesProj/src/main/java/org/telegram/tgnet/tl/TL_stories.java index 823d1895f..3fce977ca 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/tl/TL_stories.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/tl/TL_stories.java @@ -1128,6 +1128,28 @@ public class TL_stories { } } + public static class TL_stories_incrementStoryViews extends TLObject { + public static final int constructor = 0xb2028afb; + + public TLRPC.InputPeer peer; + public ArrayList id = new ArrayList<>(); + + public TLObject deserializeResponse(AbstractSerializedData stream, int constructor, boolean exception) { + return TLRPC.Bool.TLdeserialize(stream, constructor, exception); + } + + public void serializeToStream(AbstractSerializedData stream) { + stream.writeInt32(constructor); + peer.serializeToStream(stream); + stream.writeInt32(0x1cb5c415); + int count = id.size(); + stream.writeInt32(count); + for (int a = 0; a < count; a++) { + stream.writeInt32(id.get(a)); + } + } + } + public static class TL_stories_getStoryViewsList extends TLObject { public static final int constructor = 0x7ed23c57; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java index 1325b30ae..ace306d3a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ActionBarMenuItem.java @@ -1945,6 +1945,13 @@ public class ActionBarMenuItem extends FrameLayout { } } + public void setSubItemShown(int id, boolean show) { + if (show) + showSubItem(id); + else + hideSubItem(id); + } + public int getVisibleSubItemsCount() { int count = 0; for (int i = 0; i < popupLayout.getItemsCount(); ++i) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UnconfirmedAuthHintCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UnconfirmedAuthHintCell.java index 26e3da62e..48a3b8928 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/UnconfirmedAuthHintCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/UnconfirmedAuthHintCell.java @@ -167,7 +167,8 @@ public class UnconfirmedAuthHintCell extends FrameLayout { noButton.setOnClickListener(v -> { noButton.setLoading(true); MessagesController.getInstance(currentAccount).getUnconfirmedAuthController().deny(auths, success -> { - showLoginPreventedSheet(success); + if (LaunchActivity.isActive) + showLoginPreventedSheet(success); noButton.setLoading(false); MessagesController.getInstance(currentAccount).getUnconfirmedAuthController().cleanup(); }); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java index eda310db9..50ae26a72 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelMonetizationLayout.java @@ -374,7 +374,7 @@ public class ChannelMonetizationLayout extends FrameLayout { formatter.setGroupingUsed(false); } formatter.setMaximumFractionDigits(crypto_amount / 1_000_000_000.0 > 1.5 ? 2 : 6); - SpannableStringBuilder ssb = new SpannableStringBuilder(replaceTON("TON " + formatter.format(crypto_amount / 1_000_000_000.0), balanceTitle.getPaint())); + SpannableStringBuilder ssb = new SpannableStringBuilder(replaceTON("TON " + formatter.format(crypto_amount / 1_000_000_000.0), balanceTitle.getPaint(), .9f, true)); int index = TextUtils.indexOf(ssb, "."); if (index >= 0) { ssb.setSpan(balanceTitleSizeSpan, index, ssb.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); @@ -491,7 +491,7 @@ public class ChannelMonetizationLayout extends FrameLayout { } items.add(UItem.asCenterShadow(titleInfo)); if (impressionsChart != null && !impressionsChart.isEmpty) { - items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_LINEAR, stats_dc, impressionsChart)); + items.add(UItem.asChart(StatisticActivity.VIEW_TYPE_BAR_LINEAR, stats_dc, impressionsChart)); items.add(UItem.asShadow(-1, null)); } if (revenueChart != null && !revenueChart.isEmpty) { @@ -557,10 +557,10 @@ public class ChannelMonetizationLayout extends FrameLayout { private void loadTransactions() { if (loadingTransactions) return; if (transactions.size() >= transactionsTotalCount && transactionsTotalCount != 0) return; - TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId); - if (chat == null || !chat.creator) { - return; - } +// TLRPC.Chat chat = MessagesController.getInstance(currentAccount).getChat(-dialogId); +// if (chat == null || !chat.creator) { +// return; +// } loadingTransactions = true; TL_stats.TL_getBroadcastRevenueTransactions req = new TL_stats.TL_getBroadcastRevenueTransactions(); @@ -608,25 +608,33 @@ public class ChannelMonetizationLayout extends FrameLayout { public static CharSequence replaceTON(CharSequence text, TextPaint textPaint) { return replaceTON(text, textPaint, 1f, true); } - public static CharSequence replaceTON(CharSequence text, TextPaint textPaint, boolean animated) { - return replaceTON(text, textPaint, 1f, animated); + public static CharSequence replaceTON(CharSequence text, TextPaint textPaint, boolean large) { + return replaceTON(text, textPaint, 1f, large); } - public static CharSequence replaceTON(CharSequence text, TextPaint textPaint, float scale, boolean animated) { + + public static CharSequence replaceTON(CharSequence text, TextPaint textPaint, float scale, boolean large) { + return replaceTON(text, textPaint, scale, 0, large); + } + + public static CharSequence replaceTON(CharSequence text, TextPaint textPaint, float scale, float translateY, boolean large) { if (ChannelMonetizationLayout.tonString == null) { ChannelMonetizationLayout.tonString = new HashMap<>(); } - final int key = textPaint.getFontMetricsInt().bottom * (animated ? 1 : -1); + final int key = textPaint.getFontMetricsInt().bottom * (large ? 1 : -1) * (int) (100 * scale); SpannableString tonString = ChannelMonetizationLayout.tonString.get(key); if (tonString == null) { tonString = new SpannableString("T"); - if (animated) { - AnimatedEmojiSpan span = new AnimatedEmojiSpan(DIAMOND_EMOJI, scale, textPaint.getFontMetricsInt()); - span.emoji = "πŸ’Ž"; - span.cacheType = AnimatedEmojiDrawable.CACHE_TYPE_STANDARD_EMOJI; + if (large) { + ColoredImageSpan span = new ColoredImageSpan(R.drawable.ton); + span.setScale(scale, scale); + span.setColorKey(Theme.key_windowBackgroundWhiteBlueText2); + span.setRelativeSize(textPaint.getFontMetricsInt()); + span.spaceScaleX = .9f; tonString.setSpan(span, 0, tonString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } else { ColoredImageSpan span = new ColoredImageSpan(R.drawable.mini_ton); - span.setTranslateY(-dp(.66f)); + span.setScale(scale, scale); + span.setTranslateY(translateY); span.spaceScaleX = .95f; tonString.setSpan(span, 0, tonString.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); } @@ -1088,9 +1096,11 @@ public class ChannelMonetizationLayout extends FrameLayout { textView.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM)); textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText, resourcesProvider)); SpannableString animatedDiamond = new SpannableString("πŸ’Ž"); - AnimatedEmojiSpan span = new AnimatedEmojiSpan(DIAMOND_EMOJI, .98f, textView.getPaint().getFontMetricsInt()); - span.emoji = "πŸ’Ž"; - span.cacheType = AnimatedEmojiDrawable.CACHE_TYPE_ALERT_STANDARD_EMOJI; + ColoredImageSpan span = new ColoredImageSpan(R.drawable.ton); + span.setScale(.9f, .9f); + span.setColorKey(Theme.key_windowBackgroundWhiteBlueText2); + span.setRelativeSize(textView.getPaint().getFontMetricsInt()); + span.spaceScaleX = .9f; animatedDiamond.setSpan(span, 0, animatedDiamond.length(), Spanned.SPAN_EXCLUSIVE_EXCLUSIVE); textView.setText(AndroidUtilities.replaceCharSequence("πŸ’Ž", getString(R.string.MonetizationInfoTONTitle), animatedDiamond)); layout.addView(textView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, 8, 20, 8, 0)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BarChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BarChartView.java index b7559d272..4109cb146 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BarChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BarChartView.java @@ -66,7 +66,7 @@ public class BarChartView extends BaseChartView { } else { p = chartData.xPercentage[1] * fullWidth; } - int[] y = line.line.y; + final long[] y = line.line.y; int j = 0; float selectedX = 0f; @@ -148,7 +148,7 @@ public class BarChartView extends BaseChartView { } else { p = chartData.xPercentage[1] * pickerWidth; } - int[] y = line.line.y; + final long[] y = line.line.y; float a = line.alpha; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java index 1fab72022..6b4928d77 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/BaseChartView.java @@ -39,6 +39,7 @@ import org.telegram.ui.Components.CubicBezierInterpolator; import java.util.ArrayList; import java.util.Arrays; +import java.util.List; public abstract class BaseChartView extends View implements ChartPickerDelegate.Listener { @@ -293,7 +294,7 @@ public abstract class BaseChartView } if (legendShowing && selectedIndex < chartData.x.length) { - legendSignatureView.setData(selectedIndex, chartData.x[selectedIndex], (ArrayList) lines, false, chartData.yTooltipFormatter); + legendSignatureView.setData(selectedIndex, chartData.x[selectedIndex], (ArrayList) lines, false, chartData.yTooltipFormatter, chartData.yRate); } invalidatePickerChart = true; @@ -302,6 +303,10 @@ public abstract class BaseChartView int lastW = 0; int lastH = 0; + private Rect exclusionRect = new Rect(); + private List exclusionRects = new ArrayList(); + { exclusionRects.add(exclusionRect); } + @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { super.onMeasure(widthMeasureSpec, heightMeasureSpec); @@ -332,6 +337,11 @@ public abstract class BaseChartView onPickerDataChanged(false, true, false); } + + if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.Q) { + exclusionRect.set(0, getMeasuredHeight() - (PICKER_PADDING + pikerHeight + PICKER_PADDING), getMeasuredWidth(), getMeasuredHeight()); + setSystemGestureExclusionRects(exclusionRects); + } } @@ -799,11 +809,11 @@ public abstract class BaseChartView long lastTime = 0; - private void setMaxMinValue(int newMaxHeight, int newMinHeight, boolean animated) { + private void setMaxMinValue(long newMaxHeight, long newMinHeight, boolean animated) { setMaxMinValue(newMaxHeight, newMinHeight, animated, false, false); } - protected void setMaxMinValue(int newMaxHeight, int newMinHeight, boolean animated, boolean force, boolean useAnimator) { + protected void setMaxMinValue(long newMaxHeight, long newMinHeight, boolean animated, boolean force, boolean useAnimator) { boolean heightChanged = true; if ((Math.abs(ChartHorizontalLinesData.lookupHeight(newMaxHeight) - animateToMaxHeight) < thresholdMaxHeight) || newMaxHeight == 0) { heightChanged = false; @@ -918,7 +928,7 @@ public abstract class BaseChartView alphaAnimator.start(); } - protected ChartHorizontalLinesData createHorizontalLinesData(int newMaxHeight, int newMinHeight, int formatter) { + protected ChartHorizontalLinesData createHorizontalLinesData(long newMaxHeight, long newMinHeight, int formatter) { return new ChartHorizontalLinesData(newMaxHeight, newMinHeight, useMinHeight, chartData.yRate, formatter, signaturePaint, signaturePaint2); } @@ -1030,7 +1040,7 @@ public abstract class BaseChartView chartCaptured = false; onActionUp(); invalidate(); - int min = 0; + long min = 0; if (useMinHeight) min = findMinValue(startXIndex, endXIndex); setMaxMinValue(findMaxValue(startXIndex, endXIndex), min, true, true, false); return true; @@ -1117,7 +1127,7 @@ public abstract class BaseChartView public void moveLegend(float offset) { if (chartData == null || selectedIndex == -1 || !legendShowing) return; - legendSignatureView.setData(selectedIndex, chartData.x[selectedIndex], (ArrayList) lines, false, chartData.yTooltipFormatter); + legendSignatureView.setData(selectedIndex, chartData.x[selectedIndex], (ArrayList) lines, false, chartData.yTooltipFormatter, chartData.yRate); legendSignatureView.setVisibility(VISIBLE); legendSignatureView.measure( MeasureSpec.makeMeasureSpec(getMeasuredWidth(), MeasureSpec.AT_MOST), @@ -1139,12 +1149,12 @@ public abstract class BaseChartView ); } - public int findMaxValue(int startXIndex, int endXIndex) { + public long findMaxValue(int startXIndex, int endXIndex) { int linesSize = lines.size(); - int maxValue = 0; + long maxValue = 0; for (int j = 0; j < linesSize; j++) { if (!lines.get(j).enabled) continue; - int lineMax = lines.get(j).line.segmentTree.rMaxQ(startXIndex, endXIndex); + long lineMax = lines.get(j).line.segmentTree.rMaxQ(startXIndex, endXIndex); if (lineMax > maxValue) maxValue = lineMax; } @@ -1152,12 +1162,12 @@ public abstract class BaseChartView } - public int findMinValue(int startXIndex, int endXIndex) { + public long findMinValue(int startXIndex, int endXIndex) { int linesSize = lines.size(); - int minValue = Integer.MAX_VALUE; + long minValue = Long.MAX_VALUE; for (int j = 0; j < linesSize; j++) { if (!lines.get(j).enabled) continue; - int lineMin = lines.get(j).line.segmentTree.rMinQ(startXIndex, endXIndex); + long lineMin = lines.get(j).line.segmentTree.rMinQ(startXIndex, endXIndex); if (lineMin < minValue) minValue = lineMin; } @@ -1195,12 +1205,16 @@ public abstract class BaseChartView if (chartData != null) { updateIndexes(); - int min = useMinHeight ? findMinValue(startXIndex, endXIndex) : 0; + final long min = useMinHeight ? findMinValue(startXIndex, endXIndex) : 0; setMaxMinValue(findMaxValue(startXIndex, endXIndex), min, false); pickerMaxHeight = 0; pickerMinHeight = Integer.MAX_VALUE; initPickerMaxHeight(); - legendSignatureView.setSize(lines.size()); + if (chartData.yTooltipFormatter == ChartData.FORMATTER_TON) { + legendSignatureView.setSize(2 * lines.size()); + } else { + legendSignatureView.setSize(lines.size()); + } invalidatePickerChart = true; updateLineSignature(); @@ -1261,7 +1275,7 @@ public abstract class BaseChartView chartFullWidth = (chartWidth / (pickerDelegate.pickerEnd - pickerDelegate.pickerStart)); updateIndexes(); - int min = useMinHeight ? findMinValue(startXIndex, endXIndex) : 0; + final long min = useMinHeight ? findMinValue(startXIndex, endXIndex) : 0; setMaxMinValue(findMaxValue(startXIndex, endXIndex), min, animated, force, useAniamtor); if (legendShowing && !force) { @@ -1422,13 +1436,13 @@ public abstract class BaseChartView updatePickerMinMaxHeight(); if (legendShowing) - legendSignatureView.setData(selectedIndex, chartData.x[selectedIndex], (ArrayList) lines, true, chartData.yTooltipFormatter); + legendSignatureView.setData(selectedIndex, chartData.x[selectedIndex], (ArrayList) lines, true, chartData.yTooltipFormatter, chartData.yRate); } protected void updatePickerMinMaxHeight() { if (!ANIMATE_PICKER_SIZES) return; - int max = 0; - int min = Integer.MAX_VALUE; + long max = 0; + long min = Long.MAX_VALUE; for (LineViewData l : lines) { if (l.enabled && l.line.maxValue > max) max = l.line.maxValue; if (l.enabled && l.line.minValue < min) min = l.line.minValue; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/DoubleLinearChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/DoubleLinearChartView.java index 2825ddae1..d72be8fee 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/DoubleLinearChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/DoubleLinearChartView.java @@ -63,7 +63,7 @@ public class DoubleLinearChartView extends BaseChartView max) max = localMax; } return max; } - public int findMinValue(int startXIndex, int endXIndex) { + public long findMinValue(int startXIndex, int endXIndex) { if (lines.isEmpty()) { return 0; } - int n = lines.size(); - int min = Integer.MAX_VALUE; + final int n = lines.size(); + long min = Long.MAX_VALUE; for (int i = 0; i < n; i++) { - int localMin = lines.get(i).enabled ? (int) (chartData.lines.get(i).segmentTree.rMinQ(startXIndex, endXIndex) * chartData.linesK[i]) : Integer.MAX_VALUE; + long localMin = lines.get(i).enabled ? (int) (chartData.lines.get(i).segmentTree.rMinQ(startXIndex, endXIndex) * chartData.linesK[i]) : Integer.MAX_VALUE; if (localMin < min) min = localMin; } return min; @@ -299,12 +299,12 @@ public class DoubleLinearChartView extends BaseChartView max) max = l.line.maxValue; } if (lines.size() > 1) { - max = (int) (max * chartData.linesK[1]); + max = (long) (max * chartData.linesK[1]); } if (max > 0 && max != animatedToPickerMaxHeight) { @@ -324,7 +324,7 @@ public class DoubleLinearChartView extends BaseChartView { + public LinearBarChartView(Context context) { + super(context); + } + + @Override + protected void init() { + useMinHeight = true; + super.init(); + + } + + @Override + protected void drawChart(Canvas canvas) { + if (chartData != null) { + float fullWidth = (chartWidth / (pickerDelegate.pickerEnd - pickerDelegate.pickerStart)); + float offset = fullWidth * (pickerDelegate.pickerStart) - HORIZONTAL_PADDING; + + for (int k = 0; k < lines.size(); k++) { + LineViewData line = lines.get(k); + if (!line.enabled && line.alpha == 0) continue; + + int j = 0; + + float p; + if (chartData.xPercentage.length < 2) { + p = 0f; + } else { + p = chartData.xPercentage[1] * fullWidth; + } + final long[] y = line.line.y; + int additionalPoints = (int) (HORIZONTAL_PADDING / p) + 1; + + line.chartPath.reset(); + boolean first = true; + + int localStart = Math.max(0, startXIndex - additionalPoints); + int localEnd = Math.min(chartData.xPercentage.length - 1, endXIndex + additionalPoints); + for (int i = localStart; i <= localEnd; i++) { + if (y[i] < 0) continue; + float xPoint = chartData.xPercentage[i] * fullWidth - offset; + float yPercentage = ((float) y[i] - currentMinHeight) / (currentMaxHeight - currentMinHeight); + float padding = line.paint.getStrokeWidth() / 2f; + float yPoint = getMeasuredHeight() - chartBottom - padding - (yPercentage) * (getMeasuredHeight() - chartBottom - SIGNATURE_TEXT_HEIGHT - padding); + + if (USE_LINES) { + if (j == 0) { + line.linesPath[j++] = xPoint - p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = yPoint; + } else if (i == localEnd) { + line.linesPath[j++] = xPoint - p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint - p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = getMeasuredHeight() - chartBottom - padding; + } else { + line.linesPath[j++] = xPoint - p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint - p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = yPoint; + line.linesPath[j++] = xPoint + p / 2f; + line.linesPath[j++] = yPoint; + } + } else { + if (first) { + first = false; + line.chartPath.moveTo(xPoint - p / 2f, yPoint); + } else { + line.chartPath.lineTo(xPoint - p / 2f, yPoint); + } + line.chartPath.lineTo(xPoint + p / 2f, yPoint); + } + } + + canvas.save(); + float transitionAlpha = 1f; + if (transitionMode == TRANSITION_MODE_PARENT) { + transitionAlpha = transitionParams.progress > 0.5f ? 0 : 1f - transitionParams.progress * 2f; + canvas.scale( + 1 + 2 * transitionParams.progress, 1f, + transitionParams.pX, transitionParams.pY + ); + } else if (transitionMode == TRANSITION_MODE_CHILD) { + transitionAlpha = transitionParams.progress < 0.3f ? 0 : transitionParams.progress; + canvas.save(); + canvas.scale( + transitionParams.progress, transitionParams.needScaleY ? transitionParams.progress : 1f, + transitionParams.pX, transitionParams.pY + ); + } else if (transitionMode == TRANSITION_MODE_ALPHA_ENTER) { + transitionAlpha = transitionParams.progress; + } + line.paint.setAlpha((int) (255 * line.alpha * transitionAlpha)); + if(endXIndex - startXIndex > 100){ + line.paint.setStrokeCap(Paint.Cap.SQUARE); + } else { + line.paint.setStrokeCap(Paint.Cap.ROUND); + } + if (!USE_LINES) canvas.drawPath(line.chartPath, line.paint); + else canvas.drawLines(line.linesPath, 0, j, line.paint); + + canvas.restore(); + } + } + } + + @Override + protected void drawPickerChart(Canvas canvas) { + int bottom = getMeasuredHeight() - PICKER_PADDING; + int top = getMeasuredHeight() - pikerHeight - PICKER_PADDING; + + int nl = lines.size(); + + if (chartData != null) { + float p; + if (chartData.xPercentage.length < 2) { + p = 1f; + } else { + p = chartData.xPercentage[1] * pickerWidth; + } + for (int k = 0; k < nl; k++) { + LineViewData line = lines.get(k); + if (!line.enabled && line.alpha == 0) continue; + + line.bottomLinePath.reset(); + + int n = chartData.xPercentage.length; + int j = 0; + + final long[] y = line.line.y; + + line.chartPath.reset(); + for (int i = 0; i < n; i++) { + if (y[i] < 0) continue; + float xPoint = chartData.xPercentage[i] * pickerWidth; + float h = ANIMATE_PICKER_SIZES ? pickerMaxHeight : chartData.maxValue; + float hMin = ANIMATE_PICKER_SIZES ? pickerMinHeight : chartData.minValue; + float yPercentage = (y[i] - hMin) / (h - hMin); + float yPoint = (1f - yPercentage) * pikerHeight; + + if (USE_LINES) { + if (j == 0) { + line.linesPathBottom[j++] = xPoint - p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = yPoint; + } else if (i == n - 1) { + line.linesPathBottom[j++] = xPoint - p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint - p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = 0; + } else { + line.linesPathBottom[j++] = xPoint - p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint - p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = yPoint; + line.linesPathBottom[j++] = xPoint + p / 2f; + line.linesPathBottom[j++] = yPoint; + } + } else { + if (i == 0) { + line.bottomLinePath.moveTo(xPoint - p / 2f, yPoint); + } else { + line.bottomLinePath.lineTo(xPoint - p / 2f, yPoint); + } + line.bottomLinePath.lineTo(xPoint + p / 2f, yPoint); + } + } + + line.linesPathBottomSize = j; + + if (!line.enabled && line.alpha == 0) continue; + line.bottomLinePaint.setAlpha((int) (255 * line.alpha)); + if (USE_LINES) + canvas.drawLines(line.linesPathBottom, 0, line.linesPathBottomSize, line.bottomLinePaint); + else + canvas.drawPath(line.bottomLinePath, line.bottomLinePaint); + } + } + } + + @Override + public LineViewData createLineViewData(ChartData.Line line) { + return new LineViewData(line, true); + } +} diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/LinearChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/LinearChartView.java index 3f3a315a5..a001fc2c5 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/LinearChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/LinearChartView.java @@ -38,7 +38,7 @@ public class LinearChartView extends BaseChartView { } else { p = chartData.xPercentage[1] * fullWidth; } - int[] y = line.line.y; + final long[] y = line.line.y; int additionalPoints = (int) (HORIZONTAL_PADDING / p) + 1; line.chartPath.reset(); @@ -122,7 +122,7 @@ public class LinearChartView extends BaseChartView { int n = chartData.xPercentage.length; int j = 0; - int[] y = line.line.y; + final long[] y = line.line.y; line.chartPath.reset(); for (int i = 0; i < n; i++) { @@ -166,6 +166,6 @@ public class LinearChartView extends BaseChartView { @Override public LineViewData createLineViewData(ChartData.Line line) { - return new LineViewData(line); + return new LineViewData(line, false); } } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java index 56f1b21b7..3976f658c 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/PieChartView.java @@ -243,7 +243,7 @@ public class PieChartView extends StackLinearChartView { LineViewData line = lines.get(k); if (!line.enabled && line.alpha == 0) continue; - int[] y = line.line.y; + final long[] y = line.line.y; float yPercentage; if (drawingLinesCount == 1) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/StackBarChartView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/StackBarChartView.java index a131107e6..7800c240a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/StackBarChartView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/StackBarChartView.java @@ -16,7 +16,7 @@ import org.telegram.ui.Charts.view_data.StackBarViewData; public class StackBarChartView extends BaseChartView { - private int[] yMaxPoints; + private long[] yMaxPoints; public StackBarChartView(Context context) { this(context, null); @@ -91,7 +91,7 @@ public class StackBarChartView extends BaseChartView yMaxPoints[k]) yMaxPoints[k] = y; } @@ -263,7 +263,7 @@ public class StackBarChartView extends BaseChartView extends BaseCha for (int k = 0; k < lines.size(); k++) { LineViewData line = lines.get(k); if (!line.enabled && line.alpha == 0) continue; - int[] y = line.line.y; + final long[] y = line.line.y; float yPercentage; @@ -507,7 +507,7 @@ public class StackLinearChartView extends BaseCha } @Override - public int findMaxValue(int startXIndex, int endXIndex) { + public long findMaxValue(int startXIndex, int endXIndex) { return 100; } @@ -562,7 +562,7 @@ public class StackLinearChartView extends BaseCha for (int k = 0; k < lines.size(); k++) { LineViewData line = lines.get(k); if (!line.enabled && line.alpha == 0) continue; - int[] y = line.line.y; + final long[] y = line.line.y; float yPercentage; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/ChartData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/ChartData.java index e3d8a0388..eded41e50 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/ChartData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/ChartData.java @@ -24,8 +24,8 @@ public class ChartData { public float[] xPercentage; public String[] daysLookup; public ArrayList lines = new ArrayList<>(); - public int maxValue = 0; - public int minValue = Integer.MAX_VALUE; + public long maxValue = 0; + public long minValue = Long.MAX_VALUE; public float oneDayPercentage = 0f; @@ -59,9 +59,9 @@ public class ChartData { lines.add(l); int len = a.length() - 1; l.id = a.getString(0); - l.y = new int[len]; + l.y = new long[len]; for (int j = 0; j < len; j++) { - l.y[j] = a.getInt(j + 1); + l.y[j] = a.getLong(j + 1); if (l.y[j] > l.maxValue) l.maxValue = l.y[j]; if (l.y[j] < l.minValue) l.minValue = l.y[j]; } @@ -247,13 +247,13 @@ public class ChartData { } public class Line { - public int[] y; + public long[] y; public SegmentTree segmentTree; public String id; public String name; - public int maxValue = 0; - public int minValue = Integer.MAX_VALUE; + public long maxValue = 0; + public long minValue = Long.MAX_VALUE; public int colorKey; public int color = Color.BLACK; public int colorDark = Color.WHITE; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/DoubleLinearChartData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/DoubleLinearChartData.java index b6646ecc4..4d3dbcfc3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/DoubleLinearChartData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/DoubleLinearChartData.java @@ -16,16 +16,16 @@ public class DoubleLinearChartData extends ChartData { protected void measure() { super.measure(); int n = lines.size(); - int max = 0; + long max = 0; for (int i = 0; i < n; i++) { - int m = lines.get(i).maxValue; + final long m = lines.get(i).maxValue; if (m > max) max = m; } linesK = new float[n]; for (int i = 0; i < n; i++) { - int m = lines.get(i).maxValue; + final long m = lines.get(i).maxValue; if (max == m) { linesK[i] = 1; continue; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackBarChartData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackBarChartData.java index 9522e5067..7cfd7c45f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackBarChartData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackBarChartData.java @@ -7,7 +7,7 @@ import org.telegram.messenger.SegmentTree; public class StackBarChartData extends ChartData { - public int[] ySum; + public long[] ySum; public SegmentTree ySumSegmentTree; public StackBarChartData(JSONObject jsonObject) throws JSONException { @@ -19,7 +19,7 @@ public class StackBarChartData extends ChartData { int n = lines.get(0).y.length; int k = lines.size(); - ySum = new int[n]; + ySum = new long[n]; for (int i = 0; i < n; i++) { ySum[i] = 0; for (int j = 0; j < k; j++) { @@ -30,7 +30,7 @@ public class StackBarChartData extends ChartData { ySumSegmentTree = new SegmentTree(ySum); } - public int findMax(int start, int end) { + public long findMax(int start, int end) { return ySumSegmentTree.rMaxQ(start, end); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackLinearChartData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackLinearChartData.java index dd62886d3..c8bbba800 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackLinearChartData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/data/StackLinearChartData.java @@ -9,10 +9,10 @@ import java.util.Arrays; public class StackLinearChartData extends ChartData { - int[] ySum; + long[] ySum; SegmentTree ySumSegmentTree; - public int[][] simplifiedY; + public long[][] simplifiedY; public int simplifiedSize; @@ -26,7 +26,7 @@ public class StackLinearChartData extends ChartData { for (int k = 0; k < lines.size(); k++) { int n = x.length; for (int i = 0; i < n; i++) { - int v = lines.get(k).y[i]; + long v = lines.get(k).y[i]; totalCount[k] += v; if (v == 0) { emptyCount[k]++; @@ -49,7 +49,7 @@ public class StackLinearChartData extends ChartData { int n = lines.get(0).y.length; int k = lines.size(); - ySum = new int[n]; + ySum = new long[n]; for (int i = 0; i < n; i++) { ySum[i] = 0; for (int j = 0; j < k; j++) { @@ -85,7 +85,7 @@ public class StackLinearChartData extends ChartData { for (int i = 0; i < data.lines.size(); i++) { Line line = new Line(); - line.y = new int[n]; + line.y = new long[n]; line.id = data.lines.get(i).id; line.name = data.lines.get(i).name; line.colorKey = data.lines.get(i).colorKey; @@ -116,9 +116,9 @@ public class StackLinearChartData extends ChartData { int nl = lines.size(); int step = Math.max(1, Math.round(n / 140f)); int maxSize = n / step; - simplifiedY = new int[nl][maxSize]; + simplifiedY = new long[nl][maxSize]; - int[] max = new int[nl]; + long[] max = new long[nl]; for (int i = 0; i < n; i++) { for(int k = 0; k < nl; k++) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/BarViewData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/BarViewData.java index 972496b44..f678131b1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/BarViewData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/BarViewData.java @@ -12,7 +12,7 @@ public class BarViewData extends LineViewData { public int blendColor = 0; public BarViewData(ChartData.Line line) { - super(line); + super(line, false); paint.setStyle(Paint.Style.STROKE); unselectedPaint.setStyle(Paint.Style.STROKE); paint.setAntiAlias(false); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHorizontalLinesData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHorizontalLinesData.java index 0e8ef682c..d150d1820 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHorizontalLinesData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/ChartHorizontalLinesData.java @@ -1,5 +1,7 @@ package org.telegram.ui.Charts.view_data; +import static org.telegram.messenger.AndroidUtilities.dp; + import android.graphics.Canvas; import android.text.Layout; import android.text.StaticLayout; @@ -18,7 +20,7 @@ import java.util.Locale; public class ChartHorizontalLinesData { - public int[] values; + public long[] values; public CharSequence[] valuesStr; public CharSequence[] valuesStr2; private StaticLayout[] layouts; @@ -28,15 +30,15 @@ public class ChartHorizontalLinesData { public int fixedAlpha = 255; public ChartHorizontalLinesData( - int newMaxHeight, - int newMinHeight, + long newMaxHeight, + long newMinHeight, boolean useMinHeight, float k, int formatter, TextPaint firstTextPaint, TextPaint secondTextPaint ) { if (!useMinHeight) { - int v = newMaxHeight; + long v = newMaxHeight; if (newMaxHeight > 100) { v = round(newMaxHeight); } @@ -45,9 +47,9 @@ public class ChartHorizontalLinesData { int n; if (v < 6) { - n = Math.max(2, v + 1); + n = (int) Math.max(2, v + 1); } else if (v / 2 < 6) { - n = v / 2 + 1; + n = (int) (v / 2 + 1); if (v % 2 != 0) { n++; } @@ -55,7 +57,7 @@ public class ChartHorizontalLinesData { n = 6; } - values = new int[n]; + values = new long[n]; valuesStr = new CharSequence[n]; layouts = new StaticLayout[n]; if (k > 0) { @@ -69,7 +71,7 @@ public class ChartHorizontalLinesData { if (k > 0) { float v2 = (values[i] / k); if (skipFloatValues) { - if (v2 - ((int) v2) < 0.01f) { + if (v2 - ((int) v2) < 0.01f || formatter == ChartData.FORMATTER_TON) { valuesStr2[i] = format(1, secondTextPaint, (long) v2, formatter); } else { valuesStr2[i] = ""; @@ -81,29 +83,29 @@ public class ChartHorizontalLinesData { } } else { int n; - int dif = newMaxHeight - newMinHeight; + long dif = newMaxHeight - newMinHeight; float step; if (dif == 0) { newMinHeight--; n = 3; step = 1f; } else if (dif < 6) { - n = Math.max(2, dif + 1); + n = (int) Math.max(2, dif + 1); step = 1f; } else if (dif / 2 < 6) { - n = dif / 2 + dif % 2 + 1; + n = (int) (dif / 2 + dif % 2 + 1); step = 2f; } else { step = (newMaxHeight - newMinHeight) / 5f; if (step <= 0) { step = 1; - n = Math.max(2, newMaxHeight - newMinHeight + 1); + n = (int) (Math.max(2, newMaxHeight - newMinHeight + 1)); } else { n = 6; } } - values = new int[n]; + values = new long[n]; valuesStr = new CharSequence[n]; layouts = new StaticLayout[n]; if (k > 0) { @@ -117,7 +119,7 @@ public class ChartHorizontalLinesData { if (k > 0) { float v = (values[i] / k); if (skipFloatValues) { - if (v - ((int) v) < 0.01f) { + if (v - ((int) v) < 0.01f || formatter == ChartData.FORMATTER_TON) { valuesStr2[i] = format(1, secondTextPaint, (long) v, formatter); } else { valuesStr2[i] = ""; @@ -134,7 +136,7 @@ public class ChartHorizontalLinesData { public CharSequence format(int a, TextPaint paint, long v, int formatter) { if (formatter == ChartData.FORMATTER_TON) { if (a == 1) { - return BillingController.getInstance().formatCurrency(v, "USD"); + return "~" + BillingController.getInstance().formatCurrency(v, "USD"); } if (formatterTON == null) { DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US); @@ -145,13 +147,13 @@ public class ChartHorizontalLinesData { formatterTON.setGroupingUsed(false); } formatterTON.setMaximumFractionDigits(v > 1_000_000_000 ? 2 : 6); - return ChannelMonetizationLayout.replaceTON("TON " + formatterTON.format(v / 1_000_000_000.0), paint, false); + return ChannelMonetizationLayout.replaceTON("TON " + formatterTON.format(v / 1_000_000_000.0), paint, .8f, -dp(.66f), false); } return AndroidUtilities.formatWholeNumber((int) v, 0); } - public static int lookupHeight(int maxValue) { - int v = maxValue; + public static int lookupHeight(long maxValue) { + long v = maxValue; if (maxValue > 100) { v = round(maxValue); } @@ -160,7 +162,7 @@ public class ChartHorizontalLinesData { return step * 5; } - private static int round(int maxValue) { + private static long round(long maxValue) { float k = maxValue / 5; if (k % 10 == 0) return maxValue; else return ((maxValue / 10 + 1) * 10); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LegendSignatureView.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LegendSignatureView.java index c2f4bb89b..287d4cca6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LegendSignatureView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LegendSignatureView.java @@ -5,6 +5,11 @@ import android.animation.AnimatorListenerAdapter; import android.content.Context; import android.graphics.drawable.Drawable; import android.os.Build; +import android.text.SpannableString; +import android.text.Spanned; +import android.text.TextPaint; +import android.text.TextUtils; +import android.text.style.CharacterStyle; import android.transition.ChangeBounds; import android.transition.Fade; import android.transition.TransitionManager; @@ -18,6 +23,8 @@ import android.widget.LinearLayout; import android.widget.TextView; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.BillingController; +import org.telegram.messenger.LocaleController; import org.telegram.messenger.R; import org.telegram.ui.ActionBar.Theme; import org.telegram.ui.ChannelMonetizationLayout; @@ -38,7 +45,7 @@ public class LegendSignatureView extends FrameLayout { public boolean isTopHourChart; LinearLayout content; - Holder[] holdes; + Holder[] holders; TextView time; TextView hourTime; Drawable background; @@ -126,10 +133,10 @@ public class LegendSignatureView extends FrameLayout { public void setSize(int n) { content.removeAllViews(); - holdes = new Holder[n]; + holders = new Holder[n]; for (int i = 0; i < n; i++) { - holdes[i] = new Holder(); - content.addView(holdes[i].root); + holders[i] = new Holder(); + content.addView(holders[i].root); } } @@ -139,9 +146,10 @@ public class LegendSignatureView extends FrameLayout { long date, ArrayList lines, boolean animateChanges, - int formatter + int formatter, + float k ) { - int n = holdes.length; + int n = holders.length; if (animateChanges) { if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.KITKAT) { TransitionSet transition = new TransitionSet(); @@ -165,29 +173,34 @@ public class LegendSignatureView extends FrameLayout { if (useHour) hourTime.setText(hourFormat.format(date)); } - int sum = 0; + long sum = 0; - for (int i = 0; i < n; i++) { + for (int i = 0; i < lines.size(); i++) { if (lines.get(i).enabled) sum += lines.get(i).line.y[index]; } for (int i = 0; i < n; i++) { - Holder h = holdes[i]; + Holder h = holders[i]; + int formatterIndex = i % 2; + LineViewData l = lines.get(formatter == ChartData.FORMATTER_TON ? i / 2 : i); - if (!lines.get(i).enabled) { + if (!l.enabled) { h.root.setVisibility(View.GONE); } else { - ChartData.Line l = lines.get(i).line; if (h.root.getMeasuredHeight() == 0) { h.root.requestLayout(); } h.root.setVisibility(View.VISIBLE); - h.value.setText(formatWholeNumber(l.y[index], formatter, h.value)); - h.signature.setText(l.name); - if (l.colorKey >= 0 && Theme.hasThemeKey(l.colorKey)) { - h.value.setTextColor(Theme.getColor(l.colorKey, resourcesProvider)); + h.value.setText(formatWholeNumber(l.line.y[index], formatter, formatterIndex, h.value, k)); + if (formatter == ChartData.FORMATTER_TON) { + h.signature.setText(LocaleController.formatString(formatterIndex == 0 ? R.string.MonetizationChartInTON : R.string.MonetizationChartInUSD, l.line.name)); } else { - h.value.setTextColor(Theme.getCurrentTheme().isDark() ? l.colorDark : l.color); + h.signature.setText(l.line.name); + } + if (l.line.colorKey >= 0 && Theme.hasThemeKey(l.line.colorKey)) { + h.value.setTextColor(Theme.getColor(l.line.colorKey, resourcesProvider)); + } else { + h.value.setTextColor(Theme.getCurrentTheme().isDark() ? l.line.colorDark : l.line.color); } h.signature.setTextColor(Theme.getColor(Theme.key_dialogTextBlack, resourcesProvider)); @@ -224,20 +237,23 @@ public class LegendSignatureView extends FrameLayout { return s; } - private DecimalFormat formatterTON; - public CharSequence formatWholeNumber(int v, int formatter, TextView textView) { + public CharSequence formatWholeNumber(long v, int formatter, int formatterIndex, TextView textView, float k) { if (formatter == ChartData.FORMATTER_TON) { - if (formatterTON == null) { - DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US); - symbols.setDecimalSeparator('.'); - formatterTON = new DecimalFormat("#.##", symbols); - formatterTON.setMinimumFractionDigits(2); - formatterTON.setMaximumFractionDigits(6); - formatterTON.setGroupingUsed(false); + if (formatterIndex == 0) { + if (formatterTON == null) { + DecimalFormatSymbols symbols = new DecimalFormatSymbols(Locale.US); + symbols.setDecimalSeparator('.'); + formatterTON = new DecimalFormat("#.##", symbols); + formatterTON.setMinimumFractionDigits(2); + formatterTON.setMaximumFractionDigits(6); + formatterTON.setGroupingUsed(false); + } + formatterTON.setMaximumFractionDigits(v > 1_000_000_000 ? 2 : 6); + return ChannelMonetizationLayout.replaceTON("TON " + formatterTON.format(v / 1_000_000_000.), textView.getPaint(), .82f, false); + } else { + return "~" + BillingController.getInstance().formatCurrency((long) (v / k), "USD"); } - formatterTON.setMaximumFractionDigits(v > 1_000_000_000 ? 2 : 6); - return ChannelMonetizationLayout.replaceTON("TON " + formatterTON.format(v / 1_000_000_000.), textView.getPaint(), false); } float num_ = v; int count = 0; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LineViewData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LineViewData.java index 0d1f7256a..19ad59401 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LineViewData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/LineViewData.java @@ -37,11 +37,11 @@ public class LineViewData { private Theme.ResourcesProvider resourcesProvider; - public LineViewData(ChartData.Line line) { - this(line, null); + public LineViewData(ChartData.Line line, boolean bar) { + this(line, bar, null); } - public LineViewData(ChartData.Line line, Theme.ResourcesProvider resourcesProvider) { + public LineViewData(ChartData.Line line, boolean bar, Theme.ResourcesProvider resourcesProvider) { this.resourcesProvider = resourcesProvider; this.line = line; @@ -62,8 +62,8 @@ public class LineViewData { selectionPaint.setColor(line.color); - linesPath = new float[line.y.length << 2]; - linesPathBottom = new float[line.y.length << 2]; + linesPath = new float[bar ? (8 * line.y.length) : line.y.length << 2]; + linesPathBottom = new float[bar ? (8 * line.y.length) : line.y.length << 2]; } public void updateColors() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackBarViewData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackBarViewData.java index 9ca28a2c4..2f8a70c3a 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackBarViewData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackBarViewData.java @@ -25,7 +25,7 @@ public class StackBarViewData extends LineViewData { } public StackBarViewData(ChartData.Line line, Theme.ResourcesProvider resourcesProvider) { - super(line); + super(line, false); this.resourcesProvider = resourcesProvider; paint.setStrokeWidth(AndroidUtilities.dpf2(1)); paint.setStyle(Paint.Style.STROKE); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackLinearViewData.java b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackLinearViewData.java index e29192184..bb56bb538 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackLinearViewData.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Charts/view_data/StackLinearViewData.java @@ -8,7 +8,7 @@ import org.telegram.ui.Charts.data.ChartData; public class StackLinearViewData extends LineViewData { public StackLinearViewData(ChartData.Line line) { - super(line); + super(line, false); paint.setStyle(Paint.Style.FILL); if (BaseChartView.USE_LINES) { paint.setAntiAlias(false); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 23bbf7b13..b1fea30d8 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -7974,7 +7974,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not if (child instanceof ChatMessageCell) { ChatMessageCell messageCell = ((ChatMessageCell) child); MessageObject msg = messageCell.getPrimaryMessageObject(); - if (msg.messageOwner != null && msg.messageOwner.via_business_bot_id != 0) { + if (msg != null && msg.messageOwner != null && msg.messageOwner.via_business_bot_id != 0) { cell = messageCell; } } @@ -27952,7 +27952,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not popupLayout.addView(rateTranscriptionLayout, rateTranscriptionLayoutParams); } - if (selectedObject != null && selectedObject.isSponsored() && !selectedObject.sponsoredCanReport) { + if (selectedObject != null && selectedObject.isSponsored()) { if (selectedObject.sponsoredInfo != null || selectedObject.sponsoredAdditionalInfo != null || selectedObject.sponsoredWebPage != null) { LinearLayout linearLayout = new LinearLayout(getParentActivity()); linearLayout.setOrientation(LinearLayout.VERTICAL); @@ -28043,7 +28043,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not final int foregroundIndex = popupLayout.addViewToSwipeBack(linearLayout); ActionBarMenuSubItem cell = new ActionBarMenuSubItem(getParentActivity(), true, true, themeDelegate); - cell.setTextAndIcon(LocaleController.getString("SponsoredMessageSponsor", R.string.SponsoredMessageSponsor), R.drawable.msg_channel); + cell.setTextAndIcon(LocaleController.getString(selectedObject.sponsoredCanReport ? R.string.SponsoredMessageSponsorReportable : R.string.SponsoredMessageSponsor), R.drawable.msg_channel); popupLayout.addView(cell); cell.setOnClickListener(v1 -> { if (contentView == null || getParentActivity() == null) { @@ -28053,57 +28053,58 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not }); popupLayout.addView(new ActionBarPopupWindow.GapView(contentView.getContext(), themeDelegate), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8)); } - - FrameLayout sponsoredAbout = new FrameLayout(getParentActivity()) { - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - }; - sponsoredAbout.setMinimumHeight(AndroidUtilities.dp(56)); - sponsoredAbout.setBackground(Theme.createRadSelectorDrawable(getThemedColor(Theme.key_dialogButtonSelector), popupLayout.getItemsCount() <= 0 ? 6 : 0, 0)); - sponsoredAbout.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); - - ImageView infoImage = new ImageView(getParentActivity()); - infoImage.setScaleType(ImageView.ScaleType.CENTER); - infoImage.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon), PorterDuff.Mode.MULTIPLY)); - infoImage.setImageResource(R.drawable.msg_info); - sponsoredAbout.addView(infoImage, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 40, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT))); - - TextView infoText = new TextView(getParentActivity()) { - @Override - protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST && getLayout() != null) { - Layout layout = getLayout(); - int width = 0; - for (int i = 0; i < layout.getLineCount(); ++i) { - width = Math.max(width, (int) Math.ceil(layout.getLineWidth(i))); - } - widthMeasureSpec = MeasureSpec.makeMeasureSpec(getPaddingLeft() + width + getPaddingRight(), MeasureSpec.EXACTLY); + if (!selectedObject.sponsoredCanReport) { + FrameLayout sponsoredAbout = new FrameLayout(getParentActivity()) { + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + super.onMeasure(widthMeasureSpec, heightMeasureSpec); } - super.onMeasure(widthMeasureSpec, heightMeasureSpec); - } - }; - infoText.setMaxLines(3); - infoText.setGravity(Gravity.LEFT); - infoText.setEllipsize(TextUtils.TruncateAt.END); - infoText.setTextColor(getThemedColor(Theme.key_actionBarDefaultSubmenuItem)); - infoText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - infoText.setMaxWidth(AndroidUtilities.dp(240)); - infoText.setText(LocaleController.getString("SponsoredMessageInfo", R.string.SponsoredMessageInfo)); - infoText.setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(43), 0, LocaleController.isRTL ? AndroidUtilities.dp(43) : 0, 0); - sponsoredAbout.addView(infoText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL)); + }; + sponsoredAbout.setMinimumHeight(AndroidUtilities.dp(56)); + sponsoredAbout.setBackground(Theme.createRadSelectorDrawable(getThemedColor(Theme.key_dialogButtonSelector), popupLayout.getItemsCount() <= 0 ? 6 : 0, 0)); + sponsoredAbout.setPadding(AndroidUtilities.dp(18), 0, AndroidUtilities.dp(18), 0); - popupLayout.addView(sponsoredAbout); - sponsoredAbout.setOnClickListener(v1 -> { - if (contentView == null || getParentActivity() == null) { - return; - } - BottomSheet.Builder builder = new BottomSheet.Builder(contentView.getContext()); - builder.setCustomView(new SponsoredMessageInfoView(getParentActivity(), themeDelegate)); - builder.show(); - }); - popupLayout.addView(new ActionBarPopupWindow.GapView(contentView.getContext(), themeDelegate), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8)); + ImageView infoImage = new ImageView(getParentActivity()); + infoImage.setScaleType(ImageView.ScaleType.CENTER); + infoImage.setColorFilter(new PorterDuffColorFilter(getThemedColor(Theme.key_actionBarDefaultSubmenuItemIcon), PorterDuff.Mode.MULTIPLY)); + infoImage.setImageResource(R.drawable.msg_info); + sponsoredAbout.addView(infoImage, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 40, Gravity.CENTER_VERTICAL | (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT))); + + TextView infoText = new TextView(getParentActivity()) { + @Override + protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { + if (MeasureSpec.getMode(widthMeasureSpec) == MeasureSpec.AT_MOST && getLayout() != null) { + Layout layout = getLayout(); + int width = 0; + for (int i = 0; i < layout.getLineCount(); ++i) { + width = Math.max(width, (int) Math.ceil(layout.getLineWidth(i))); + } + widthMeasureSpec = MeasureSpec.makeMeasureSpec(getPaddingLeft() + width + getPaddingRight(), MeasureSpec.EXACTLY); + } + super.onMeasure(widthMeasureSpec, heightMeasureSpec); + } + }; + infoText.setMaxLines(3); + infoText.setGravity(Gravity.LEFT); + infoText.setEllipsize(TextUtils.TruncateAt.END); + infoText.setTextColor(getThemedColor(Theme.key_actionBarDefaultSubmenuItem)); + infoText.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); + infoText.setMaxWidth(AndroidUtilities.dp(240)); + infoText.setText(LocaleController.getString("SponsoredMessageInfo", R.string.SponsoredMessageInfo)); + infoText.setPadding(LocaleController.isRTL ? 0 : AndroidUtilities.dp(43), 0, LocaleController.isRTL ? AndroidUtilities.dp(43) : 0, 0); + sponsoredAbout.addView(infoText, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL)); + + popupLayout.addView(sponsoredAbout); + sponsoredAbout.setOnClickListener(v1 -> { + if (contentView == null || getParentActivity() == null) { + return; + } + BottomSheet.Builder builder = new BottomSheet.Builder(contentView.getContext()); + builder.setCustomView(new SponsoredMessageInfoView(getParentActivity(), themeDelegate)); + builder.show(); + }); + popupLayout.addView(new ActionBarPopupWindow.GapView(contentView.getContext(), themeDelegate), LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 8)); + } } scrimPopupWindowItems = new ActionBarMenuSubItem[items.size()]; for (int a = 0, N = items.size(); a < N; a++) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java index 67dd85879..df1779e65 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/AlertsCreator.java @@ -2530,6 +2530,7 @@ public class AlertsCreator { if (users.isEmpty()) return; AndroidUtilities.runOnUIThread(() -> { + if (!LaunchActivity.isActive) return; BaseFragment lastFragment = LaunchActivity.getLastFragment(); if (lastFragment != null && lastFragment.getParentActivity() != null) { LimitReachedBottomSheet restrictedUsersBottomSheet = new LimitReachedBottomSheet(lastFragment, lastFragment.getParentActivity(), LimitReachedBottomSheet.TYPE_ADD_MEMBERS_RESTRICTED, currentAccount, null); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java index 4b8a593e6..6a78edd34 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatActivityEnterView.java @@ -3705,6 +3705,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific } new File(audioToSendPath).delete(); } + MediaController.getInstance().cleanRecording(true); MediaDataController.getInstance(currentAccount).pushDraftVoiceMessage(dialog_id, parentFragment != null && parentFragment.isTopic ? parentFragment.getTopicId() : 0, null); MediaController.getInstance().stopRecording(0, false, 0, false); millisecondsRecorded = 0; @@ -6432,6 +6433,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific if (playing != null && playing == audioToSendMessageObject) { MediaController.getInstance().cleanupPlayer(true, true); } + MediaController.getInstance().cleanRecording(false); MediaDataController.getInstance(currentAccount).pushDraftVoiceMessage(dialog_id, parentFragment != null && parentFragment.isTopic ? parentFragment.getTopicId() : 0, null); SendMessagesHelper.SendMessageParams params = SendMessagesHelper.SendMessageParams.of(audioToSend, null, audioToSendPath, dialog_id, replyingMessageObject, getThreadMessage(), null, null, null, null, notify, scheduleDate, voiceOnce ? 0x7FFFFFFF : 0, null, null, false); params.quick_reply_shortcut = parentFragment != null ? parentFragment.quickReplyShortcut : null; @@ -9064,7 +9066,7 @@ public class ChatActivityEnterView extends BlurredFrameLayout implements Notific controlsView.periodDrawable.setValue(1, voiceOnce, true); } TL_stories.StoryItem storyItem = delegate != null ? delegate.getReplyToStory() : null; - MediaController.getInstance().prepareResumedRecording(currentAccount, draft, dialog_id, replyingMessageObject, getThreadMessage(), storyItem, recordingGuid, true, parentFragment != null ? parentFragment.quickReplyShortcut : null, parentFragment != null ? parentFragment.getQuickReplyId() : 0); + MediaController.getInstance().prepareResumedRecording(currentAccount, draft, dialog_id, replyingMessageObject, getThreadMessage(), storyItem, recordingGuid, parentFragment != null ? parentFragment.quickReplyShortcut : null, parentFragment != null ? parentFragment.getQuickReplyId() : 0); } public void setSelection(int start) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ColoredImageSpan.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ColoredImageSpan.java index 76de2543f..e8fbf67d6 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ColoredImageSpan.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ColoredImageSpan.java @@ -60,6 +60,19 @@ public class ColoredImageSpan extends ReplacementSpan { this.verticalAlignment = verticalAlignment; } + private boolean isRelativeSize; + private Paint.FontMetricsInt fontMetrics; + public void setRelativeSize(Paint.FontMetricsInt fontMetricsInt) { + this.isRelativeSize = true; + this.fontMetrics = fontMetricsInt; + if (fontMetrics != null) { + setSize(Math.abs(fontMetrics.descent) + Math.abs(fontMetrics.ascent)); + if (size == 0) { + setSize(AndroidUtilities.dp(20)); + } + } + } + public void setSize(int size) { this.size = size; drawable.setBounds(0, 0, size, size); @@ -83,7 +96,20 @@ public class ColoredImageSpan extends ReplacementSpan { } @Override - public int getSize(@NonNull Paint paint, CharSequence charSequence, int i, int i1, @Nullable Paint.FontMetricsInt fontMetricsInt) { + public int getSize(@NonNull Paint paint, CharSequence charSequence, int i, int i1, @Nullable Paint.FontMetricsInt fm) { + if (isRelativeSize && fontMetrics != null) { + if (fm == null) { + fm = new Paint.FontMetricsInt(); + } + if (fm != null) { + fm.ascent = fontMetrics.ascent; + fm.descent = fontMetrics.descent; + + fm.top = fontMetrics.top; + fm.bottom = fontMetrics.bottom; + } + return (int) (scaleX * Math.abs(spaceScaleX) * size); + } if (sizeWidth != 0) return (int) (Math.abs(scaleX) * sizeWidth); return (int) (Math.abs(scaleX) * Math.abs(spaceScaleX) * (size != 0 ? size : drawable.getIntrinsicWidth())); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCreateSpan.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCreateSpan.java index 1807aaa95..607433a92 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCreateSpan.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/GroupCreateSpan.java @@ -149,7 +149,7 @@ public class GroupCreateSpan extends View { case "premium": isFlag = true; avatarDrawable.setColor(Theme.getColor(Theme.key_premiumGradientBackground2, resourcesProvider)); - firstName = "Premium Users"; + firstName = LocaleController.getString(R.string.PrivacyPremium); break; case "archived": default: diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkSpanDrawable.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkSpanDrawable.java index b56b3951a..a474b0407 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkSpanDrawable.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/LinkSpanDrawable.java @@ -26,6 +26,7 @@ import android.widget.TextView; import androidx.core.graphics.ColorUtils; import org.telegram.messenger.AndroidUtilities; +import org.telegram.messenger.FileLog; import org.telegram.messenger.LiteMode; import org.telegram.messenger.SharedConfig; import org.telegram.ui.ActionBar.SimpleTextView; @@ -498,7 +499,7 @@ public class LinkSpanDrawable { } private boolean isCustomLinkCollector; - private LinkCollector links; + private final LinkCollector links; private Theme.ResourcesProvider resourcesProvider; AnimatedEmojiSpan.EmojiGroupedSpans stack; @@ -646,6 +647,8 @@ public class LinkSpanDrawable { return pressedLink != null || super.onTouchEvent(event); } + private boolean loggedError = false; + @Override protected void onDraw(Canvas canvas) { if (!isCustomLinkCollector) { @@ -653,21 +656,29 @@ public class LinkSpanDrawable { if (!disablePaddingsOffset) { canvas.translate(disablePaddingsOffsetX ? 0 : getPaddingLeft(), disablePaddingsOffsetY ? 0 : getPaddingTop()); } - if (links.draw(canvas)) { + if (links != null && links.draw(canvas)) { invalidate(); } canvas.restore(); } - super.onDraw(canvas); - float offset = (getGravity() & Gravity.CENTER_VERTICAL) != 0 && getLayout() != null ? getPaddingTop() + (getHeight() - getPaddingTop() - getPaddingBottom() - getLayout().getHeight()) / 2f : 0; - if (offset != 0 || getPaddingLeft() != 0) { - canvas.save(); - canvas.translate(getPaddingLeft(), offset); + boolean restore = false; + try { + Layout layout = getLayout(); + float offset = (getGravity() & Gravity.CENTER_VERTICAL) != 0 && layout != null ? getPaddingTop() + (getHeight() - getPaddingTop() - getPaddingBottom() - layout.getHeight()) / 2f : 0; + if (offset != 0 || getPaddingLeft() != 0) { + canvas.save(); + restore = true; + canvas.translate(getPaddingLeft(), offset); + } + AnimatedEmojiSpan.drawAnimatedEmojis(canvas, layout, stack, 0, null, 0, 0, 0, 1f); + } catch (Exception e) { + if (!loggedError) FileLog.e(e, true); + loggedError = true; } - AnimatedEmojiSpan.drawAnimatedEmojis(canvas, getLayout(), stack, 0, null, 0, 0, 0, 1f); - if (offset != 0 || getPaddingLeft() != 0) { + if (restore) { canvas.restore(); } + super.onDraw(canvas); } @Override diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/LPhotoPaintView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/LPhotoPaintView.java index ca9b96be0..4f80d8799 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/LPhotoPaintView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/LPhotoPaintView.java @@ -2032,7 +2032,7 @@ public class LPhotoPaintView extends SizeNotifierFrameLayoutPhoto implements IPh return; } - if (editingText) { + if (editingText && currentEntityView != null) { selectEntity(null); return; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java index 0427b0d7b..259951f5b 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Paint/Views/StickerMakerView.java @@ -16,13 +16,11 @@ import android.graphics.Matrix; import android.graphics.Paint; import android.graphics.Path; import android.graphics.PathMeasure; -import android.graphics.PointF; import android.graphics.PorterDuff; import android.graphics.PorterDuffXfermode; import android.graphics.Rect; import android.graphics.RectF; import android.os.Build; -import android.util.Log; import android.util.TypedValue; import android.view.Gravity; import android.view.MotionEvent; @@ -33,7 +31,6 @@ import android.widget.FrameLayout; import android.widget.TextView; import androidx.annotation.Nullable; -import androidx.core.graphics.ColorUtils; import com.google.mlkit.common.MlKitException; import com.google.mlkit.vision.common.InputImage; @@ -806,7 +803,9 @@ public class StickerMakerView extends FrameLayout implements NotificationCenter. sourceBitmap = null; if (objects != null) { for (int i = 0; i < objects.length; ++i) { - objects[i].recycle(); + if (objects[i] != null) { + objects[i].recycle(); + } } objects = null; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java index caa5e0c36..1c87da57d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Reactions/ReactionsLayoutInBubble.java @@ -1264,6 +1264,17 @@ public class ReactionsLayoutInBubble { return false; } + public VisibleReaction flatten() { + if (documentId != 0) { + TLRPC.Document document = AnimatedEmojiDrawable.findDocument(UserConfig.selectedAccount, documentId); + String emoji = MessageObject.findAnimatedEmojiEmoticon(document, null); + if (emoji != null) { + return VisibleReaction.fromEmojicon(emoji); + } + } + return this; + } + @NonNull @Override public String toString() { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java index 4de885e58..71cd9ed33 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ReactionsContainerLayout.java @@ -174,6 +174,7 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio RectF rectF = new RectF(); HashSet selectedReactions = new HashSet<>(); + HashSet alwaysSelectedReactions = new HashSet<>(); private int[] location = new int[2]; @@ -1250,12 +1251,20 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio selectedReactions.clear(); selectedReactions.addAll(getInclusiveReactions(messages)); updateSelected(); + if (type == TYPE_STICKER_SET_EMOJI) { + alwaysSelectedReactions.addAll(selectedReactions); + setMessage(messageObject, null); + } } public void setSelectedReactionInclusive(ReactionsLayoutInBubble.VisibleReaction visibleReaction) { selectedReactions.clear(); selectedReactions.add(visibleReaction); updateSelected(); + if (type == TYPE_STICKER_SET_EMOJI) { + alwaysSelectedReactions.addAll(selectedReactions); + setMessage(messageObject, null); + } } private void updateSelected() { @@ -1280,11 +1289,20 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio } private void fillRecentReactionsList(List visibleReactions) { + HashSet hashSet = new HashSet<>(); + int added = 0; + if (type == TYPE_STICKER_SET_EMOJI) { + for (ReactionsLayoutInBubble.VisibleReaction visibleReaction : alwaysSelectedReactions) { + if (!hashSet.contains(visibleReaction)) { + hashSet.add(visibleReaction); + visibleReactions.add(visibleReaction); + added++; + } + } + } if (!allReactionsAvailable || type == TYPE_STICKER_SET_EMOJI) { if (type == TYPE_TAGS) { ArrayList topReactions = MediaDataController.getInstance(currentAccount).getSavedReactions(); - HashSet hashSet = new HashSet<>(); - int added = 0; for (int i = 0; i < topReactions.size(); i++) { ReactionsLayoutInBubble.VisibleReaction visibleReaction = ReactionsLayoutInBubble.VisibleReaction.fromTLReaction(topReactions.get(i)); if (!hashSet.contains(visibleReaction)) { @@ -1313,8 +1331,6 @@ public class ReactionsContainerLayout extends FrameLayout implements Notificatio } else { topReactions = MediaDataController.getInstance(currentAccount).getTopReactions(); } - HashSet hashSet = new HashSet<>(); - int added = 0; if (type == TYPE_TAGS) { TLRPC.TL_messages_savedReactionsTags savedTags = MessagesController.getInstance(currentAccount).getSavedReactionTags(0); if (savedTags != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java index 1506d2c9a..09c99a7bb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/SharedMediaLayout.java @@ -1618,7 +1618,7 @@ public class SharedMediaLayout extends FrameLayout implements NotificationCenter } searchItem.setVisibility(View.GONE); searchWas = text.length() != 0 || searchingReaction != null; - switchToCurrentSelectedMode(false); + post(() -> switchToCurrentSelectedMode(false)); if (mediaPages[0].selectedType == TAB_FILES) { if (documentsSearchAdapter == null) { return; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java index 08b097fd3..f06e75624 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/StickersAlert.java @@ -1099,7 +1099,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not private void checkOptions() { final MediaDataController mediaDataController = MediaDataController.getInstance(currentAccount); - boolean notInstalled = !mediaDataController.isStickerPackInstalled(stickerSet.set.id); + boolean notInstalled = stickerSet == null || !mediaDataController.isStickerPackInstalled(stickerSet.set.id); if (stickerSet != null && stickerSet.set != null && stickerSet.set.creator && deleteItem == null && !DISABLE_STICKER_EDITOR) { optionsButton.addSubItem(3, R.drawable.tabs_reorder, LocaleController.getString(R.string.StickersReorder)); optionsButton.addSubItem(4, R.drawable.msg_edit, LocaleController.getString(R.string.EditName)); @@ -2156,6 +2156,7 @@ public class StickersAlert extends BottomSheet implements NotificationCenter.Not } else { if (holder.getItemViewType() != TYPE_ADD_STICKER) { StickerEmojiCell cell = (StickerEmojiCell) holder.itemView; + if (stickerSet == null) return; cell.setSticker(stickerSet.documents.get(position), null, stickerSet, null, showEmoji, isEditModeEnabled); cell.editModeIcon.setOnClickListener(v -> { ContentPreviewViewer.getInstance().showMenuFor(cell); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java index d0a79e28b..980b286fe 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UItem.java @@ -257,7 +257,7 @@ public class UItem extends AdapterWithDiffUtils.Item { } public static UItem asChart(int type, int stats_dc, StatisticActivity.ChartViewData data) { - UItem item = new UItem(UniversalAdapter.VIEW_TYPE_CHART0 + type, false); + UItem item = new UItem(UniversalAdapter.VIEW_TYPE_CHART_LINEAR + type, false); item.intValue = stats_dc; item.object = data; return item; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/UniversalAdapter.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/UniversalAdapter.java index ce98d4d6d..935ef7477 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UniversalAdapter.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UniversalAdapter.java @@ -64,21 +64,23 @@ public class UniversalAdapter extends AdapterWithDiffUtils { public static final int VIEW_TYPE_QUICK_REPLY = 16; public static final int VIEW_TYPE_LARGE_QUICK_REPLY = 17; - public static final int VIEW_TYPE_CHART0 = 18; - public static final int VIEW_TYPE_CHART1 = 19; - public static final int VIEW_TYPE_CHART2 = 20; - public static final int VIEW_TYPE_CHART3 = 21; + public static final int VIEW_TYPE_CHART_LINEAR = 18; + public static final int VIEW_TYPE_CHART_DOUBLE_LINEAR = 19; + public static final int VIEW_TYPE_CHART_STACK_BAR = 20; + public static final int VIEW_TYPE_CHART_BAR = 21; + public static final int VIEW_TYPE_CHART_STACK_LINEAR = 22; + public static final int VIEW_TYPE_CHART_LINEAR_BAR = 23; - public static final int VIEW_TYPE_PROCEED_OVERVIEW = 22; - public static final int VIEW_TYPE_TRANSACTION = 23; + public static final int VIEW_TYPE_PROCEED_OVERVIEW = 24; + public static final int VIEW_TYPE_TRANSACTION = 25; - public static final int VIEW_TYPE_LARGE_HEADER = 24; - public static final int VIEW_TYPE_RADIO_USER = 25; - public static final int VIEW_TYPE_SPACE = 26; + public static final int VIEW_TYPE_LARGE_HEADER = 26; + public static final int VIEW_TYPE_RADIO_USER = 27; + public static final int VIEW_TYPE_SPACE = 28; - public static final int VIEW_TYPE_BUSINESS_LINK = 27; + public static final int VIEW_TYPE_BUSINESS_LINK = 29; - public static final int VIEW_TYPE_RIGHT_ICON_TEXT = 28; + public static final int VIEW_TYPE_RIGHT_ICON_TEXT = 30; private final RecyclerListView listView; private final Context context; @@ -319,14 +321,16 @@ public class UniversalAdapter extends AdapterWithDiffUtils { view = new QuickRepliesActivity.LargeQuickReplyView(context, resourcesProvider); view.setBackgroundColor(getThemedColor(Theme.key_windowBackgroundWhite)); break; - case VIEW_TYPE_CHART0: - case VIEW_TYPE_CHART1: - case VIEW_TYPE_CHART2: - case VIEW_TYPE_CHART3: + case VIEW_TYPE_CHART_LINEAR: + case VIEW_TYPE_CHART_DOUBLE_LINEAR: + case VIEW_TYPE_CHART_STACK_BAR: + case VIEW_TYPE_CHART_BAR: + case VIEW_TYPE_CHART_STACK_LINEAR: + case VIEW_TYPE_CHART_LINEAR_BAR: if (chartSharedUI == null) { chartSharedUI = new BaseChartView.SharedUiComponents(); } - view = new StatisticActivity.UniversalChartCell(context, currentAccount, viewType - VIEW_TYPE_CHART0, chartSharedUI, classGuid); + view = new StatisticActivity.UniversalChartCell(context, currentAccount, viewType - VIEW_TYPE_CHART_LINEAR, chartSharedUI, classGuid); view.setBackgroundColor(getThemedColor(Theme.key_windowBackgroundWhite)); break; case VIEW_TYPE_TRANSACTION: @@ -554,10 +558,12 @@ public class UniversalAdapter extends AdapterWithDiffUtils { replyView2.set((QuickRepliesController.QuickReply) item.object, divider); } break; - case VIEW_TYPE_CHART0: - case VIEW_TYPE_CHART1: - case VIEW_TYPE_CHART2: - case VIEW_TYPE_CHART3: + case VIEW_TYPE_CHART_LINEAR: + case VIEW_TYPE_CHART_DOUBLE_LINEAR: + case VIEW_TYPE_CHART_STACK_BAR: + case VIEW_TYPE_CHART_BAR: + case VIEW_TYPE_CHART_STACK_LINEAR: + case VIEW_TYPE_CHART_LINEAR_BAR: ((StatisticActivity.UniversalChartCell) holder.itemView).set( item.intValue, (StatisticActivity.ChartViewData) item.object, diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java index d0cf93ebe..31cd9a684 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java @@ -12304,13 +12304,15 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter. fragmentView.requestLayout(); } } else { - for (int i = 0; i < viewPages.length; i++) { - ViewPage page = viewPages[i]; - if (page != null) { - page.setLayerType(View.LAYER_TYPE_NONE, null); - page.setClipChildren(true); - page.setClipToPadding(true); - page.listView.setClipChildren(true); + if (viewPages != null) { + for (int i = 0; i < viewPages.length; i++) { + ViewPage page = viewPages[i]; + if (page != null) { + page.setLayerType(View.LAYER_TYPE_NONE, null); + page.setClipChildren(true); + page.setClipToPadding(true); + page.listView.setClipChildren(true); + } } } if (actionBar != null) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java index cbd4b651c..89f4189c0 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java @@ -213,6 +213,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati public final static String EXTRA_FORCE_NOT_INTERNAL_APPS = "force_not_internal_apps"; public final static Pattern PREFIX_T_ME_PATTERN = Pattern.compile("^(?:http(?:s|)://|)([A-z0-9-]+?)\\.t\\.me"); + public static boolean isActive; public static boolean isResumed; public static Runnable onResumeStaticCallback; @@ -329,6 +330,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati @Override protected void onCreate(Bundle savedInstanceState) { + isActive = true; if (BuildVars.DEBUG_VERSION) { StrictMode.setVmPolicy(new StrictMode.VmPolicy.Builder(StrictMode.getVmPolicy()) .detectLeakedClosableObjects() @@ -4964,6 +4966,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati AtomicBoolean allowWrite = new AtomicBoolean(); BaseFragment lastFragment = mainFragmentsStack.get(mainFragmentsStack.size() - 1); Runnable loadBotSheet = () -> { + if (!isActive) return; 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); @@ -6007,6 +6010,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati @Override protected void onDestroy() { + isActive = false; if (PhotoViewer.getPipInstance() != null) { PhotoViewer.getPipInstance().destroyPhotoViewer(); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java index 1bd7692f3..59453aca1 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PhotoViewer.java @@ -6625,7 +6625,7 @@ public class PhotoViewer implements NotificationCenter.NotificationCenterDelegat return; } Runnable onEnd = () -> { - cropTransform.setViewTransform(previousHasTransform, previousCropPx, previousCropPy, previousCropRotation, previousCropOrientation, previousCropScale, 1.0f, 1.0f, previousCropPw, previousCropPh, 0, 0, previousCropMirrored); + cropTransform.setViewTransform(previousHasTransform, previousCropPx, previousCropPy, previousCropRotation, previousCropOrientation, previousCropScale, scale1(), scale1(), previousCropPw, previousCropPh, 0, 0, previousCropMirrored); // if (previousHasTransform) { // editState.cropState = new MediaController.CropState(); // editState.cropState.cropPx = previousCropPx; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PrivacyControlActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PrivacyControlActivity.java index d4aef8999..735ecd360 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/PrivacyControlActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/PrivacyControlActivity.java @@ -1587,7 +1587,7 @@ public class PrivacyControlActivity extends BaseFragment implements Notification } else if (rulesType == PRIVACY_RULES_TYPE_MESSAGES) { headerCell.setText(LocaleController.getString(R.string.PrivacyMessagesTitle)); } else if (rulesType == PRIVACY_RULES_TYPE_BIRTHDAY) { - headerCell.setText(LocaleController.getString(R.string.PrivacyBirthday)); + headerCell.setText(LocaleController.getString(R.string.PrivacyBirthdayTitle)); } else { headerCell.setText(LocaleController.getString("LastSeenTitle", R.string.LastSeenTitle)); } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java index ed5334647..1166dfc2f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ProfileActivity.java @@ -1856,6 +1856,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. getNotificationCenter().addObserver(this, NotificationCenter.reloadDialogPhotos); getNotificationCenter().addObserver(this, NotificationCenter.storiesUpdated); getNotificationCenter().addObserver(this, NotificationCenter.storiesReadUpdated); + getNotificationCenter().addObserver(this, NotificationCenter.userIsPremiumBlockedUpadted); NotificationCenter.getGlobalInstance().addObserver(this, NotificationCenter.emojiLoaded); updateRowsIds(); if (listAdapter != null) { @@ -1927,6 +1928,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. getNotificationCenter().removeObserver(this, NotificationCenter.reloadDialogPhotos); getNotificationCenter().removeObserver(this, NotificationCenter.storiesUpdated); getNotificationCenter().removeObserver(this, NotificationCenter.storiesReadUpdated); + getNotificationCenter().removeObserver(this, NotificationCenter.userIsPremiumBlockedUpadted); NotificationCenter.getGlobalInstance().removeObserver(this, NotificationCenter.emojiLoaded); if (avatarsViewPager != null) { avatarsViewPager.onDestroy(); @@ -7396,6 +7398,10 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. avatarImage.setHasStories(needInsetForStories()); updateAvatarRoundRadius(); } + } else if (id == NotificationCenter.userIsPremiumBlockedUpadted) { + if (otherItem != null) { + otherItem.setSubItemShown(start_secret_chat, !getMessagesController().isUserPremiumBlocked(userId)); + } } } @@ -8112,6 +8118,9 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. if (birthdayFetcher != null) { birthdayFetcher.subscribe(this::createBirthdayEffect); } + if (otherItem != null) { + otherItem.setSubItemShown(start_secret_chat, !getMessagesController().isUserPremiumBlocked(userId)); + } } public boolean canSearchMembers() { @@ -9408,6 +9417,7 @@ public class ProfileActivity extends BaseFragment implements NotificationCenter. otherItem.addSubItem(gift_premium, R.drawable.msg_gift_premium, LocaleController.getString(R.string.GiftPremium)); } otherItem.addSubItem(start_secret_chat, R.drawable.msg_secret, LocaleController.getString("StartEncryptedChat", R.string.StartEncryptedChat)); + otherItem.setSubItemShown(start_secret_chat, !getMessagesController().isUserPremiumBlocked(userId)); } if (!isBot && getContactsController().contactsDict.get(userId) != null) { otherItem.addSubItem(add_shortcut, R.drawable.msg_home, LocaleController.getString("AddShortcut", R.string.AddShortcut)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/RevenueSharingAdsInfoBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/RevenueSharingAdsInfoBottomSheet.java index 808f6d764..9b2479f8d 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/RevenueSharingAdsInfoBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/RevenueSharingAdsInfoBottomSheet.java @@ -106,8 +106,8 @@ public class RevenueSharingAdsInfoBottomSheet extends BottomSheet { textViewDescription4.setTextAlignment(TextView.TEXT_ALIGNMENT_CENTER); linearLayout.addView(textViewDescription4, LayoutHelper.createLinear(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL, 22, 0, 22, 0)); - SpannableStringBuilder bottomSubtitle1 = AndroidUtilities.replaceTags(LocaleController.getString("RevenueSharingAdsInfo4Subtitle", R.string.RevenueSharingAdsInfo4Subtitle)); - String bottomSubtitle2 = getString("RevenueSharingAdsInfo4Subtitle", R.string.RevenueSharingAdsInfo4SubtitleLearnMore); + SpannableStringBuilder bottomSubtitle1 = AndroidUtilities.replaceTags(LocaleController.getString(R.string.RevenueSharingAdsInfo4Subtitle2)); + String bottomSubtitle2 = getString(R.string.RevenueSharingAdsInfo4SubtitleLearnMore); SpannableStringBuilder stringBuilder2 = AndroidUtilities.replaceSingleTag(bottomSubtitle2, Theme.key_chat_messageLinkIn, 0, () -> Browser.openUrl(getContext(), LocaleController.getString("PromoteUrl", R.string.PromoteUrl))); SpannableString arrowStr = new SpannableString(">"); ColoredImageSpan span = new ColoredImageSpan(R.drawable.attach_arrow_right); @@ -133,7 +133,7 @@ public class RevenueSharingAdsInfoBottomSheet extends BottomSheet { buttonTextView.setTextColor(Theme.getColor(Theme.key_featuredStickers_buttonText)); buttonTextView.setTypeface(AndroidUtilities.getTypeface(AndroidUtilities.TYPEFACE_ROBOTO_MEDIUM)); buttonTextView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 14); - buttonTextView.setText(LocaleController.getString("RevenueSharingAdsAlertButton", R.string.RevenueSharingAdsUnderstood)); + buttonTextView.setText(LocaleController.getString("RevenueSharingAdsAlertButton", R.string.RevenueSharingAdsAlertButton)); buttonTextView.setBackground(Theme.AdaptiveRipple.filledRect(Theme.getColor(Theme.key_featuredStickers_addButton), 6)); buttonTextView.setOnClickListener(e -> dismiss()); linearLayout.addView(buttonTextView, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, 48, 0, 14, 22, 14, 14)); diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java index 0ee0d6819..b7ecf1c22 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java @@ -72,6 +72,7 @@ import org.telegram.ui.Cells.StatisticPostInfoCell; import org.telegram.ui.Charts.BarChartView; import org.telegram.ui.Charts.BaseChartView; import org.telegram.ui.Charts.DoubleLinearChartView; +import org.telegram.ui.Charts.LinearBarChartView; import org.telegram.ui.Charts.LinearChartView; import org.telegram.ui.Charts.PieChartView; import org.telegram.ui.Charts.StackBarChartView; @@ -924,7 +925,9 @@ public class StatisticActivity extends BaseFragment implements NotificationCente public static final int VIEW_TYPE_LINEAR = 0; public static final int VIEW_TYPE_DOUBLE_LINEAR = 1; public static final int VIEW_TYPE_STACKBAR = 2; + public static final int VIEW_TYPE_BAR = 3; public static final int VIEW_TYPE_STACKLINEAR = 4; + public static final int VIEW_TYPE_BAR_LINEAR = 5; class Adapter extends RecyclerListView.SelectionAdapter { @@ -1620,13 +1623,14 @@ public class StatisticActivity extends BaseFragment implements NotificationCente checkboxContainer = new FrameLayout(context) { @Override protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) { - super.onMeasure(widthMeasureSpec, heightMeasureSpec); + final int width = MeasureSpec.getSize(widthMeasureSpec); + super.onMeasure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.EXACTLY), heightMeasureSpec); int currentW = 0; int currentH = 0; int n = getChildCount(); int firstH = n > 0 ? getChildAt(0).getMeasuredHeight() : 0; for (int i = 0; i < n; i++) { - if (currentW + getChildAt(i).getMeasuredWidth() > getMeasuredWidth()) { + if (currentW + getChildAt(i).getMeasuredWidth() > width) { currentW = 0; currentH += getChildAt(i).getMeasuredHeight(); } @@ -1678,6 +1682,12 @@ public class StatisticActivity extends BaseFragment implements NotificationCente chartView.legendSignatureView.showPercentage = true; zoomedChartView = new PieChartView(getContext()); break; + case 5: + chartView = new LinearBarChartView(getContext()); + zoomedChartView = new LinearBarChartView(getContext()); + zoomedChartView.legendSignatureView.useHour = true; + break; + case 0: default: chartView = new LinearChartView(getContext()); zoomedChartView = new LinearChartView(getContext()); @@ -1719,7 +1729,7 @@ public class StatisticActivity extends BaseFragment implements NotificationCente linearLayout.addView(chartHeaderView, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, 52)); linearLayout.addView(frameLayout, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); - linearLayout.addView(checkboxContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.NO_GRAVITY, 16, 0, 16, 0)); + linearLayout.addView(checkboxContainer, LayoutHelper.createFrame(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT, Gravity.FILL_HORIZONTAL, 16, 0, 16, 0)); if (chartType == 4) { frameLayout.setClipChildren(false); @@ -1913,8 +1923,8 @@ public class StatisticActivity extends BaseFragment implements NotificationCente zoomedChartView.transitionParams = params; chartView.transitionParams = params; - int max = 0; - int min = Integer.MAX_VALUE; + long max = 0; + long min = Integer.MAX_VALUE; for (int i = 0; i < data.chartData.lines.size(); i++) { if (data.chartData.lines.get(i).y[dateIndex] > max) max = data.chartData.lines.get(i).y[dateIndex]; 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 68b075a0d..6b4c7ac13 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/PeerStoriesView.java @@ -5672,6 +5672,10 @@ public class PeerStoriesView extends SizeNotifierFrameLayout implements Notifica storyViewer.unreadStateChanged = true; } } + } else if (isActive && this.storyItem != null && storyViewer.storiesList != null) { + if (storyViewer.storiesList.markAsRead(this.storyItem.id)) { + storyViewer.unreadStateChanged = true; + } } } 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 13578ed88..502a9407f 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesController.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/StoriesController.java @@ -2376,6 +2376,7 @@ public class StoriesController { private final SortedSet cachedObjects = new TreeSet<>(Comparator.reverseOrder()); private final SortedSet loadedObjects = new TreeSet<>(Comparator.reverseOrder()); + public final HashSet seenStories = new HashSet<>(); private boolean showPhotos = true; private boolean showVideos = true; @@ -2471,6 +2472,7 @@ public class StoriesController { final MessagesStorage storage = MessagesStorage.getInstance(currentAccount); storage.getStorageQueue().postRunnable(() -> { SQLiteCursor cursor = null; + HashSet seen = new HashSet<>(); HashSet loadUserIds = new HashSet<>(); HashSet loadChatIds = new HashSet<>(); ArrayList cacheResult = new ArrayList<>(); @@ -2478,7 +2480,7 @@ public class StoriesController { final ArrayList loadedChats = new ArrayList<>(); try { SQLiteDatabase database = storage.getDatabase(); - cursor = database.queryFinalized(String.format(Locale.US, "SELECT data FROM profile_stories WHERE dialog_id = %d AND type = %d ORDER BY story_id DESC", dialogId, type)); + cursor = database.queryFinalized(String.format(Locale.US, "SELECT data, seen FROM profile_stories WHERE dialog_id = %d AND type = %d ORDER BY story_id DESC", dialogId, type)); while (cursor.next()) { NativeByteBuffer data = cursor.byteBufferValue(0); if (data != null) { @@ -2518,6 +2520,10 @@ public class StoriesController { msg.generateThumbs(false); cacheResult.add(msg); data.reuse(); + + if (cursor.intValue(1) == 1) { + seen.add(storyItem.id); + } } } cursor.dispose(); @@ -2549,6 +2555,7 @@ public class StoriesController { return; } + seenStories.addAll(seen); cachedObjects.clear(); for (int i = 0; i < cacheResult.size(); ++i) { pushObject(cacheResult.get(i), true); @@ -2672,7 +2679,7 @@ public class StoriesController { try { SQLiteDatabase database = storage.getDatabase(); database.executeFast(String.format(Locale.US, "DELETE FROM profile_stories WHERE dialog_id = %d AND type = %d", dialogId, type)).stepThis().dispose(); - state = database.executeFast("REPLACE INTO profile_stories VALUES(?, ?, ?, ?)"); + state = database.executeFast("REPLACE INTO profile_stories VALUES(?, ?, ?, ?, ?)"); for (int i = 0; i < toSave.size(); ++i) { MessageObject messageObject = toSave.get(i); @@ -2689,6 +2696,7 @@ public class StoriesController { state.bindInteger(2, storyItem.id); state.bindByteBuffer(3, data); state.bindInteger(4, type); + state.bindInteger(5, seenStories.contains(storyItem.id) ? 1 : 0); state.step(); data.reuse(); } @@ -2707,6 +2715,18 @@ public class StoriesController { }); } + public boolean markAsRead(int storyId) { + if (seenStories.contains(storyId)) return false; + seenStories.add(storyId); + saveCache(); + TL_stories.TL_stories_incrementStoryViews req = new TL_stories.TL_stories_incrementStoryViews(); + req.peer = MessagesController.getInstance(currentAccount).getInputPeer(dialogId); + req.id.add(storyId); + ConnectionsManager.getInstance(currentAccount).sendRequest(req, (response, error) -> {}); + NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.storiesReadUpdated); + return true; + } + private boolean canLoad() { if (lastLoadTime == null) { return true; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java index 470beede1..bef5fd6e3 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/EmojiBottomSheet.java @@ -1602,6 +1602,14 @@ public class EmojiBottomSheet extends BottomSheet implements NotificationCenter. private Utilities.Callback onWidgetSelected; public EmojiBottomSheet whenWidgetSelected(Utilities.Callback listener) { this.onWidgetSelected = listener; + View[] pages = viewPager.getViewPages(); + for (int i = 0; i < pages.length; ++i) { + View view = pages[i]; + if (view instanceof Page) { + Page page = (Page) view; + page.adapter.update(); + } + } return this; } diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryEntry.java b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryEntry.java index f45b06892..18ee7b6cb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryEntry.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Stories/recorder/StoryEntry.java @@ -7,6 +7,7 @@ import android.graphics.Canvas; import android.graphics.LinearGradient; import android.graphics.Matrix; import android.graphics.Paint; +import android.graphics.Rect; import android.graphics.Shader; import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.Drawable; @@ -212,6 +213,9 @@ public class StoryEntry { if (drawable == null) { return; } + Rect rect = new Rect(drawable.getBounds()); + Drawable.Callback callback = drawable.getCallback(); + drawable.setCallback(null); if (drawable instanceof BitmapDrawable) { BitmapDrawable bd = (BitmapDrawable) drawable; int bw = bd.getBitmap().getWidth(); @@ -223,6 +227,8 @@ public class StoryEntry { drawable.setBounds(0, 0, w, h); drawable.draw(canvas); } + drawable.setBounds(rect); + drawable.setCallback(callback); } public Bitmap buildBitmap(float scale, Bitmap mainFileBitmap) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/bots/BotBiometry.java b/TMessagesProj/src/main/java/org/telegram/ui/bots/BotBiometry.java index c15c2e9ea..4b6e1c1cb 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/bots/BotBiometry.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/bots/BotBiometry.java @@ -15,8 +15,11 @@ import androidx.annotation.RequiresApi; import androidx.biometric.BiometricManager; import androidx.biometric.BiometricPrompt; import androidx.core.content.ContextCompat; +import androidx.fragment.app.Fragment; import androidx.fragment.app.FragmentActivity; import androidx.fragment.app.FragmentManager; +import androidx.lifecycle.Lifecycle; +import androidx.lifecycle.LifecycleRegistry; import org.json.JSONException; import org.json.JSONObject; diff --git a/TMessagesProj/src/main/res/drawable-hdpi/menu_feature_withdrawals.png b/TMessagesProj/src/main/res/drawable-hdpi/menu_feature_withdrawals.png index 5831602acfa4d9949c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Gxdl8<7LK5&FE1y+83%gWI%5M$C95 zH3kiQoqynuagGHp#a7HN6&G~Me46sLVVt+IA2H5|+m!T&8F!_|sDb~AamLW;;-+0O zyHr{b?WN$0j7W7VqMYjD+m$e=A#u~u;mV~mC&qcJAbmID8RyZjm`y4y=(5>AqL(;7 z*7$VyT{=`@yZ6vqe1(GloN;yK?INNpW|K+^LVvFZ<1!#83KLf2yQ;M0H_2Jol-b}a z{<9@GZ?=l{rMw`22wr2G^sSCRGi9@^dL26@I$#wFkLf3zXN_>2WUFH`ww>7an*B5} z<1r`d`uVGf8tgaB3gW6n_V?;Ug?Dd%#_A6BO?BVO{X*JHlE~Gv|=+ zSHTs`oX;S;OEc?3F}PFlr}Q9q&v#a*6>4#TVqElz)l(RNBR%97kw~ELCcO@}1)S;m zvmq!zPoVZG-#ls7Ev@}KCM-&A%Fx$=4&>AOhn0#c5{lHRGxLd4#I0rj2Zpb&ZxFYG R&&mJ*002ovPDHLkV1jI#|Dyl^ diff --git a/TMessagesProj/src/main/res/drawable-mdpi/menu_feature_withdrawals.png b/TMessagesProj/src/main/res/drawable-mdpi/menu_feature_withdrawals.png index eee393e9f390b447317fdfcae4b3798488aa9246..109cad9d6431c5136bdfe2be4859d96d95a4fb65 100644 GIT binary patch delta 596 zcmV-a0;~P%1$Nlk5lCBC#UrNJei(a0CCNWpe31fhw%{_ zZOQ!90<2ypVT6Qd;4{#n&x1UBPf&;Y2^6iyO+JESKvuY6%|VsmW<0JQuHNHj;7T4> zfRl~s4fHw59)JCH@l!GP0XTBj4n`eeb5fmv(>cn@3akQMjxVhE&5m(FGw9YJVXcX= z8!D$+yS0Qa>N_A!X`6P8lW+oj`(YC7gW!VTaa(>7^J6fsJo9QC%oM~l^QVd81IF5g zE{+azUt<~bUfe6{z8WG3uJIjqEO$suT%e0)Oa%Dt;D31Q`|!&^8+Za%KtG7h)md-E z<6zc+U0#7L#qbZncW`F0gnwvbYSC4ehB*K9GxONhB_cxv=WN0-+(l-xM^;-P{&ic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T*Kd8$~nz9el9)CBgYNOP)@2SSGJ|DahvSJeT zfY#hOHfcCgpOn^dQ*|Eys5hA`5}_f0H%?NLMA|E)IhSCQZn1yajBMNeNU+b4V(X4| z`sGLf8ccdWn>rI^bfT%vMPMqh3xK(?ODED@#L-TZ!fK!(e=HDW3`1y|{GSDu0lRkY zHU9khYk!Jl>q(Sm0W?+83))TcDc>WKF%8Ibg4CN%Gn01u7FKYQ5BX}(8!B|h30w;S zS}n0lO0X)EY{}-7(D7P(LHZzTG_6d7v@=YLky_2v`j(KlQlb5hS}PZ{;@Q@}=xS?% zXj}u4G_B8T!=(1;#QSu#p-brZKY1gD3zU_C{}lk4ana3RPQq#c0000 + + + + + + \ No newline at end of file diff --git a/TMessagesProj/src/main/res/values-night/styles.xml b/TMessagesProj/src/main/res/values-night/styles.xml index 0729d80ec..e5a85d925 100644 --- a/TMessagesProj/src/main/res/values-night/styles.xml +++ b/TMessagesProj/src/main/res/values-night/styles.xml @@ -11,7 +11,7 @@ - - - - - - -