Skip to content

Commit

Permalink
Merge pull request #6457 from brave/swipe_navigation
Browse files Browse the repository at this point in the history
Brings back a swipe navigation between tabs on a bottom toolbar
  • Loading branch information
SergeyZhukovsky authored Aug 20, 2020
2 parents 7c2497f + cb9c6b9 commit a86b8f2
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.chromium.base.supplier.Supplier;
import org.chromium.chrome.R;
import org.chromium.chrome.browser.ActivityTabProvider;
import org.chromium.chrome.browser.ChromeActivity;
import org.chromium.chrome.browser.ThemeColorProvider;
import org.chromium.chrome.browser.compositor.layouts.EmptyOverviewModeObserver;
import org.chromium.chrome.browser.compositor.layouts.OverviewModeBehavior;
Expand All @@ -42,10 +43,12 @@ public class BraveBottomToolbarCoordinator
private BottomToolbarNewTabButton mNewTabButton;
private ActivityTabProvider mBraveTabProvider;
private Runnable mOriginalHomeButtonRunnable;
private final ScrollingBottomViewResourceFrameLayout rootView;

private final Context mContext = ContextUtils.getApplicationContext();

BraveBottomToolbarCoordinator(ViewStub stub, ActivityTabProvider tabProvider,
BraveBottomToolbarCoordinator(ViewStub stub, ScrollingBottomViewResourceFrameLayout root,
ActivityTabProvider tabProvider,
OnLongClickListener tabsSwitcherLongClickListner, ThemeColorProvider themeColorProvider,
ObservableSupplier<ShareDelegate> shareDelegateSupplier,
Supplier<Boolean> showStartSurfaceCallable, Runnable openHomepageAction,
Expand All @@ -56,6 +59,7 @@ public class BraveBottomToolbarCoordinator
setUrlBarFocusAction, overviewModeBehaviorSupplier);
mBraveTabProvider = tabProvider;
mOriginalHomeButtonRunnable = openHomepageAction;
rootView = root;
}

@Override
Expand Down Expand Up @@ -186,5 +190,10 @@ public void onOverviewModeStartedHiding(
mOverviewModeBehavior.addOverviewModeObserver(mOverviewModeObserver);
}
}
ChromeActivity activity = TabUtils.getChromeActivity();
if (rootView != null && activity != null) {
rootView.setSwipeDetector(
activity.getCompositorViewHolder().getLayoutManager().getToolbarSwipeHandler());
}
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ private static void openNewTab(ChromeActivity chromeActivity, boolean isIncognit
chromeActivity.getTabCreator(isIncognito).launchNTP();
}

private static ChromeActivity getChromeActivity() {
public static ChromeActivity getChromeActivity() {
for (Activity ref : ApplicationStatus.getRunningActivities()) {
if (!(ref instanceof ChromeActivity)) continue;
return (ChromeActivity) ref;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java
index dbe1439508218d563014b99910968b79520099d4..3ed8ac4af4687d9088fd1e314334fb78ab63a752 100644
index dbe143950821..7cee920587e0 100644
--- a/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java
+++ b/chrome/android/java/src/org/chromium/chrome/browser/toolbar/bottom/BottomControlsCoordinator.java
@@ -120,7 +120,7 @@ public class BottomControlsCoordinator {
scrimCoordinator);
} else {
mBottomToolbarCoordinator =
- new BottomToolbarCoordinator(root.findViewById(R.id.bottom_toolbar_stub),
+ new BraveBottomToolbarCoordinator(root.findViewById(R.id.bottom_toolbar_stub),
+ new BraveBottomToolbarCoordinator(root.findViewById(R.id.bottom_toolbar_stub), root,
tabProvider, tabSwitcherLongclickListener, themeColorProvider,
shareDelegateSupplier, showStartSurfaceCallable, openHomepageAction,
setUrlBarFocusAction, overviewModeBehaviorSupplier);
Expand Down

0 comments on commit a86b8f2

Please sign in to comment.