diff --git a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java index 044478dfd..7d2fa88cd 100644 --- a/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java +++ b/TMessagesProj/src/main/java/org/telegram/tgnet/TLRPC.java @@ -46551,6 +46551,7 @@ public class TLRPC { public boolean isThreadMessage; //custom public String translatedMessage; //custom public boolean translated; // custom + public boolean hide; // custom public static Message TLdeserialize(AbstractSerializedData stream, int constructor, boolean exception) { Message result = null; diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java index 147ec4116..f00d87074 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java @@ -144,6 +144,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } boolean voiceTransitionInPorgress; + public void setVoiceTransitionInProgress(boolean b) { voiceTransitionInPorgress = b; invalidate(); @@ -778,9 +779,10 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate private SparseArray accessibilityVirtualViewBounds = new SparseArray<>(); private int currentFocusedVirtualView = -1; - private boolean isBlockedUserMessage() { - return MessagesController.getInstance(currentAccount).blockePeers.indexOfKey( - currentMessageObject.getFromChatId()) >= 0 && NekoConfig.ignoreBlocked; + private boolean needHideMessage() { + return currentMessageObject.messageOwner.hide || + MessagesController.getInstance(currentAccount).blockePeers.indexOfKey(currentMessageObject.getFromChatId()) >= 0 && + NekoConfig.ignoreBlocked; } public ChatMessageCell(Context context) { @@ -2295,7 +2297,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } public void updatePlayingMessageProgress() { - if (currentMessageObject == null) { + if (currentMessageObject == null || needHide) { return; } @@ -2413,7 +2415,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate invalidate(); } - if (currentMessageObject == null || currentMessageObject.textLayoutBlocks == null) { + if (currentMessageObject == null || currentMessageObject.textLayoutBlocks == null || needHide) { return; } position -= textY; @@ -2552,7 +2554,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } private void updateSecretTimeText(MessageObject messageObject) { - if (messageObject == null || !messageObject.needDrawBluredPreview()) { + if (messageObject == null || !messageObject.needDrawBluredPreview() || needHide) { return; } String str = messageObject.getSecretTimeString(); @@ -2975,7 +2977,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate drawVideoSize = false; canStreamVideo = false; animatingNoSound = 0; - drawSideButton = !isRepliesChat && checkNeedDrawShareButton(messageObject) && (currentPosition == null || currentPosition.last) ? 1 : 0; + drawSideButton = !isRepliesChat && checkNeedDrawShareButton(messageObject) && (currentPosition == null || currentPosition.last) && totalHeight != 0 ? 1 : 0; if (isPinnedChat || drawSideButton == 1 && messageObject.messageOwner.fwd_from != null && !messageObject.isOutOwner() && messageObject.messageOwner.fwd_from.saved_from_peer != null && messageObject.getDialogId() == UserConfig.getInstance(currentAccount).getClientUserId()) { drawSideButton = 2; } @@ -3970,7 +3972,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate currentPhotoFilterThumb = String.format(Locale.US, "%d_%d_b", w, h); if (webDocument != null) { - /*TODO*/photoImage.setImage(ImageLocation.getForWebFile(webDocument), currentPhotoFilter, null, null, webDocument.size, null, messageObject, 1); + /*TODO*/ + photoImage.setImage(ImageLocation.getForWebFile(webDocument), currentPhotoFilter, null, null, webDocument.size, null, messageObject, 1); } else { if (documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER) { if (messageObject.mediaExists) { @@ -4003,13 +4006,16 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate photoImage.setAllowDecodeSingleFrame(true); photoImage.setAllowStartAnimation(true); photoImage.startAnimation(); - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(documentAttach), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, documentAttach.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(documentAttach), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, documentAttach.size, null, messageObject, 0); autoPlayingMedia = true; } else { if (currentPhotoObjectThumb != null) { - /*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); } else { - /*TODO*/photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoObject instanceof TLRPC.TL_photoStrippedSize || "s".equals(currentPhotoObject.type) ? currentPhotoFilterThumb : currentPhotoFilter, 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoObject instanceof TLRPC.TL_photoStrippedSize || "s".equals(currentPhotoObject.type) ? currentPhotoFilterThumb : currentPhotoFilter, 0, null, messageObject, 0); } } } else if (documentAttachType == DOCUMENT_ATTACH_TYPE_GIF || documentAttachType == DOCUMENT_ATTACH_TYPE_ROUND) { @@ -4027,23 +4033,28 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate autoPlayingMedia = true; TLRPC.VideoSize videoSize = MessageObject.getDocumentVideoThumb(document); if (!messageObject.mediaExists && videoSize != null && (currentPhotoObject == null || currentPhotoObjectThumb == null)) { - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? filter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? filter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0); } else { - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, document.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), document.size < 1024 * 32 ? null : ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, ImageLocation.getForDocument(currentPhotoObjectThumb, documentAttach), currentPhotoFilterThumb, null, document.size, null, messageObject, 0); } } else { - /*TODO*/photoImage.setImage(null, null, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, 0, null, currentMessageObject, 0); + /*TODO*/ + photoImage.setImage(null, null, ImageLocation.getForDocument(currentPhotoObject, documentAttach), filter, 0, null, currentMessageObject, 0); } } else { boolean photoExist = messageObject.mediaExists; String fileName = FileLoader.getAttachFileName(currentPhotoObject); if (hasGamePreview || photoExist || DownloadController.getInstance(currentAccount).canDownloadMedia(currentMessageObject) || FileLoader.getInstance(currentAccount).isLoadingFile(fileName)) { photoNotSet = false; - /*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); } else { photoNotSet = true; if (currentPhotoObjectThumb != null) { - /*TODO*/photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), String.format(Locale.US, "%d_%d_b", w, h), 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(null, null, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), String.format(Locale.US, "%d_%d_b", w, h), 0, null, messageObject, 0); } else { photoImage.setImageBitmap((Drawable) null); } @@ -5366,13 +5377,15 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate TLRPC.Document document = messageObject.getDocument(); if (currentMessageObject.videoEditedInfo != null && currentMessageObject.videoEditedInfo.canAutoPlaySourceVideo()) { - /*TODO*/photoImage.setImage(ImageLocation.getForPath(currentMessageObject.videoEditedInfo.originalPath), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForPath(currentMessageObject.videoEditedInfo.originalPath), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0); photoImage.setMediaStartEndTime(currentMessageObject.videoEditedInfo.startTime / 1000, currentMessageObject.videoEditedInfo.endTime / 1000); } else { if (!messageIdChanged && !dataChanged) { photoImage.setCrossfadeWithOldImage(true); } - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForDocument(currentPhotoObjectThumb, document), currentPhotoFilterThumb, null, messageObject.getDocument().size, null, messageObject, 0); } } else if (messageObject.type == MessageObject.TYPE_PHOTO) { if (messageObject.useCustomPhoto) { @@ -5423,41 +5436,50 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate photoImage.setCrossfadeDuration(250); } if (localFile == 0 && videoSize != null && (currentPhotoObject == null || currentPhotoObjectThumb == null)) { - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0); } else { - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), ImageLoader.AUTOPLAY_FILTER, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0); } } else if (localFile == 1) { - /*TODO*/photoImage.setImage(ImageLocation.getForPath(messageObject.isSendError() ? null : messageObject.messageOwner.attachPath), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForPath(messageObject.isSendError() ? null : messageObject.messageOwner.attachPath), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, 0, null, messageObject, 0); } else { if (videoSize != null && (currentPhotoObject == null || currentPhotoObjectThumb == null)) { - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForDocument(videoSize, documentAttach), null, ImageLocation.getForDocument(currentPhotoObject != null ? currentPhotoObject : currentPhotoObjectThumb, documentAttach), currentPhotoObject != null ? currentPhotoFilter : currentPhotoFilterThumb, null, document.size, null, messageObject, 0); } else { - /*TODO*/photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForDocument(document), null, ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, null, document.size, null, messageObject, 0); } } } else { if (messageObject.videoEditedInfo != null && messageObject.type == MessageObject.TYPE_ROUND_VIDEO && !currentMessageObject.needDrawBluredPreview()) { - /*TODO*/photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); photoImage.setMediaStartEndTime(currentMessageObject.videoEditedInfo.startTime / 1000, currentMessageObject.videoEditedInfo.endTime / 1000); } else { if (!messageIdChanged && !currentMessageObject.needDrawBluredPreview()) { photoImage.setCrossfadeWithOldImage(true); photoImage.setCrossfadeDuration(250); } - /*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, 0); } } } else { if (messageObject.videoEditedInfo != null && messageObject.type == MessageObject.TYPE_ROUND_VIDEO && !currentMessageObject.needDrawBluredPreview()) { - /*TODO*/photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForPath(messageObject.videoEditedInfo.originalPath), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0); photoImage.setMediaStartEndTime(currentMessageObject.videoEditedInfo.startTime / 1000, currentMessageObject.videoEditedInfo.endTime / 1000); } else { if (!messageIdChanged && !currentMessageObject.needDrawBluredPreview()) { photoImage.setCrossfadeWithOldImage(true); photoImage.setCrossfadeDuration(250); } - /*TODO*/photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0); + /*TODO*/ + photoImage.setImage(ImageLocation.getForObject(currentPhotoObject, photoParentObject), currentPhotoFilter, ImageLocation.getForObject(currentPhotoObjectThumb, photoParentObject), currentPhotoFilterThumb, 0, null, messageObject, currentMessageObject.shouldEncryptPhotoOrVideo() ? 2 : 0); } } } @@ -5862,8 +5884,26 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate seekBarWaveform.setProgress(0); } - if (isBlockedUserMessage()) { + needHide = needHideMessage(); + if (needHide) { totalHeight = 0; + drawTime = false; + needNewVisiblePart = false; + needReplyImage = false; + drawCommentButton = false; + drawForwardedName = false; + drawInstantView = false; + drawBackground = false; + drawCommentNumber = false; + drawImageButton = false; + drawJoinChannelView = false; + drawJoinGroupView = false; + drawMediaCheckBox = false; + drawName = false; + drawNameLayout = false; + drawPhotoImage = false; + drawBackground = false; + isAvatarVisible = false; } updateWaveform(); updateButtonState(false, dataChanged && !messageObject.cancelEditing, true); @@ -5879,6 +5919,8 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } accessibilityVirtualViewBounds.clear(); } + + private boolean needHide; public void checkVideoPlayback(boolean allowStart) { if (currentMessageObject.isVideo()) { @@ -6627,7 +6669,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate inLayout = false; } updateSelectionTextPosition(); - setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), totalHeight + keyboardHeight); + setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), needHide ? 0: totalHeight + keyboardHeight); } public void forceResetMessageObject() { @@ -6667,7 +6709,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate @SuppressLint("DrawAllocation") @Override protected void onLayout(boolean changed, int left, int top, int right, int bottom) { - if (currentMessageObject == null) { + if (currentMessageObject == null || needHide) { return; } if (changed || !wasLayout) { @@ -7130,7 +7172,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate int size = AndroidUtilities.dp(48); buttonX = this.buttonX = (int) (photoImage.getImageX() + (photoImage.getImageWidth() - size) / 2.0f); buttonY = this.buttonY = (int) (photoImage.getImageY() + (photoImage.getImageHeight() - size) / 2.0f); - radialProgress.setProgressRect((int) buttonX, (int ) buttonY, (int) buttonX + size, (int) buttonY + size); + radialProgress.setProgressRect((int) buttonX, (int) buttonY, (int) buttonX + size, (int) buttonY + size); } imageDrawn = photoImage.draw(canvas); } @@ -7490,7 +7532,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate canvas.translate(timeAudioX + songX, AndroidUtilities.dp(13) + namesOffset + mediaOffsetY); songLayout.draw(canvas); canvas.restore(); - + boolean showSeekbar = MediaController.getInstance().isPlayingMessage(currentMessageObject); if (showSeekbar && toSeekBarProgress != 1f) { toSeekBarProgress += 16f / 100f; @@ -7498,7 +7540,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate toSeekBarProgress = 1f; } invalidate(); - } else if (!showSeekbar && toSeekBarProgress != 0){ + } else if (!showSeekbar && toSeekBarProgress != 0) { toSeekBarProgress -= 16f / 100f; if (toSeekBarProgress < 0) { toSeekBarProgress = 0; @@ -8763,7 +8805,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (setCurrentDiceValue(!memCache && !currentMessageObject.wasUnread)) { return; } - if (!thumb && !currentMessageObject.mediaExists && !currentMessageObject.attachPathExists && (currentMessageObject.type == 0 && (documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER || documentAttachType == DOCUMENT_ATTACH_TYPE_NONE || documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) || currentMessageObject.type == MessageObject.TYPE_PHOTO)){ + if (!thumb && !currentMessageObject.mediaExists && !currentMessageObject.attachPathExists && (currentMessageObject.type == 0 && (documentAttachType == DOCUMENT_ATTACH_TYPE_WALLPAPER || documentAttachType == DOCUMENT_ATTACH_TYPE_NONE || documentAttachType == DOCUMENT_ATTACH_TYPE_STICKER) || currentMessageObject.type == MessageObject.TYPE_PHOTO)) { currentMessageObject.mediaExists = true; updateButtonState(false, true, false); } @@ -10313,7 +10355,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate int additionalTop = 0; if (currentPosition != null) { if ((currentPosition.flags & MessageObject.POSITION_FLAG_TOP) == 0) { - additionalTop -= AndroidUtilities.dp( 3); + additionalTop -= AndroidUtilities.dp(3); } } return additionalTop + (drawPinnedTop ? 0 : AndroidUtilities.dp(1)); @@ -11023,7 +11065,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate int restore = Integer.MIN_VALUE; if (renderingAlpha != 1.0f) { - rect.set(captionX, captionY, captionX + captionLayout.getWidth(), captionY + captionLayout.getHeight()); + rect.set(captionX, captionY, captionX + captionLayout.getWidth(), captionY + captionLayout.getHeight()); restore = canvas.saveLayerAlpha(rect, (int) (255 * renderingAlpha), Canvas.ALL_SAVE_FLAG); } @@ -11077,7 +11119,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate boolean drawSelectionBackground = i == 1; if (i == 1) { curentAplha *= currentSelectedBackgroundAlpha; - } else if (!shouldDrawTimeOnMedia()){ + } else if (!shouldDrawTimeOnMedia()) { curentAplha *= (1f - currentSelectedBackgroundAlpha); } if (transitionParams.animateShouldDrawTimeOnMedia && transitionParams.animateChangeProgress != 1f) { @@ -11232,7 +11274,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate transitionParams.lastStatusDrawableParams = transitionParams.createStatusDrawableParams(); if (drawClock && fromParent && getParent() != null) { - ((View)getParent()).invalidate(); + ((View) getParent()).invalidate(); } } @@ -11287,7 +11329,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate transitionParams.lastStatusDrawableParams = transitionParams.createStatusDrawableParams(); if (drawClock && fromParent && getParent() != null) { - ((View)getParent()).invalidate(); + ((View) getParent()).invalidate(); } } canvas.save(); @@ -11341,7 +11383,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (!outDrawClock && !isBroadcast && !outIsBroadcast && outDrawCheck2 && drawCheck2 && !outDrawCheck1 && drawCheck1) { drawStatusDrawable(canvas, drawCheck1, drawCheck2, drawClock, drawError, isBroadcast, alpha, bigRadius, timeYOffset, layoutHeight, statusDrawableProgress, true, drawSelectionBackground); } else { - drawStatusDrawable(canvas, outDrawCheck1, outDrawCheck2, outDrawClock, outDrawError, outIsBroadcast, alpha, bigRadius, timeYOffset, layoutHeight,1f - statusDrawableProgress, false, drawSelectionBackground); + drawStatusDrawable(canvas, outDrawCheck1, outDrawCheck2, outDrawClock, outDrawError, outIsBroadcast, alpha, bigRadius, timeYOffset, layoutHeight, 1f - statusDrawableProgress, false, drawSelectionBackground); drawStatusDrawable(canvas, drawCheck1, drawCheck2, drawClock, drawError, isBroadcast, alpha, bigRadius, timeYOffset, layoutHeight, statusDrawableProgress, false, drawSelectionBackground); } } else { @@ -11371,7 +11413,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate return; } statusDrawableProgress = 0f; - statusDrawableAnimator = ValueAnimator.ofFloat(0,1f); + statusDrawableAnimator = ValueAnimator.ofFloat(0, 1f); if (moveCheckTransition) { statusDrawableAnimator.setDuration(220); } else { @@ -11417,7 +11459,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate clockDrawable = drawSelectionBackground ? Theme.chat_msgInSelectedClockDrawable : Theme.chat_msgInClockDrawable; } float timeY = shouldDrawTimeOnMedia() ? photoImage.getImageY2() + additionalTimeOffsetY - AndroidUtilities.dp(9.0f) : layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9.5f : 8.5f) + timeYOffset; - setDrawableBounds(clockDrawable, timeX + (currentMessageObject.scheduled ? 0 : AndroidUtilities.dp(11)), timeY - clockDrawable.getIntrinsicHeight()); + setDrawableBounds(clockDrawable, timeX + (currentMessageObject.scheduled ? 0 : AndroidUtilities.dp(11)), timeY - clockDrawable.getIntrinsicHeight()); clockDrawable.setAlpha((int) (255 * alpha)); if (useScale) { canvas.save(); @@ -11780,7 +11822,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate canvas.translate(AndroidUtilities.dp(4) * (1f - progress), 0); } drawable = drawSelectionBackground ? Theme.chat_msgOutCheckReadSelectedDrawable : Theme.chat_msgOutCheckReadDrawable; - setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(22.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight() + timeYOffset); + setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(22.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight() + timeYOffset); } else { drawable = drawSelectionBackground ? Theme.chat_msgOutCheckSelectedDrawable : Theme.chat_msgOutCheckDrawable; setDrawableBounds(drawable, layoutWidth - AndroidUtilities.dp(18.5f) - drawable.getIntrinsicWidth(), layoutHeight - AndroidUtilities.dp(pinnedBottom || pinnedTop ? 9 : 8) - drawable.getIntrinsicHeight() + timeYOffset); @@ -11951,7 +11993,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } else { imageW = 0; } - if (drawLoadingProgress && loadingProgressLayout != null){ + if (drawLoadingProgress && loadingProgressLayout != null) { imageW = 0; infoW = (int) loadingProgressLayout.getLineWidth(0); } else { @@ -12079,7 +12121,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate StaticLayout docTitleLayout = this.docTitleLayout; StaticLayout infoLayout = this.infoLayout; float alpha = 1f; - if (transitionParams.animateLocationIsExpired){ + if (transitionParams.animateLocationIsExpired) { progress = transitionParams.lastDrawLocationExpireProgress; text = transitionParams.lastDrawLocationExpireText; docTitleLayout = transitionParams.lastDrawDocTitleLayout; @@ -12832,6 +12874,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate } public int computeHeight(MessageObject object, MessageObject.GroupedMessages groupedMessages) { + if (needHide) return 0; /*if (object.type == 2 || object.type == 12 || object.type == 9 || object.type == 4 || object.type == 14 || object.type == 10 || object.type == 11 || object.type == MessageObject.TYPE_ROUND_VIDEO) { @@ -12987,7 +13030,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate AccessibilityNodeInfo info = AccessibilityNodeInfo.obtain(ChatMessageCell.this); onInitializeAccessibilityNodeInfo(info); StringBuilder sb = new StringBuilder(); - if (isChat && currentUser!=null && !currentMessageObject.isOut()) { + if (isChat && currentUser != null && !currentMessageObject.isOut()) { sb.append(UserObject.getUserName(currentUser)); sb.append('\n'); } @@ -13009,7 +13052,7 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate if (currentMessageObject.isMusic()) { sb.append("\n"); sb.append(LocaleController.formatString("AccDescrMusicInfo", R.string.AccDescrMusicInfo, currentMessageObject.getMusicAuthor(), currentMessageObject.getMusicTitle())); - } else if (currentMessageObject.isVoice() || currentMessageObject.isRoundVideo()){ + } else if (currentMessageObject.isVoice() || currentMessageObject.isRoundVideo()) { sb.append(", "); sb.append(LocaleController.formatDuration(currentMessageObject.getDuration())); if (currentMessageObject.isContentUnread()) { diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java index 4403424d6..06b809060 100644 --- a/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java +++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatActivity.java @@ -1091,6 +1091,7 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not private final static int unpin = 106; private final static int save = 107; private final static int delete_history = 108; + private final static int hide = 109; private final static int bot_help = 30; private final static int bot_settings = 31; @@ -1904,6 +1905,12 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not ArrayList messages = getSelectedMessages(); forwardMessages(messages, false, true, 0, UserConfig.getInstance(currentAccount).getClientUserId()); undoView.showWithAction(getUserConfig().getClientUserId(), UndoView.ACTION_FWD_MESSAGES, messages.size()); + } else if (id == hide) { + ArrayList messages = getSelectedMessages(); + for (MessageObject message : messages) { + message.messageOwner.hide = true; + } + getMessageHelper().resetMessageContent(dialog_id, messages); } else if (id == delete) { if (getParentActivity() == null) { return; @@ -2558,6 +2565,10 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not actionModeOtherItem.addSubItem(unpin, R.drawable.deproko_baseline_pin_undo_24, LocaleController.getString("UnpinMessage", R.string.UnpinMessage)); actionModeOtherItem.addSubItem(save, R.drawable.baseline_bookmark_24, LocaleController.getString("AddToSavedMessages", R.string.AddToSavedMessages)); + if (NekoConfig.showMessageHide) { + actionModeOtherItem.addSubItem(hide, R.drawable.baseline_remove_circle_24, LocaleController.getString("Hide", R.string.Hide)); + } + actionMode.getItem(reply).setVisibility(ChatObject.canSendMessages(currentChat) && selectedMessagesIds[0].size() + selectedMessagesIds[1].size() == 1 ? View.VISIBLE : View.GONE); actionMode.getItem(edit).setVisibility(canEditMessagesCount == 1 && selectedMessagesIds[0].size() + selectedMessagesIds[1].size() == 1 ? View.VISIBLE : View.GONE); actionMode.getItem(copy).setVisibility(selectedMessagesCanCopyIds[0].size() + selectedMessagesCanCopyIds[1].size() != 0 ? View.VISIBLE : View.GONE); @@ -19193,6 +19204,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not options.add(89); icons.add(R.drawable.menu_info); } + if (NekoConfig.showMessageHide) { + items.add(LocaleController.getString("Hide", R.string.Hide)); + options.add(204); + icons.add(R.drawable.baseline_remove_circle_24); + } boolean canViewStats = false; if (message.messageOwner.views > 0 || message.messageOwner.forwards > 0) { if (message.messageOwner.fwd_from != null && message.messageOwner.fwd_from.channel_post != 0) { @@ -19364,6 +19380,11 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not icons.add(R.drawable.baseline_vpn_key_24); } } + if (NekoConfig.showMessageHide) { + items.add(LocaleController.getString("Hide", R.string.Hide)); + options.add(204); + icons.add(R.drawable.baseline_remove_circle_24); + } items.add(LocaleController.getString("Delete", R.string.Delete)); options.add(1); icons.add(selectedObject.messageOwner.ttl_period != 0 ? R.drawable.msg_delete_auto : R.drawable.baseline_delete_24); @@ -20737,6 +20758,18 @@ public class ChatActivity extends BaseFragment implements NotificationCenter.Not } } + case 204: { + if (selectedObjectGroup != null) { + for (MessageObject object : selectedObjectGroup.messages) { + object.messageOwner.hide = true; + } + getMessageHelper().resetMessageContent(dialog_id, selectedObjectGroup.messages); + } else { + selectedObject.messageOwner.hide = true; + getMessageHelper().resetMessageContent(dialog_id, selectedObject); + } + + } } selectedObject = null; selectedObjectGroup = null; diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java index 59f58090b..01a085425 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/MessageHelper.java @@ -46,6 +46,15 @@ public class MessageHelper extends BaseController { getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, dialog_id, arrayList, false); } + public void resetMessageContent(long dialog_id, ArrayList messageObjects) { + ArrayList arrayList = new ArrayList<>(); + for (MessageObject messageObject : messageObjects) { + MessageObject obj = new MessageObject(currentAccount, messageObject.messageOwner, true, true); + arrayList.add(obj); + } + getNotificationCenter().postNotificationName(NotificationCenter.replaceMessagesObjects, dialog_id, arrayList, false); + } + public static MessageHelper getInstance(int num) { MessageHelper localInstance = Instance.get(num); if (localInstance == null) { diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java index cb75e9077..416ab9ea3 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/NekoConfig.java @@ -59,6 +59,7 @@ public class NekoConfig { public static boolean showMessageDetails; public static boolean showTranslate; public static boolean showRepeat; + public static boolean showMessageHide; public static boolean hidePhone; public static int typeface; @@ -218,6 +219,8 @@ public class NekoConfig { showMessageDetails = preferences.getBoolean("showMessageDetails", false); showTranslate = preferences.getBoolean("showTranslate", true); showRepeat = preferences.getBoolean("showRepeat", false); + showMessageHide = preferences.getBoolean("showMessageHide", false); + eventType = preferences.getInt("eventType", 0); actionBarDecoration = preferences.getInt("actionBarDecoration", 0); newYear = preferences.getBoolean("newYear", false); @@ -371,6 +374,14 @@ public class NekoConfig { editor.apply(); } + public static void toggleShowHide() { + showMessageHide = !showMessageHide; + SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); + SharedPreferences.Editor editor = preferences.edit(); + editor.putBoolean("showMessageHide", showMessageHide); + editor.apply(); + } + public static void toggleIPv6() { useIPv6 = !useIPv6; SharedPreferences preferences = ApplicationLoader.applicationContext.getSharedPreferences("nekoconfig", Activity.MODE_PRIVATE); diff --git a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java index c0676512b..256b2fbdc 100644 --- a/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java +++ b/TMessagesProj/src/main/java/tw/nekomimi/nekogram/settings/NekoChatSettingsActivity.java @@ -386,7 +386,7 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati linearLayoutInviteContainer.setOrientation(LinearLayout.VERTICAL); linearLayout.addView(linearLayoutInviteContainer, LayoutHelper.createLinear(LayoutHelper.MATCH_PARENT, LayoutHelper.WRAP_CONTENT)); - int count = NekoXConfig.developerMode ? 9 : 8; + int count = NekoXConfig.developerMode ? 10 : 9; for (int a = 0; a < count; a++) { TextCheckCell textCell = new TextCheckCell(context); switch (a) { @@ -423,6 +423,10 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati break; } case 8: { + textCell.setTextAndCheck(LocaleController.getString("Hide", R.string.Hide), NekoConfig.showMessageHide, false); + break; + } + case 9: { textCell.setTextAndCheck(LocaleController.getString("MessageDetails", R.string.MessageDetails), NekoConfig.showMessageDetails, false); break; } @@ -474,6 +478,11 @@ public class NekoChatSettingsActivity extends BaseFragment implements Notificati break; } case 8: { + NekoConfig.toggleShowHide(); + textCell.setChecked(NekoConfig.showMessageHide); + break; + } + case 9: { NekoConfig.toggleShowMessageDetails(); textCell.setChecked(NekoConfig.showMessageDetails); break;