@@ -4920,6 +4920,9 @@ public void onItemClick(int id) {
49204920 }
49214921 closePhoto(true, false);
49224922 } else if (id == gallery_menu_save) {
4923+ if (pageBlocksAdapter != null && !allowShare) {
4924+ return;
4925+ }
49234926 if (Build.VERSION.SDK_INT >= 23 && (Build.VERSION.SDK_INT <= 28 || BuildVars.NO_SCOPED_STORAGE) && parentActivity.checkSelfPermission(Manifest.permission.WRITE_EXTERNAL_STORAGE) != PackageManager.PERMISSION_GRANTED) {
49244927 parentActivity.requestPermissions(new String[]{Manifest.permission.WRITE_EXTERNAL_STORAGE}, 4);
49254928 return;
@@ -14034,6 +14037,7 @@ private void onPhotoShow(final MessageObject messageObject, final TLRPC.FileLoca
1403414037 menuItem.hideSubItem(gallery_menu_edit_avatar);
1403514038 menuItem.hideSubItem(gallery_menu_set_as_main);
1403614039 menuItem.hideSubItem(gallery_menu_delete);
14040+ menuItem.hideSubItem(gallery_menu_cancel_loading);
1403714041 speedItem.setVisibility(View.GONE);
1403814042 speedGap.setVisibility(View.GONE);
1403914043 videoItem.setVisibility(View.GONE);
@@ -15180,7 +15184,7 @@ private void setIsAboutToSwitchToIndex(int index, boolean init, boolean animated
1518015184 }
1518115185 menuItem.hideSubItem(gallery_menu_translate);
1518215186 menuItem.hideSubItem(gallery_menu_hide_translation);
15183- allowShare = !MessagesController.getInstance(currentAccount).isPeerNoForwards(currentDialogId) && (currentMessageObject == null || !currentMessageObject.hasRevealedExtendedMedia());
15187+ allowShare = !MessagesController.getInstance(currentAccount).isPeerNoForwards(currentDialogId) && (currentMessageObject == null || !currentMessageObject.hasRevealedExtendedMedia()) && !isPageBlocksNoForwards(pageBlocksAdapter) ;
1518415188 TL_iv.PageBlock pageBlock = pageBlocksAdapter.get(switchingToIndex);
1518515189 caption = pageBlocksAdapter.getCaption(switchingToIndex);
1518615190 isVideo = pageBlocksAdapter.isVideo(switchingToIndex);
@@ -15229,8 +15233,8 @@ private void setIsAboutToSwitchToIndex(int index, boolean init, boolean animated
1522915233 title = getString(R.string.AttachPhoto);
1523015234 }
1523115235 }
15232- galleryButton.setVisibility(View.VISIBLE);
15233- galleryGap.setVisibility(View.VISIBLE);
15236+ galleryButton.setVisibility(allowShare ? View.VISIBLE : View.GONE );
15237+ galleryGap.setVisibility(allowShare ? View.VISIBLE : View.GONE );
1523415238 menuItem.hideSubItem(gallery_menu_savegif);
1523515239 menuItem.checkHideMenuItem();
1523615240 }
@@ -17481,7 +17485,8 @@ public boolean openPhoto(final MessageObject messageObject, final TLRPC.FileLoca
1748117485 if (chatActivity != null && chatActivity.getCurrentEncryptedChat() != null ||
1748217486 avatarsDialogId != 0 && MessagesController.getInstance(currentAccount).isPeerNoForwards(avatarsDialogId) ||
1748317487 messageObject != null && (MessagesController.getInstance(currentAccount).isPeerNoForwards(messageObject.getDialogId()) ||
17484- (messageObject.messageOwner != null && messageObject.messageOwner.noforwards)) || messageObject != null && messageObject.hasRevealedExtendedMedia()
17488+ (messageObject.messageOwner != null && messageObject.messageOwner.noforwards)) || messageObject != null && messageObject.hasRevealedExtendedMedia() ||
17489+ isPageBlocksNoForwards(pageBlocksAdapter)
1748517490 ) {
1748617491 windowLayoutParams.flags |= WindowManager.LayoutParams.FLAG_SECURE;
1748717492 AndroidUtilities.logFlagSecure();
@@ -19478,6 +19483,20 @@ private boolean shouldMessageObjectAutoPlayed(MessageObject messageObject) {
1947819483 return messageObject != null && messageObject.isVideo() && (messageObject.mediaExists || messageObject.attachPathExists || messageObject.hasVideoQualities() || messageObject.canStreamVideo() && SharedConfig.streamMedia) && SharedConfig.isAutoplayVideo();
1947919484 }
1948019485
19486+ private boolean isPageBlocksNoForwards(PageBlocksAdapter adapter) {
19487+ if (adapter == null) {
19488+ return false;
19489+ }
19490+ // rich messages open their media as page blocks without a MessageObject/dialogId,
19491+ // so protected content has to be resolved from the adapter's parent message
19492+ final Object parent = adapter.getParentObject();
19493+ if (parent instanceof MessageObject && ((MessageObject) parent).messageOwner != null) {
19494+ final MessageObject messageObject = (MessageObject) parent;
19495+ return MessagesController.getInstance(currentAccount).isPeerNoForwards(messageObject.getDialogId()) || messageObject.messageOwner.noforwards || messageObject.hasRevealedExtendedMedia();
19496+ }
19497+ return false;
19498+ }
19499+
1948119500 private boolean shouldIndexAutoPlayed(int index) {
1948219501 if (pageBlocksAdapter != null) {
1948319502 if ((pageBlocksAdapter.isVideo(index) || pageBlocksAdapter.isHardwarePlayer(index)) && SharedConfig.isAutoplayVideo()) {
0 commit comments