From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: alina sireneva <alina@tei.su>
Date: Thu, 21 May 2026 02:21:56 +0400
Subject: support patch for material 3 stylized switches and fabs

---
 .../java/org/telegram/ui/Cells/AvailableReactionCell.java | 2 +-
 .../main/java/org/telegram/ui/Cells/CheckBoxUserCell.java | 2 +-
 .../src/main/java/org/telegram/ui/Cells/TextCell.java     | 2 +-
 .../telegram/ui/Components/FragmentFloatingButton.java    | 4 ++--
 .../src/main/java/org/telegram/ui/Components/Switch.java  | 8 ++++++++
 5 files changed, 13 insertions(+), 5 deletions(-)

diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/AvailableReactionCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/AvailableReactionCell.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/AvailableReactionCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/AvailableReactionCell.java
@@ -69,7 +69,7 @@ public class AvailableReactionCell extends FrameLayout {
         } else {
             switchView = new Switch(context);
             switchView.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_switchTrackBlueThumb, Theme.key_switchTrackBlueThumbChecked);
-            addView(switchView, LayoutHelper.createFrameRelatively(37, 20, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 22, 0));
+            addView(switchView, LayoutHelper.createFrameRelatively(37, desu.inugram.InuConfig.MATERIAL3_SWITCHES.getValue() ? 24 : 20, Gravity.END | Gravity.CENTER_VERTICAL, 0, 0, 22, 0));
         }
         overlaySelectorView = new View(context);
         overlaySelectorView.setBackground(Theme.getSelectorDrawable(false));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Cells/CheckBoxUserCell.java b/TMessagesProj/src/main/java/org/telegram/ui/Cells/CheckBoxUserCell.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Cells/CheckBoxUserCell.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Cells/CheckBoxUserCell.java
@@ -53,7 +53,7 @@ public class CheckBoxUserCell extends FrameLayout {
 
         checkBox = new Switch(context, null);
         checkBox.setColors(Theme.key_switchTrack, Theme.key_switchTrackChecked, Theme.key_windowBackgroundWhite, Theme.key_windowBackgroundWhite);
-        addView(checkBox, LayoutHelper.createFrame(37, 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
+        addView(checkBox, LayoutHelper.createFrame(37, desu.inugram.InuConfig.MATERIAL3_SWITCHES.getValue() ? 24 : 20, (LocaleController.isRTL ? Gravity.LEFT : Gravity.RIGHT) | Gravity.CENTER_VERTICAL, 22, 0, 22, 0));
     }
 
     @Override
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
@@ -208,7 +208,7 @@ public class TextCell extends FrameLayout {
             valueImageView.measure(MeasureSpec.makeMeasureSpec(width, MeasureSpec.AT_MOST), MeasureSpec.makeMeasureSpec(height, MeasureSpec.AT_MOST));
         }
         if (checkBox != null) {
-            checkBox.measure(MeasureSpec.makeMeasureSpec(dp(37), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(dp(20), MeasureSpec.EXACTLY));
+            checkBox.measure(MeasureSpec.makeMeasureSpec(dp(37), MeasureSpec.EXACTLY), MeasureSpec.makeMeasureSpec(dp(desu.inugram.InuConfig.MATERIAL3_SWITCHES.getValue() ? 24 : 20), MeasureSpec.EXACTLY));
         }
         setMeasuredDimension(width, height + (needDivider ? 1 : 0));
     }
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentFloatingButton.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentFloatingButton.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentFloatingButton.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/FragmentFloatingButton.java
@@ -70,7 +70,7 @@ public class FragmentFloatingButton extends FrameLayout implements FactorAnimato
 
         ScaleStateListAnimator.apply(this);
         if (!isSubButton) {
-            setOutlineProvider(ViewOutlineProviderImpl.BOUNDS_OVAL);
+            setOutlineProvider(desu.inugram.helpers.theme.M3FabHelper.outlineProvider());
             setTranslationZ(dpf2(0.5f));
         }
 
@@ -163,7 +163,7 @@ public class FragmentFloatingButton extends FrameLayout implements FactorAnimato
         } else {
             imageView.setColorFilter(Theme.getColor(Theme.key_chats_actionIcon, resourcesProvider), PorterDuff.Mode.SRC_IN);
             progressView.setProgressColor(Theme.getColor(Theme.key_chats_actionIcon, resourcesProvider));
-            setBackground(Theme.createSimpleSelectorCircleDrawable(dp(48),
+            setBackground(desu.inugram.helpers.theme.M3FabHelper.makeSelectorBackground(48,
                 Theme.getColor(Theme.key_featuredStickers_addButton, resourcesProvider),
                 Theme.getColor(Theme.key_featuredStickers_addButtonPressed, resourcesProvider)
             ));
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java b/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/Components/Switch.java
@@ -236,6 +236,9 @@ public class Switch extends View {
     private void animateToCheckedState(boolean newCheckedState) {
         checkAnimator = ObjectAnimator.ofFloat(this, "progress", newCheckedState ? 1 : 0);
         checkAnimator.setDuration(200);
+        if (desu.inugram.InuConfig.MATERIAL3_SWITCHES.getValue()) {
+            checkAnimator.setInterpolator(new android.view.animation.OvershootInterpolator(1.4f));
+        }
         checkAnimator.addListener(new AnimatorListenerAdapter() {
             @Override
             public void onAnimationEnd(Animator animation) {
@@ -377,6 +380,11 @@ public class Switch extends View {
             return;
         }
 
+        if (desu.inugram.InuConfig.MATERIAL3_SWITCHES.getValue()) {
+            desu.inugram.helpers.theme.M3SwitchHelper.draw(getMeasuredWidth(), getMeasuredHeight(), progress, isChecked, drawIconType, iconProgress, iconDrawable, animatorIconVisibility.getFloatValue(), trackColorKey, trackCheckedColorKey, thumbCheckedColorKey, resourcesProvider, canvas);
+            return;
+        }
+
         int width = AndroidUtilities.dp(31);
         int thumb = AndroidUtilities.dp(20);
         int x = (getMeasuredWidth() - width) / 2;
