From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: alina sireneva <alina@tei.su>
Date: Tue, 12 May 2026 00:00:00 +0000
Subject: Use DialogsActivity as root fragment when old layout is enabled

Restore hamburger side drawer for old layout mode (DrawerLayoutContainer)

Restore hamburger side drawer for old layout mode (DialogsActivity)
---
 .../ui/ActionBar/DrawerLayoutContainer.java   | 38 +++++++++++++++++--
 .../java/org/telegram/ui/DialogsActivity.java | 25 ++++++++++--
 .../java/org/telegram/ui/LaunchActivity.java  | 32 ++++++----------
 .../java/org/telegram/ui/LoginActivity.java   |  9 ++---
 .../ui/TwoStepVerificationActivity.java       |  5 +--
 .../ui/TwoStepVerificationSetupActivity.java  | 10 ++---
 6 files changed, 75 insertions(+), 44 deletions(-)

diff --git a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/ActionBar/DrawerLayoutContainer.java
@@ -28,7 +28,7 @@ import org.telegram.messenger.FileLog;
 
 public class DrawerLayoutContainer extends FrameLayout {
 
-    private INavigationLayout parentActionBarLayout;
+    public INavigationLayout parentActionBarLayout;
     private ActionBarLayout actionBarLayout;
     private boolean inLayout;
 
@@ -51,13 +51,26 @@ public class DrawerLayoutContainer extends FrameLayout {
         return false;
     }
 
+    public desu.inugram.ui.drawer.DrawerSwipeController inu_drawer;
+
+    public boolean inu_superDrawChild(@NonNull Canvas canvas, View child, long drawingTime) {
+        return super.drawChild(canvas, child, drawingTime);
+    }
+
     public boolean onTouchEvent(MotionEvent ev) {
+        if (inu_drawer != null) return inu_drawer.onTouchEvent(ev);
         return false;
     }
 
     @Override
     public boolean onInterceptTouchEvent(MotionEvent ev) {
-        return parentActionBarLayout.checkTransitionAnimation();
+        return parentActionBarLayout.checkTransitionAnimation() || onTouchEvent(ev);
+    }
+
+    @Override
+    public void requestDisallowInterceptTouchEvent(boolean disallowIntercept) {
+        if (inu_drawer != null) inu_drawer.onParentDisallowIntercept();
+        super.requestDisallowInterceptTouchEvent(disallowIntercept);
     }
 
     @Override
@@ -73,7 +86,11 @@ public class DrawerLayoutContainer extends FrameLayout {
 
             final LayoutParams lp = (LayoutParams) child.getLayoutParams();
             try {
-                child.layout(lp.leftMargin, lp.topMargin + getPaddingTop(), lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight() + getPaddingTop());
+                if (inu_drawer != null && inu_drawer.isDrawerChild(child)) {
+                    child.layout(-child.getMeasuredWidth(), lp.topMargin + getPaddingTop(), 0, lp.topMargin + child.getMeasuredHeight() + getPaddingTop());
+                } else {
+                    child.layout(lp.leftMargin, lp.topMargin + getPaddingTop(), lp.leftMargin + child.getMeasuredWidth(), lp.topMargin + child.getMeasuredHeight() + getPaddingTop());
+                }
             } catch (Exception e) {
                 FileLog.e(e);
                 if (BuildVars.DEBUG_VERSION) {
@@ -119,7 +136,12 @@ public class DrawerLayoutContainer extends FrameLayout {
 
             final LayoutParams lp = (LayoutParams) child.getLayoutParams();
 
-            final int contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY);
+            final int contentWidthSpec;
+            if (inu_drawer != null && inu_drawer.isDrawerChild(child)) {
+                contentWidthSpec = MeasureSpec.makeMeasureSpec(lp.width > 0 ? lp.width : widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY);
+            } else {
+                contentWidthSpec = MeasureSpec.makeMeasureSpec(widthSize - lp.leftMargin - lp.rightMargin, MeasureSpec.EXACTLY);
+            }
             final int contentHeightSpec;
             if (lp.height > 0) {
                 contentHeightSpec = MeasureSpec.makeMeasureSpec(lp.height, MeasureSpec.EXACTLY);
@@ -137,6 +159,14 @@ public class DrawerLayoutContainer extends FrameLayout {
         }
     }
 
+    @Override
+    protected boolean drawChild(@NonNull Canvas canvas, View child, long drawingTime) {
+        if (inu_drawer != null) {
+            return inu_drawer.drawChild(canvas, child, drawingTime);
+        }
+        return super.drawChild(canvas, child, drawingTime);
+    }
+
     @Override
     protected void dispatchDraw(@NonNull Canvas canvas) {
         if (actionBarLayout != null && actionBarLayout.getParent() == this) {
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/DialogsActivity.java
@@ -525,7 +525,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
     private ChatAvatarContainer avatarContainer;
     private int undoViewIndex;
     private UndoView[] undoView = new UndoView[2];
-    private FilterTabsView filterTabsView;
+    public FilterTabsView filterTabsView;
     private boolean askingForPermissions;
     private int searchViewPagerIndex;
     @Nullable
@@ -740,7 +740,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
     private Bulletin topBulletin;
 
     private AnimationNotificationsLocker notificationsLocker = new AnimationNotificationsLocker();
-    private boolean searchIsShowed;
+    public boolean searchIsShowed;
     private boolean searchWasFullyShowed;
     public boolean whiteActionBar;
     private boolean searchFiltersWasShowed;
@@ -3480,7 +3480,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
         });
         fragmentSearchFieldWatcher.setDoNotCloseAfterFieldEmpty();
 
-        if (initialDialogsType == DIALOGS_TYPE_DEFAULT) {
+        if (initialDialogsType == DIALOGS_TYPE_DEFAULT && !(desu.inugram.InuConfig.NAVIGATION_DRAWER.getValue() && !isArchive() && communityId == 0)) {
             optionsItem = menu.addItem(4, R.drawable.ic_ab_other);
             optionsItem.setContentDescription(LocaleController.getString(R.string.AccDescrMoreOptions));
             optionsItem.setOnClickListener(v -> {
@@ -3541,6 +3541,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
         } else {
             if (searchString != null || folderId != 0 || communityId != 0) {
                 actionBar.setBackButtonDrawable(backDrawable = new BackDrawable(false));
+            } else if (!hasMainTabs && desu.inugram.InuConfig.NAVIGATION_DRAWER.getValue()) {
+                org.telegram.ui.ActionBar.MenuDrawable menuDrawable = new org.telegram.ui.ActionBar.MenuDrawable();
+                menuDrawable.setRoundCap();
+                actionBar.setBackButtonDrawable(menuDrawable);
+                desu.inugram.helpers.dialogs.DrawerHelper.refreshMenuButton(menuDrawable, false);
             }
             if (folderId != 0) {
                 actionBar.setTitle(getString(R.string.ArchivedChats));
@@ -3919,6 +3924,11 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
                     return;
                 }
                 if (id == -1) {
+                    if (!hasMainTabs && !actionBar.isActionModeShowed() && desu.inugram.InuConfig.NAVIGATION_DRAWER.getValue()
+                            && folderId == 0 && communityId == 0 && searchString == null
+                            && desu.inugram.helpers.dialogs.DrawerHelper.INSTANCE.toggleDrawer(parentLayout)) {
+                        return;
+                    }
                     if (rightSlidingDialogContainer != null && rightSlidingDialogContainer.hasFragment()) {
                         if (actionBar.isActionModeShowed()) {
                             if (searchViewPager != null && searchViewPager.getVisibility() == View.VISIBLE && searchViewPager.actionModeShowing()) {
@@ -5379,7 +5389,7 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
             }
         };
         dialogStoriesCell.setActionBar(actionBar);
-        dialogStoriesCell.setMenuItemsOffset(isArchive() ? dp(68) : dpf2(16.66f));
+        dialogStoriesCell.setMenuItemsOffset(isArchive() || desu.inugram.InuConfig.NAVIGATION_DRAWER.getValue() ? dp(68) : dpf2(16.66f));
         dialogStoriesCell.allowGlobalUpdates = false;
         dialogStoriesCell.setVisibility(View.GONE);
         animateToHasStories = false;
@@ -5938,6 +5948,9 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
             yoff = -(actionBar.getHeight() - AndroidUtilities.rectTmp2.centerY()) - dp(16);
             xoff = AndroidUtilities.rectTmp2.centerX() - dp(16);
             xoff += dp(4);
+            if (!hasMainTabs && desu.inugram.InuConfig.NAVIGATION_DRAWER.getValue()) {
+                xoff -= dp(4);
+            }
             if (animatedStatusView != null) {
                 animatedStatusView.translate(AndroidUtilities.rectTmp2.centerX(), AndroidUtilities.rectTmp2.centerY());
             }
@@ -9141,6 +9154,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
         selectedDialogs.clear();
         if (backDrawable != null) {
             backDrawable.setRotation(0, true);
+        } else if (actionBar.getBackButton() != null && actionBar.getBackButton().getDrawable() instanceof MenuDrawable) {
+            ((MenuDrawable) actionBar.getBackButton().getDrawable()).setRotation(0, true);
         }
         if (filterTabsView != null) {
             filterTabsView.animateColorsTo(Theme.key_actionBarTabLine, Theme.key_actionBarTabActiveText, Theme.key_actionBarTabUnactiveText, Theme.key_actionBarTabSelector, Theme.key_windowBackgroundWhite);
@@ -10228,6 +10243,8 @@ public class DialogsActivity extends BaseFragment implements NotificationCenter.
             }
             if (backDrawable != null) {
                 backDrawable.setRotation(1, true);
+            } else if (actionBar.getBackButton() != null && actionBar.getBackButton().getDrawable() instanceof MenuDrawable) {
+                ((MenuDrawable) actionBar.getBackButton().getDrawable()).setRotation(1, true);
             }
         }
         updateCounters(false);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LaunchActivity.java
@@ -598,8 +598,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
             if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
                 actionBarLayout.addFragmentToStack(getClientNotActivatedFragment());
             } else {
-                MainTabsActivity mainTabsActivity = new MainTabsActivity();
-                actionBarLayout.addFragmentToStack(mainTabsActivity);
+                desu.inugram.helpers.dialogs.DrawerHelper.setupMainFragment(this, actionBarLayout, drawerLayoutContainer);
             }
 
             try {
@@ -748,7 +747,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
         final int inuPredictiveMode = desu.inugram.InuConfig.PREDICTIVE_BACK_MODE.getValue();
         if (Build.VERSION.SDK_INT >= 34 && inuPredictiveMode == desu.inugram.InuConfig.PredictiveBackModeItem.MATERIAL3 && actionBarLayout != null) {
             if (onBackAnimationCallback == null) {
-                onBackAnimationCallback = desu.inugram.helpers.theme.Material3PredictiveBack.createCallback(
+                onBackAnimationCallback = desu.inugram.helpers.dialogs.DrawerBackGesture.wrap(this, desu.inugram.helpers.theme.Material3PredictiveBack.createCallback(
                     this,
                     actionBarLayout,
                     () -> {
@@ -759,7 +758,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
                         if (!onBackPressed(true)) return;
                         onBackPressed();
                     }
-                );
+                ));
             }
             getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
                 OnBackInvokedDispatcher.PRIORITY_DEFAULT,
@@ -767,7 +766,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
             );
         } else if (Build.VERSION.SDK_INT >= 34 && inuPredictiveMode == desu.inugram.InuConfig.PredictiveBackModeItem.STOCK) {
             if (onBackAnimationCallback == null) {
-                onBackAnimationCallback =  new OnBackAnimationCallback() {
+                onBackAnimationCallback = desu.inugram.helpers.dialogs.DrawerBackGesture.wrap(this, new OnBackAnimationCallback() {
                     private AnimationNotificationsLocker locker = new AnimationNotificationsLocker();
                     private boolean locked;
 
@@ -850,7 +849,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
                             actionBarLayout.onBackCancelled();
                         }
                     }
-                };
+                });
             }
             getOnBackInvokedDispatcher().registerOnBackInvokedCallback(
                 OnBackInvokedDispatcher.PRIORITY_DEFAULT,
@@ -1221,10 +1220,10 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
 
     private boolean switchingAccount;
     public void switchToAccount(int account, boolean removeAll) {
-        switchToAccount(account, removeAll, obj -> new MainTabsActivity());
+        switchToAccount(account, removeAll, obj -> desu.inugram.helpers.dialogs.DrawerHelper.createMainFragment());
     }
 
-    public void switchToAccount(int account, boolean removeAll, GenericProvider<Void, MainTabsActivity> dialogsActivityProvider) {
+    public void switchToAccount(int account, boolean removeAll, GenericProvider<Void, org.telegram.ui.ActionBar.BaseFragment> dialogsActivityProvider) {
         if (account == UserConfig.selectedAccount || !UserConfig.isValidAccount(account)) {
             return;
         }
@@ -1252,7 +1251,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
         } else {
             actionBarLayout.removeFragmentFromStack(0);
         }
-        MainTabsActivity mainTabsActivity = dialogsActivityProvider.provide(null);
+        org.telegram.ui.ActionBar.BaseFragment mainTabsActivity = dialogsActivityProvider.provide(null);
         actionBarLayout.addFragmentToStack(mainTabsActivity, INavigationLayout.FORCE_ATTACH_VIEW_AS_FIRST);
         actionBarLayout.rebuildFragments(INavigationLayout.REBUILD_FLAG_REBUILD_LAST);
         if (AndroidUtilities.isTablet()) {
@@ -1266,6 +1265,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
             showTosActivity(account, UserConfig.getInstance(account).unacceptedTermsOfService);
         }
         updateCurrentConnectionState(currentAccount);
+        desu.inugram.helpers.dialogs.DrawerHelper.notifyDataChanged();
 
         switchingAccount = false;
     }
@@ -3334,12 +3334,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
                     }
                 } else {
                     if (actionBarLayout.getFragmentStack().isEmpty()) {
-                        MainTabsActivity mainTabsActivity = new MainTabsActivity();
-                        DialogsActivity dialogsActivity = mainTabsActivity.prepareDialogsActivity(null);
-                        if (searchQuery != null) {
-                            dialogsActivity.setInitialSearchString(searchQuery);
-                        }
-                        actionBarLayout.addFragmentToStack(mainTabsActivity, INavigationLayout.FORCE_NOT_ATTACH_VIEW);
+                        desu.inugram.helpers.dialogs.DrawerHelper.addMainFragmentToStack(actionBarLayout, searchQuery);
                     }
                 }
             } else {
@@ -3347,12 +3342,7 @@ public class LaunchActivity extends BasePermissionsActivity implements INavigati
                     if (!UserConfig.getInstance(currentAccount).isClientActivated()) {
                         actionBarLayout.addFragmentToStack(getClientNotActivatedFragment(), INavigationLayout.FORCE_NOT_ATTACH_VIEW);
                     } else {
-                        MainTabsActivity mainTabsActivity = new MainTabsActivity();
-                        DialogsActivity dialogsActivity = mainTabsActivity.prepareDialogsActivity(null);
-                        if (searchQuery != null) {
-                            dialogsActivity.setInitialSearchString(searchQuery);
-                        }
-                        actionBarLayout.addFragmentToStack(mainTabsActivity, INavigationLayout.FORCE_NOT_ATTACH_VIEW);
+                        desu.inugram.helpers.dialogs.DrawerHelper.addMainFragmentToStack(actionBarLayout, searchQuery);
                     }
                 }
             }
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/LoginActivity.java
@@ -1601,9 +1601,7 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
                 ((LaunchActivity) getParentActivity()).switchToAccount(currentAccount, true, obj -> {
                     Bundle args = new Bundle();
                     args.putBoolean("afterSignup", afterSignup);
-                    MainTabsActivity mainTabsActivity = new MainTabsActivity();
-                    mainTabsActivity.prepareDialogsActivity(args);
-                    return mainTabsActivity;
+                    return desu.inugram.helpers.dialogs.DrawerHelper.createMainFragment(args);
                 });
                 pendingSwitchingAccount = false;
                 finishFragment();
@@ -1616,9 +1614,8 @@ public class LoginActivity extends BaseFragment implements NotificationCenter.No
                 } else {
                     Bundle args = new Bundle();
                     args.putBoolean("afterSignup", afterSignup);
-                    MainTabsActivity mainTabsActivity = new MainTabsActivity();
-                    mainTabsActivity.prepareDialogsActivity(args);
-                    presentFragment(mainTabsActivity, true);
+                    desu.inugram.helpers.dialogs.DrawerHelper.ensureSetup(getParentLayout());
+                    presentFragment(desu.inugram.helpers.dialogs.DrawerHelper.createMainFragment(args), true);
                 }
 
                 NotificationCenter.getInstance(currentAccount).postNotificationName(NotificationCenter.mainUserInfoChanged);
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationActivity.java
@@ -1298,9 +1298,8 @@ public class TwoStepVerificationActivity extends BaseFragment implements Notific
         if (otherwiseReloginDays >= 0) {
             final Bundle args = new Bundle();
             args.putBoolean("afterSignup", true);
-            MainTabsActivity mainTabsActivity = new MainTabsActivity();
-            mainTabsActivity.prepareDialogsActivity(args);
-            presentFragment(mainTabsActivity, true);
+            desu.inugram.helpers.dialogs.DrawerHelper.ensureSetup(getParentLayout());
+            presentFragment(desu.inugram.helpers.dialogs.DrawerHelper.createMainFragment(args), true);
         } else {
             super.finishFragment();
         }
diff --git a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java
index 0000000..0000000 100644
--- a/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java
+++ b/TMessagesProj/src/main/java/org/telegram/ui/TwoStepVerificationSetupActivity.java
@@ -1315,9 +1315,8 @@ public class TwoStepVerificationSetupActivity extends BaseFragment {
                 } else if (fromRegistration) {
                     final Bundle args = new Bundle();
                     args.putBoolean("afterSignup", true);
-                    MainTabsActivity mainTabsActivity = new MainTabsActivity();
-                    mainTabsActivity.prepareDialogsActivity(args);
-                    presentFragment(mainTabsActivity, true);
+                    desu.inugram.helpers.dialogs.DrawerHelper.ensureSetup(getParentLayout());
+                    presentFragment(desu.inugram.helpers.dialogs.DrawerHelper.createMainFragment(args), true);
                 } else {
                     TwoStepVerificationActivity fragment = new TwoStepVerificationActivity();
                     fragment.setCurrentPasswordParams(currentPassword, currentPasswordHash, currentSecretId, currentSecret);
@@ -2154,9 +2153,8 @@ public class TwoStepVerificationSetupActivity extends BaseFragment {
         if (otherwiseReloginDays >= 0 && parentLayout.getFragmentStack().size() == 1) {
             final Bundle args = new Bundle();
             args.putBoolean("afterSignup", true);
-            MainTabsActivity mainTabsActivity = new MainTabsActivity();
-            mainTabsActivity.prepareDialogsActivity(args);
-            presentFragment(mainTabsActivity, true);
+            desu.inugram.helpers.dialogs.DrawerHelper.ensureSetup(getParentLayout());
+            presentFragment(desu.inugram.helpers.dialogs.DrawerHelper.createMainFragment(args), true);
         } else {
             super.finishFragment();
         }
