From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: alina sireneva <alina@tei.su>
Date: Fri, 17 Apr 2026 04:51:56 +0300
Subject: disabling animated spoiler in power settings doesn't apply to photos

---
 .../org/telegram/ui/Cells/ChatMessageCell.java   |  8 ++++++++
 .../java/org/telegram/ui/Cells/GroupMedia.java   | 13 ++++++++++++-
 .../ChatAttachAlertPhotoLayoutPreview.java       | 16 +++++++++++++++-
 .../ui/Components/spoilers/SpoilerEffect2.java   |  3 ++-
 4 files changed, 37 insertions(+), 3 deletions(-)

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 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/ChatMessageCell.java
@@ -15228,6 +15228,14 @@ public class ChatMessageCell extends BaseCell implements SeekBar.SeekBarDelegate
 
     public void drawBlurredPhotoParticles(Canvas canvas) {
         if (mediaSpoilerEffect2 == null) {
+            if (!LiteMode.isEnabled(LiteMode.FLAG_CHAT_SPOILER)) {
+                if (mediaSpoilerEffect == null) {
+                    mediaSpoilerEffect = new SpoilerEffect();
+                }
+                mediaSpoilerEffect.setColor(ColorUtils.setAlphaComponent(Color.WHITE, (int) (255 * 0.5f * photoImage.getAlpha())));
+                mediaSpoilerEffect.setBounds((int) photoImage.getImageX(), (int) photoImage.getImageY(), (int) photoImage.getImageX2(), (int) photoImage.getImageY2());
+                mediaSpoilerEffect.draw(canvas);
+            }
             return;
         }
         canvas.save();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/GroupMedia.java
@@ -41,6 +41,7 @@ import org.telegram.ui.Components.LoadingDrawable;
 import org.telegram.ui.Components.MediaActionDrawable;
 import org.telegram.ui.Components.RadialProgress2;
 import org.telegram.ui.Components.Text;
+import org.telegram.ui.Components.spoilers.SpoilerEffect;
 import org.telegram.ui.Components.spoilers.SpoilerEffect2;
 import org.telegram.ui.Stars.StarsIntroActivity;
 
@@ -66,6 +67,7 @@ public class GroupMedia {
     private LoadingDrawable loadingDrawable;
 
     SpoilerEffect2 spoilerEffect;
+    SpoilerEffect spoilerEffectFallback;
 
     public GroupMedia(@NonNull ChatMessageCell cell) {
         this.cell = cell;
@@ -605,7 +607,16 @@ public class GroupMedia {
             canvas.clipPath(clipPath2);
             canvas.translate(l, t);
             canvas.saveLayerAlpha(0, 0, (int) (r - l), (int) (b - t), (int) (0xFF * hiddenAlpha), Canvas.ALL_SAVE_FLAG);
-            spoilerEffect.draw(canvas, cell, (int) (r - l), (int) (b - t), 1f, cell.drawingToBitmap);
+            if (spoilerEffect != null) {
+                spoilerEffect.draw(canvas, cell, (int) (r - l), (int) (b - t), 1f, cell.drawingToBitmap);
+            } else {
+                if (spoilerEffectFallback == null) {
+                    spoilerEffectFallback = new SpoilerEffect();
+                    spoilerEffectFallback.setColor(Color.WHITE);
+                }
+                spoilerEffectFallback.setBounds(0, 0, (int) (r - l), (int) (b - t));
+                spoilerEffectFallback.draw(canvas);
+            }
             canvas.restore();
             canvas.restore();
             cell.invalidate();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayoutPreview.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayoutPreview.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayoutPreview.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ChatAttachAlertPhotoLayoutPreview.java
@@ -60,7 +60,11 @@ import org.telegram.ui.ActionBar.BaseFragment;
 import org.telegram.ui.ActionBar.Theme;
 import org.telegram.ui.Cells.ChatActionCell;
 import org.telegram.ui.ChatActivity;
+import org.telegram.ui.Components.spoilers.SpoilerEffect;
 import org.telegram.ui.Components.spoilers.SpoilerEffect2;
+
+import android.graphics.Color;
+import androidx.core.graphics.ColorUtils;
 import org.telegram.ui.LaunchActivity;
 import org.telegram.ui.PhotoViewer;
 import org.telegram.ui.Stars.StarsIntroActivity;
@@ -1951,6 +1955,7 @@ public class ChatAttachAlertPhotoLayoutPreview extends ChatAttachAlert.AttachAle
                 private String videoDurationText = null;
 
                 private SpoilerEffect2 spoilerEffect;
+                private SpoilerEffect spoilerEffectFallback;
                 private Path path = new Path();
                 private float[] radii = new float[8];
 
@@ -2381,7 +2386,16 @@ public class ChatAttachAlertPhotoLayoutPreview extends ChatAttachAlert.AttachAle
                         if (spoilerEffect == null) {
                             spoilerEffect = SpoilerEffect2.getInstance(PreviewGroupsView.this);
                         }
-                        spoilerEffect.draw(canvas, PreviewGroupsView.this, getWidth(), getHeight());
+                        if (spoilerEffect != null) {
+                            spoilerEffect.draw(canvas, PreviewGroupsView.this, getWidth(), getHeight());
+                        } else {
+                            if (spoilerEffectFallback == null) {
+                                spoilerEffectFallback = new SpoilerEffect();
+                                spoilerEffectFallback.setColor(ColorUtils.setAlphaComponent(Color.WHITE, (int) (Color.alpha(Color.WHITE) * 0.325f)));
+                            }
+                            spoilerEffectFallback.setBounds(0, 0, getWidth(), getHeight());
+                            spoilerEffectFallback.draw(canvas);
+                        }
                         canvas.restore();
 
                         invalidate();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect2.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect2.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect2.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/spoilers/SpoilerEffect2.java
@@ -19,6 +19,7 @@ import androidx.annotation.NonNull;
 
 import org.telegram.messenger.AndroidUtilities;
 import org.telegram.messenger.FileLog;
+import org.telegram.messenger.LiteMode;
 import org.telegram.messenger.R;
 import org.telegram.messenger.SharedConfig;
 import org.telegram.messenger.Utilities;
@@ -57,7 +58,7 @@ public class SpoilerEffect2 {
     }
 
     public static SpoilerEffect2 getInstance(int type, View view, ViewGroup rootView) {
-        if (view == null || !supports()) {
+        if (view == null || !supports() || !LiteMode.isEnabled(LiteMode.FLAG_CHAT_SPOILER)) {
             return null;
         }
         if (instance == null) {
