From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: alina sireneva <alina@tei.su>
Date: Thu, 28 May 2026 22:18:07 +0400
Subject: md3-style sections redesign

---
 .../ui/ActionBar/ThemeDescription.java        |  7 +++-
 .../java/org/telegram/ui/BoostsActivity.java  |  5 +++
 .../java/org/telegram/ui/Cells/TextCell.java  | 27 ++++++++++---
 .../org/telegram/ui/Cells/TextCheckCell.java  |  6 ++-
 .../ui/Cells/TextDetailSettingsCell.java      |  8 ++--
 .../telegram/ui/Cells/TextSettingsCell.java   |  2 +-
 .../org/telegram/ui/ChannelBoostLayout.java   |  5 +++
 .../telegram/ui/ChatRightsEditActivity.java   |  3 ++
 .../org/telegram/ui/ChatUsersActivity.java    |  6 +++
 .../telegram/ui/Components/ItemOptions.java   |  8 ++++
 .../ui/Components/RecyclerListView.java       | 39 +++++++++++++++----
 .../ui/Components/UniversalAdapter.java       | 15 ++++++-
 .../telegram/ui/LiteModeSettingsActivity.java |  7 ++++
 .../org/telegram/ui/PeerColorActivity.java    |  9 +++--
 .../org/telegram/ui/ProxyListActivity.java    |  5 ---
 .../org/telegram/ui/SettingsActivity.java     | 18 +++++++++
 .../org/telegram/ui/StatisticActivity.java    |  1 +
 17 files changed, 143 insertions(+), 28 deletions(-)

diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeDescription.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeDescription.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeDescription.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/ThemeDescription.java
@@ -32,6 +32,7 @@ import androidx.viewpager.widget.ViewPager;
 
 import org.telegram.messenger.AndroidUtilities;
 import org.telegram.messenger.FileLog;
+import org.telegram.ui.Cells.HeaderCell;
 import org.telegram.ui.Components.AnimatedArrowDrawable;
 import org.telegram.ui.Components.AudioPlayerAlert;
 import org.telegram.ui.Components.AvatarDrawable;
@@ -529,7 +530,11 @@ public class ThemeDescription {
                             }
                         }
                     } else if ((changeFlags & FLAG_CELLBACKGROUNDCOLOR) != 0) {
-                        child.setBackgroundColor(color);
+                        if (child instanceof HeaderCell && viewToInvalidate instanceof RecyclerListView && ((RecyclerListView) viewToInvalidate).hasSections() && desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                            // skip
+                        } else {
+                            child.setBackgroundColor(color);
+                        }
                     } else if ((changeFlags & FLAG_TEXTCOLOR) != 0) {
                         if (child instanceof TextView) {
                             ((TextView) child).setTextColor(color);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/BoostsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/BoostsActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/BoostsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/BoostsActivity.java
@@ -160,10 +160,12 @@ public class BoostsActivity extends GradientHeaderActivity implements Notificati
                 case HEADER_VIEW_TYPE:
                     view = new ChartHeaderView(getContext());
                     view.setPadding(view.getPaddingLeft(), AndroidUtilities.dp(16), view.getRight(), AndroidUtilities.dp(16));
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(view, false, true);
                     break;
                 case HEADER_VIEW_TYPE_SMALL:
                     view = new ChartHeaderView(getContext());
                     view.setPadding(view.getPaddingLeft(), AndroidUtilities.dp(16), view.getRight(), AndroidUtilities.dp(8));
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(view, false, true);
                     break;
                 case HEADER_VIEW_TYPE_TABS:
                     boostsTabs = new ScrollSlidingTextTabStrip(getContext(), resourceProvider);
@@ -174,6 +176,7 @@ public class BoostsActivity extends GradientHeaderActivity implements Notificati
                         @Override
                         protected void dispatchDraw(Canvas canvas) {
                             super.dispatchDraw(canvas);
+                            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) return;
                             dividerPaint.setColor(Theme.getColor(Theme.key_windowBackgroundGray, resourceProvider));
                             canvas.drawRect(0, getHeight() - 2, getWidth(), getHeight(), dividerPaint);
                         }
@@ -196,6 +199,7 @@ public class BoostsActivity extends GradientHeaderActivity implements Notificati
                         }
                     });
                     frameLayoutWrapper.addView(boostsTabs, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 48));
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(frameLayoutWrapper, false, true);
                     view = frameLayoutWrapper;
                     break;
                 case SHOW_BOOST_BY_GIFTS:
@@ -285,6 +289,7 @@ public class BoostsActivity extends GradientHeaderActivity implements Notificati
                 userCell.setData(user, ContactsController.formatName(user), str, 0, !items.get(position).isLast);
                 userCell.setStatus(booster);
                 userCell.setAvatarPadding(5);
+                desu.inugram.helpers.theme.M3SectionsHelper.markMerged(userCell, true, true);
             } else if (holder.getItemViewType() == DIVIDER_TEXT_VIEW_TYPE) {
                 TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
                 privacyCell.setText(items.get(position).title);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCell.java
@@ -58,9 +58,10 @@ public class TextCell extends FrameLayout {
     private ImageView valueImageView;
     public int leftPadding;
     private boolean needDivider;
-    public int offsetFromImage = 58;
-    public int heightDp = 50;
+    public int offsetFromImage = desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() ? 60 : 58;
+    public int heightDp = desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() ? 56 : 50;
     public int imageLeft = 16;
+    public int inu_m3IconSize = 22;
     private boolean inDialogs;
     private boolean prioritizeTitleOverValue;
     private Theme.ResourcesProvider resourcesProvider;
@@ -113,7 +114,7 @@ public class TextCell extends FrameLayout {
         valueTextView.setTextSize(dp(16));
         valueTextView.setGravity(LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT);
         valueTextView.setImportantForAccessibility(IMPORTANT_FOR_ACCESSIBILITY_NO);
-        valueTextView.setTranslationY(dp(-2));
+        valueTextView.setTranslationY(desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() ? 0 : dp(-2));
         addView(valueTextView);
 
         valueSpoilersTextView = new SimpleTextView(context);
@@ -202,7 +203,15 @@ public class TextCell extends FrameLayout {
             subtitleView.measure(MeasureSpec.makeMeasureSpec(width - dp(71 + leftPadding) - valueWidth, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(dp(20), MeasureSpec.EXACTLY));
         }
         if (imageView.getVisibility() == VISIBLE) {
+            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                imageView.setPadding(0, 0, 0, 0);
+                imageView.setScaleType(ImageView.ScaleType.FIT_CENTER);
+                final boolean autoSizeLottie = inu_m3IconSize == 22 && imageView.getDrawable() instanceof RLottieDrawable;
+                final int iconMeasureSpec = MeasureSpec.makeMeasureSpec(dp(autoSizeLottie ? 48 : inu_m3IconSize), autoSizeLottie ? MeasureSpec.AT_MOST : MeasureSpec.EXACTLY);
+                imageView.measure(iconMeasureSpec, iconMeasureSpec);
+            } else {
             imageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
+            }
         }
         if (valueImageView.getVisibility() == VISIBLE) {
             valueImageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
@@ -265,7 +274,7 @@ public class TextCell extends FrameLayout {
         } else {
             viewLeft = dp(imageView.getVisibility() == VISIBLE ? offsetFromImage : leftPadding);
         }
-        if (subtitleView.getVisibility() == View.VISIBLE) {
+        if (subtitleView.getVisibility() == View.VISIBLE && (!desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() || subtitleView.getTextHeight() > 0)) {
             int margin = heightDp > 50 ? 4 : 2;
             viewTop = (height - textView.getTextHeight() - subtitleView.getTextHeight() - dp(margin)) / 2 + dp(1);
             textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight());
@@ -273,11 +282,18 @@ public class TextCell extends FrameLayout {
             subtitleView.layout(viewLeft, viewTop, viewLeft + subtitleView.getMeasuredWidth(), viewTop + subtitleView.getMeasuredHeight());
         } else {
             viewTop = (height - textView.getTextHeight()) / 2 + dp(1);
+            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                viewTop = (height - textView.getMeasuredHeight()) / 2;
+            }
             textView.layout(viewLeft, viewTop, viewLeft + textView.getMeasuredWidth(), viewTop + textView.getMeasuredHeight());
         }
         if (imageView.getVisibility() == VISIBLE) {
             viewTop = dp(heightDp > 50 ? 0 : 2) + (height - imageView.getMeasuredHeight()) / 2 - imageView.getPaddingTop() + dp(1);
-            viewLeft = !LocaleController.isRTL ? dp(imageLeft) : width - imageView.getMeasuredWidth() - dp(imageLeft);
+            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                viewTop = (height - imageView.getMeasuredHeight()) / 2;
+            }
+            final int inu_imageLeft = desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() && imageLeft == 16 ? 21 : imageLeft;
+            viewLeft = !LocaleController.isRTL ? dp(inu_imageLeft) : width - imageView.getMeasuredWidth() - dp(inu_imageLeft);
             imageView.layout(viewLeft, viewTop, viewLeft + imageView.getMeasuredWidth(), viewTop + imageView.getMeasuredHeight());
         }
 
@@ -822,6 +838,7 @@ public class TextCell extends FrameLayout {
     }
 
     protected int getOffsetFromImage(boolean colourful) {
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) return 60;
         return colourful ? 52 : 58;
     }
 
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextCheckCell.java
@@ -59,7 +59,7 @@ public class TextCheckCell extends FrameLayout {
     private Paint animationPaint;
     private float lastTouchX;
     private ObjectAnimator animator;
-    private boolean drawCheckRipple;
+    public boolean drawCheckRipple;
     private int padding;
     private Theme.ResourcesProvider resourcesProvider;
     ImageView imageView;
@@ -149,6 +149,10 @@ public class TextCheckCell extends FrameLayout {
         if (isMultiline) {
             super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
         } else {
+            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 72 : (height == 50 ? 56 : height)) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
+                return;
+            }
             super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(valueTextView.getVisibility() == VISIBLE ? 64 : height) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
         }
     }
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextDetailSettingsCell.java
@@ -36,6 +36,8 @@ public class TextDetailSettingsCell extends FrameLayout {
     public TextDetailSettingsCell(Context context) {
         super(context);
 
+        final int inu_topOffset = desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() ? 4 : 0;
+
         textView = new TextView(context);
         textView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteBlackText));
         textView.setTextSize(TypedValue.COMPLEX_UNIT_DIP, 16);
@@ -44,7 +46,7 @@ public class TextDetailSettingsCell extends FrameLayout {
         textView.setSingleLine(true);
         textView.setEllipsize(TextUtils.TruncateAt.END);
         textView.setGravity((LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.CENTER_VERTICAL);
-        addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 10, 21, 0));
+        addView(textView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 10 + inu_topOffset, 21, 0));
 
         valueTextView = new TextView(context);
         valueTextView.setTextColor(Theme.getColor(Theme.key_windowBackgroundWhiteGrayText2));
@@ -54,7 +56,7 @@ public class TextDetailSettingsCell extends FrameLayout {
         valueTextView.setMaxLines(1);
         valueTextView.setSingleLine(true);
         valueTextView.setPadding(0, 0, 0, 0);
-        addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 35, 21, 0));
+        addView(valueTextView, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, LayoutHelper.WRAP_CONTENT, (LocaleController.isRTL ? Gravity.RIGHT : Gravity.LEFT) | Gravity.TOP, 21, 35 + inu_topOffset, 21, 0));
 
         imageView = new ImageView(context);
         imageView.setScaleType(ImageView.ScaleType.CENTER);
@@ -66,7 +68,7 @@ public class TextDetailSettingsCell extends FrameLayout {
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
         if (!multiline) {
-            super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(64) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
+            super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(AndroidUtilities.dp(desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() ? 72 : 64) + (needDivider ? 1 : 0), MeasureSpec.EXACTLY));
         } else {
             super.onMeasure(MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(0, MeasureSpec.UNSPECIFIED));
         }
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/TextSettingsCell.java
@@ -120,7 +120,7 @@ public class TextSettingsCell extends FrameLayout {
 
     @Override
     protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
-        setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(50) + (needDivider ? 1 : 0));
+        setMeasuredDimension(MeasureSpec.getSize(widthMeasureSpec), AndroidUtilities.dp(desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() ? 56 : 50) + (needDivider ? 1 : 0));
 
         int availableWidth = getMeasuredWidth() - getPaddingLeft() - getPaddingRight() - AndroidUtilities.dp(34);
         int width = betterLayout ? availableWidth : availableWidth / 2;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChannelBoostLayout.java b/TMessagesProj/src/main/java/org/telegram/ui/ChannelBoostLayout.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChannelBoostLayout.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChannelBoostLayout.java
@@ -137,10 +137,12 @@ public class ChannelBoostLayout extends FrameLayout {
                 case HEADER_VIEW_TYPE:
                     view = new ChartHeaderView(getContext());
                     view.setPadding(view.getPaddingLeft(), AndroidUtilities.dp(16), view.getRight(), AndroidUtilities.dp(16));
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(view, false, true);
                     break;
                 case HEADER_VIEW_TYPE_SMALL:
                     view = new ChartHeaderView(getContext());
                     view.setPadding(view.getPaddingLeft(), AndroidUtilities.dp(16), view.getRight(), AndroidUtilities.dp(8));
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(view, false, true);
                     break;
                 case HEADER_VIEW_TYPE_TABS:
                     boostsTabs = new ScrollSlidingTextTabStrip(fragment.getContext(), resourcesProvider);
@@ -151,6 +153,7 @@ public class ChannelBoostLayout extends FrameLayout {
                         @Override
                         protected void dispatchDraw(Canvas canvas) {
                             super.dispatchDraw(canvas);
+                            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) return;
                             dividerPaint.setColor(Theme.getColor(Theme.key_windowBackgroundGray, resourcesProvider));
                             canvas.drawRect(0, getHeight() - 2, getWidth(), getHeight(), dividerPaint);
                         }
@@ -173,6 +176,7 @@ public class ChannelBoostLayout extends FrameLayout {
                         }
                     });
                     frameLayoutWrapper.addView(boostsTabs, LayoutHelper.createFrame(LayoutHelper.WRAP_CONTENT, 48));
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(frameLayoutWrapper, false, true);
                     view = frameLayoutWrapper;
                     break;
                 case SHOW_BOOST_BY_GIFTS:
@@ -263,6 +267,7 @@ public class ChannelBoostLayout extends FrameLayout {
                 userCell.setData(user, ContactsController.formatName(user), str, 0, !items.get(position).isLast);
                 userCell.setStatus(booster);
                 userCell.setAvatarPadding(5);
+                desu.inugram.helpers.theme.M3SectionsHelper.markMerged(userCell, true, true);
             } else if (holder.getItemViewType() == DIVIDER_TEXT_VIEW_TYPE) {
                 TextInfoPrivacyCell privacyCell = (TextInfoPrivacyCell) holder.itemView;
                 privacyCell.setText(items.get(position).title);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatRightsEditActivity.java
@@ -1918,6 +1918,9 @@ public class ChatRightsEditActivity extends BaseFragment implements Notification
                 case VIEW_TYPE_HEADER_CELL:
                     view = new HeaderCell(mContext, Theme.key_windowBackgroundWhiteBlueHeader, 21, 15, true);
                     view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
+                    if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                        desu.inugram.helpers.theme.M3SectionsHelper.styleHeaderCell((HeaderCell) view);
+                    }
                     break;
                 case VIEW_TYPE_EXPANDABLE_SWITCH:
                 case VIEW_TYPE_SWITCH_CELL:
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ChatUsersActivity.java
@@ -3740,6 +3740,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
                     } else {
                         checkCell.setIcon(0);
                     }
+                    if (position == sendMediaRow && desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                        desu.inugram.helpers.theme.M3SectionsHelper.markMerged(checkCell, false, sendMediaExpanded);
+                    }
                     break;
                 case 8:
                     GraySectionCell sectionCell = (GraySectionCell) holder.itemView;
@@ -3815,6 +3818,9 @@ public class ChatUsersActivity extends BaseFragment implements NotificationCente
                     } else
                     //  checkBoxCell.setText(getCheckBoxTitle(item.headerName, percents[item.index < 0 ? 8 : item.index], item.index < 0), AndroidUtilities.formatFileSize(item.size), selected, item.index < 0 ? !collapsed : !item.last);
                     checkBoxCell.setPad(1);
+                    if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                        desu.inugram.helpers.theme.M3SectionsHelper.markMerged(checkBoxCell, true, isExpandableSendMediaRow(position + 1));
+                    }
                     break;
                 case VIEW_TYPE_CHECK:
                     TextCheckCell checkCell2 = (TextCheckCell) holder.itemView;
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/ItemOptions.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/ItemOptions.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/ItemOptions.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/ItemOptions.java
@@ -1266,6 +1266,13 @@ public class ItemOptions {
             scrimBlur3SourceBitmap = new BlurredBackgroundSourceBitmap();
         }
 
+        if (scrimViewBackground == null && scrimView != null && scrimView.getParent() instanceof RecyclerListView) {
+            final RecyclerListView listView = (RecyclerListView) scrimView.getParent();
+            if (listView.hasSections()) {
+                scrimViewBackground = listView.getClipBackground(scrimView);
+            }
+        }
+
         ViewGroup container = pointContainer = this.container == null ? fragment.getParentLayout().getOverlayContainerView() : this.container;
 
         if (context == null || container == null) {
@@ -2152,6 +2159,7 @@ public class ItemOptions {
                     } else {
                         canvas.save();
                     }
+                    desu.inugram.helpers.theme.M3SectionsHelper.applyScrimClip(canvas, scrimView);
                     if (scrimView instanceof ScrimView) {
                         ((ScrimView) scrimView).drawScrim(canvas, dimProgress);
                     } else {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/RecyclerListView.java
@@ -214,7 +214,7 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
 
     protected Consumer<Canvas> selectorTransformer;
 
-    protected final Theme.ResourcesProvider resourcesProvider;
+    public final Theme.ResourcesProvider resourcesProvider;
 
     private boolean accessibilityEnabled = true;
 
@@ -2679,15 +2679,20 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
 
     @Override
     public boolean drawChild(Canvas canvas, View child, long drawingTime) {
+        final boolean inu_m3 = hasSections() && desu.inugram.helpers.theme.M3SectionsHelper.isEnabled();
+        final int inu_oldDividerAlpha = inu_m3 ? Theme.dividerPaint.getAlpha() : 0;
+        if (inu_m3) Theme.dividerPaint.setAlpha(0);
+        final boolean r;
         if (hasSections() && !ignoreClipChild) {
             canvas.save();
             clipChild(canvas, child);
-            boolean r = super.drawChild(canvas, child, drawingTime);
+            r = super.drawChild(canvas, child, drawingTime);
             canvas.restore();
-            return r;
         } else {
-            return super.drawChild(canvas, child, drawingTime);
+            r = super.drawChild(canvas, child, drawingTime);
         }
+        if (inu_m3) Theme.dividerPaint.setAlpha(inu_oldDividerAlpha);
+        return r;
     }
 
     @Override
@@ -3257,12 +3262,12 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
         return sectionsItemDecoration != null;
     }
 
-    private ListSectionsDecoration sectionsItemDecoration;
+    public ListSectionsDecoration sectionsItemDecoration;
     private Utilities.CallbackReturn<Integer, Boolean> isViewTypeSection;
     private Utilities.Callback5<Canvas, RectF, Float, Float, Float> drawSectionBackground;
     public ArrayList<Long> forcedSections;
-    private float sectionRadius;
-    private float[] sectionRadiusTop, sectionRadiusBottom;
+    public float sectionRadius;
+    public float[] sectionRadiusTop, sectionRadiusBottom;
     public boolean applyPaddingToSections = false;
 
     public static final int TAG_NOT_SECTION = -33024;
@@ -3288,7 +3293,7 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
     }
     public void setSections(int padding, float roundRadius, boolean topPadding) {
         setSections(
-            view -> !(view instanceof TextInfoPrivacyCell || view instanceof ShadowSectionCell || view instanceof FiltersSetupActivity.HintInnerCell || view instanceof GraySectionCell || view instanceof CollapseTextCell) && !Objects.equals(view.getTag(), TAG_NOT_SECTION),
+            view -> !(view instanceof TextInfoPrivacyCell || view instanceof ShadowSectionCell || view instanceof FiltersSetupActivity.HintInnerCell || view instanceof GraySectionCell || view instanceof CollapseTextCell) && !(desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() && view instanceof org.telegram.ui.Cells.HeaderCell) && !Objects.equals(view.getTag(), TAG_NOT_SECTION),
             padding,
             roundRadius,
             this::drawBackgroundRect,
@@ -3405,6 +3410,9 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
                         if (last) outRect.bottom = padding;
                     }
                 }
+                if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                    desu.inugram.helpers.theme.M3SectionsHelper.augmentItemOffsets(outRect, parent, view);
+                }
             }
         }
 
@@ -3476,6 +3484,11 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
     public void drawSectionsBackgrounds(Canvas canvas) {
         if (drawSectionBackground == null) return;
 
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+            desu.inugram.helpers.theme.M3SectionsHelper.drawSectionsBackgrounds(canvas, this);
+            return;
+        }
+
         if (isAnimating()) {
             if (sections == null) {
                 sections = new ArrayList<>();
@@ -3622,6 +3635,11 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
         if (child == null || !sectionsItemDecoration.isSectionItem.run(child))
             return;
 
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+            desu.inugram.helpers.theme.M3SectionsHelper.clipChild(canvas, child, this);
+            return;
+        }
+
         boolean prev, next;
         int position = getChildAdapterPosition(child);
         if (position == RecyclerView.NO_POSITION) {
@@ -3682,6 +3700,11 @@ public class RecyclerListView extends RecyclerView implements IBlur3Capture {
     public Drawable getClipBackground(View child, boolean forceRound) {
         if (child.getParent() != this || !hasSections() || !sectionsItemDecoration.isSectionItem.run(child)) return null;
 
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+            final Drawable m3 = desu.inugram.helpers.theme.M3SectionsHelper.makeClipBackground(this, child);
+            if (m3 != null) return m3;
+        }
+
         boolean prev, next;
         int position = getChildAdapterPosition(child);
         if (position == RecyclerView.NO_POSITION) {
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 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/UniversalAdapter.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/UniversalAdapter.java
@@ -590,12 +590,14 @@ public class UniversalAdapter extends AdapterWithDiffUtils {
     }
 
     private boolean hasDivider(int position) {
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() && listView != null && listView.hasSections()) return false;
         UItem item = getItem(position);
         UItem nextItem = getItem(position + 1);
         return item != null && !item.hideDivider && nextItem != null && isShadow(nextItem.viewType) == isShadow(item.viewType);
     }
 
     public static boolean isShadow(int viewType) {
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() && desu.inugram.helpers.theme.M3SectionsHelper.isHeaderViewType(viewType)) return true;
         if (viewType >= UItem.factoryViewTypeStartsWith) {
             UItem.UItemFactory<?> factory = UItem.findFactory(viewType);
             return factory != null && factory.isShadow();
@@ -621,6 +623,13 @@ public class UniversalAdapter extends AdapterWithDiffUtils {
         final int viewType = holder.getItemViewType();
         final boolean divider = hasDivider(position);
         updateColors(holder);
+        if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+            desu.inugram.helpers.theme.M3SectionsHelper.markMerged(
+                holder.itemView,
+                item.pad > 0,
+                nextItem != null && nextItem.pad > 0
+            );
+        }
         if (viewType >= UItem.factoryViewTypeStartsWith) {
             UItem.UItemFactory<?> factory = UItem.findFactory(viewType);
             if (factory != null) {
@@ -632,6 +641,9 @@ public class UniversalAdapter extends AdapterWithDiffUtils {
             case VIEW_TYPE_LARGE_HEADER:
                 ((HeaderCell) holder.itemView).setText(item.text);
                 ((HeaderCell) holder.itemView).setEnabled(item.enabled, true);
+                if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled() && listView != null && listView.hasSections()) {
+                    desu.inugram.helpers.theme.M3SectionsHelper.styleHeaderCell((HeaderCell) holder.itemView);
+                }
                 break;
             case VIEW_TYPE_ANIMATED_HEADER:
                 HeaderCell animatedHeaderCell = (HeaderCell) holder.itemView;
@@ -753,7 +765,7 @@ public class UniversalAdapter extends AdapterWithDiffUtils {
                 if (viewType == VIEW_TYPE_SHADOW || viewType == VIEW_TYPE_LARGE_SHADOW) {
                     TextInfoPrivacyCell cell2 = (TextInfoPrivacyCell) holder.itemView;
                     if (TextUtils.isEmpty(item.text)) {
-                        cell2.setFixedSize(viewType == VIEW_TYPE_LARGE_SHADOW ? 220 : 12);
+                        cell2.setFixedSize(viewType == VIEW_TYPE_LARGE_SHADOW ? 220 : desu.inugram.helpers.theme.M3SectionsHelper.shadowHeightDp(nextItem, 12));
                         cell2.setText("");
                     } else {
                         cell2.setFixedSize(0);
@@ -1135,6 +1147,7 @@ public class UniversalAdapter extends AdapterWithDiffUtils {
                 viewType == VIEW_TYPE_ICON_TEXT_CHECK ||
                 viewType == VIEW_TYPE_RIGHT_ICON_TEXT ||
                 viewType == VIEW_TYPE_CHECK ||
+                viewType == VIEW_TYPE_CHECKRIPPLE ||
                 viewType == VIEW_TYPE_RADIO ||
                 viewType == VIEW_TYPE_RADIO_2 ||
                 viewType == VIEW_TYPE_FILTER_CHAT ||
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LiteModeSettingsActivity.java
@@ -405,6 +405,13 @@ public class LiteModeSettingsActivity extends BaseFragment {
                 final boolean divider = position + 1 < items.size() && items.get(position + 1).viewType != VIEW_TYPE_INFO;
                 SwitchCell switchCell = (SwitchCell) holder.itemView;
                 switchCell.set(item, divider);
+                if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                    desu.inugram.helpers.theme.M3SectionsHelper.markMerged(
+                        switchCell,
+                        viewType == VIEW_TYPE_CHECKBOX,
+                        position + 1 < items.size() && items.get(position + 1).viewType == VIEW_TYPE_CHECKBOX
+                    );
+                }
             } else if (viewType == VIEW_TYPE_SWITCH2) {
                 TextCell textCell = (TextCell) holder.itemView;
                 if (item.type == SWITCH_TYPE_SMOOTH_TRANSITIONS) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/PeerColorActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/PeerColorActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/PeerColorActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/PeerColorActivity.java
@@ -2291,10 +2291,13 @@ public class PeerColorActivity extends BaseFragment implements NotificationCente
 
         @Override
         protected void dispatchDraw(Canvas canvas) {
-            DrawableUtils.setBounds(drawable, rtl(dp(28)), getMeasuredHeight() / 2f, Gravity.CENTER);
+            final boolean m3 = desu.inugram.helpers.theme.M3SectionsHelper.isEnabled();
+            final int iconCenter = m3 ? dp(31) : dp(28);
+            final int textInset = m3 ? dp(60) : dp(58);
+            DrawableUtils.setBounds(drawable, rtl(iconCenter), getMeasuredHeight() / 2f, Gravity.CENTER);
             drawable.draw(canvas);
-            buttonText.ellipsize(getMeasuredWidth() - dp(64 + 7 + 100) - (lock != null ? lock.getIntrinsicWidth() + dp(8) : 0));
-            float textX = LocaleController.isRTL ? getMeasuredWidth() - buttonText.getWidth() - dp(58) : dp(58);
+            buttonText.ellipsize(getMeasuredWidth() - (m3 ? textInset + dp(100) : dp(64 + 7 + 100)) - (lock != null ? lock.getIntrinsicWidth() + dp(8) : 0));
+            float textX = LocaleController.isRTL ? getMeasuredWidth() - buttonText.getWidth() - textInset : textInset;
             buttonText.draw(canvas, textX, getMeasuredHeight() / 2f);
             if (lock != null) {
                 int x = (int) (textX + buttonText.getWidth() + dp(6));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ProxyListActivity.java
@@ -1008,27 +1008,22 @@ public class ProxyListActivity extends BaseFragment implements NotificationCente
                     break;
                 case VIEW_TYPE_TEXT_SETTING:
                     view = new TextSettingsCell(mContext);
-                    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
                     break;
                 case VIEW_TYPE_HEADER:
                     view = new HeaderCell(mContext);
-                    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
                     break;
                 case VIEW_TYPE_TEXT_CHECK:
                     view = new TextCheckCell(mContext);
-                    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
                     break;
                 case VIEW_TYPE_INFO:
                     view = new TextInfoPrivacyCell(mContext);
                     break;
                 case VIEW_TYPE_SLIDE_CHOOSER:
                     view = new SlideChooseView(mContext);
-                    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
                     break;
                 case VIEW_TYPE_PROXY_DETAIL:
                 default:
                     view = new TextDetailProxyCell(mContext);
-                    view.setBackgroundColor(Theme.getColor(Theme.key_windowBackgroundWhite));
                     break;
             }
             view.setLayoutParams(new RecyclerView.LayoutParams(RecyclerView.LayoutParams.MATCH_PARENT, RecyclerView.LayoutParams.WRAP_CONTENT));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/SettingsActivity.java
@@ -1195,6 +1195,8 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
             titleView.setTranslationX(icon == 0 ? dp(2) : 0);
             subtitleView.setTranslationX(icon == 0 ? dp(2) : 0);
 
+            desu.inugram.helpers.theme.M3SectionsHelper.applySettingCellIcon(iconLayout, iconView, iconColorTop, iconColorBottom, iconBackground);
+
             iconBackground.setColor(iconColorTop, iconColorBottom);
             iconView.setImageResource(icon);
             titleView.setText(title);
@@ -1210,6 +1212,13 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
 
         @Override
         protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
+            if (desu.inugram.helpers.theme.M3SectionsHelper.isEnabled()) {
+                super.onMeasure(
+                    MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY),
+                    MeasureSpec.makeMeasureSpec(dp(twoLines ? 64 : 52), MeasureSpec.EXACTLY)
+                );
+                return;
+            }
             super.onMeasure(
                 MeasureSpec.makeMeasureSpec(MeasureSpec.getSize(widthMeasureSpec), MeasureSpec.EXACTLY),
                 MeasureSpec.makeMeasureSpec(dp(mini ? 44 : twoLines ? 60 : 50), MeasureSpec.EXACTLY)
@@ -1238,8 +1247,17 @@ public class SettingsActivity extends BaseFragment implements NotificationCenter
                 this.border = drawBorder;
             }
 
+            public int inu_monetColor;
+
             @Override
             public void draw(@NonNull Canvas canvas) {
+                if (inu_monetColor != 0) {
+                    paint.setShader(null);
+                    paint.setColor(inu_monetColor);
+                    Rect b = getBounds();
+                    canvas.drawCircle(b.exactCenterX(), b.exactCenterY(), Math.min(b.width(), b.height()) / 2f, paint);
+                    return;
+                }
                 final float r = dp(10);
                 AndroidUtilities.rectTmp.set(getBounds());
                 matrix.reset();
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/StatisticActivity.java
@@ -1287,6 +1287,7 @@ public class StatisticActivity extends BaseFragment implements NotificationCente
                 };
                 headerCell.setWillNotDraw(false);
                 headerCell.setPadding(headerCell.getPaddingLeft(), dp(16), headerCell.getRight(), dp(16));
+                desu.inugram.helpers.theme.M3SectionsHelper.markMerged(headerCell, false, true);
                 v = headerCell;
             } else if (viewType == 14) {
                 v = new OverviewCell(parent.getContext(), isMegagroup ? 2 : 4);
