Skip to content

Commit

Permalink
first patch application-move_toolbar_to_bottom
Browse files Browse the repository at this point in the history
  • Loading branch information
DevT75 committed Sep 2, 2024
1 parent faf43de commit 05decfd
Show file tree
Hide file tree
Showing 45 changed files with 220 additions and 107 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -985,8 +985,8 @@ public boolean shouldShowTabSwitcherToolbar() {
}

private void setTopMargin(int topMargin) {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
topMargin = 0;
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
topMargin = 0;
mPropertyModel.set(TOP_MARGIN, topMargin);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -178,8 +178,8 @@ void setContentBackgroundColor(int color) {
mFadingEdgeEnd.setColorFilter(color, PorterDuff.Mode.SRC_IN);
}
void setPrimaryColorAndApplyTint(int color) {
// if (!ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
if(false)
if (!ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
// if(false)
return;

// change the background color of the bottom bar if the top toolbar is below
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -480,8 +480,8 @@ public void onLayoutCompleted(RecyclerView.State state) {
checkAwaitingLayout();
}
};
// if (actionOnRelatedTabs && ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (actionOnRelatedTabs && ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
gridLayoutManager =
new GridLayoutManagerDockBottom(context, GRID_LAYOUT_SPAN_COUNT_COMPACT);
((GridLayoutManagerDockBottom)gridLayoutManager)
Expand Down Expand Up @@ -513,7 +513,7 @@ public void onLayoutCompleted(RecyclerView.State state) {
}
};
mRecyclerView.setLayoutManager(layoutManager);
} else if (mMode == TabListMode.LIST) {
} else if (mMode == TabListMode.LIST) {
LinearLayoutManager layout =
new LinearLayoutManager(context, LinearLayoutManager.VERTICAL, false) {
@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -249,10 +249,10 @@ public float getTop() {
@Override
public void setCurrentTouchEventOffsets(float top) {
EventForwarder forwarder = getEventForwarder();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// no need to adjust the touch offsets, since the content view is never moved
top = 0;
// }
}
if (forwarder != null) forwarder.setCurrentTouchEventOffsets(0, top);
}

Expand Down Expand Up @@ -909,8 +909,8 @@ void updateWebContentsSize(Tab tab) {
mApplicationBottomInsetSupplier != null
? mApplicationBottomInsetSupplier.get().webContentsHeightInset
: 0;
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
keyboardInset = 0;
}
int viewportInsets = controlsInsets + keyboardInset;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -312,8 +312,8 @@ public SwipeHandler getToolbarSwipeHandler() {

@Override
public SwipeHandler createToolbarSwipeHandler(boolean supportSwipeDown) {
boolean move_top_toolbar = true;
// ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled();
// boolean move_top_toolbar = true;
boolean move_top_toolbar = ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled();
return new ToolbarSwipeHandler(supportSwipeDown && !move_top_toolbar,
supportSwipeDown && move_top_toolbar);
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@
import org.chromium.chrome.browser.compositor.overlays.strip.StripLayoutHelperManager;
import org.chromium.chrome.browser.compositor.overlays.strip.StripLayoutHelperManager.TabModelStartupInfo;
import org.chromium.chrome.browser.device.DeviceClassManager;
import org.chromium.chrome.browser.fullscreen.BrowserControlsManager;
import org.chromium.chrome.browser.hub.HubLayout;
import org.chromium.chrome.browser.hub.HubLayoutDependencyHolder;
import org.chromium.chrome.browser.layouts.LayoutType;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -443,8 +443,8 @@ protected void updateLayout(long time, long dt) {
mLeftToolbarOverlay.setXOffset(leftX * dpToPx);
}
mLeftTab.setX(leftX);
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
mLeftTab.setY(0);
} else {
mLeftTab.setY(mBrowserControlsStateProvider.getContentOffset() / dpToPx);
Expand All @@ -461,8 +461,8 @@ protected void updateLayout(long time, long dt) {
mRightToolbarOverlay.setXOffset(rightX * dpToPx);
}
mRightTab.setX(rightX);
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
mRightTab.setY(0);
} else {
mRightTab.setY(mBrowserControlsStateProvider.getContentOffset() / dpToPx);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@
import org.chromium.chrome.browser.tab_ui.TabContentManager;
import org.chromium.ui.modelutil.PropertyKey;
import org.chromium.ui.modelutil.PropertyModel;
import org.chromium.chrome.browser.flags.ChromeFeatureList;

/** A SceneLayer to render a static tab. */
@JNINamespace("android")
Expand Down Expand Up @@ -46,7 +47,12 @@ public void update(PropertyModel model) {

float x = model.get(LayoutTab.RENDER_X) * LayoutTab.sDpToPx;
// the page content window never moves, it is fixed at the top
float y = 0;
float y = model.get(LayoutTab.CONTENT_OFFSET)
+ model.get(LayoutTab.RENDER_Y) * LayoutTab.sDpToPx;
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// the page content window never moves, it is fixed at the top
y = 0;
}
// Check isActiveLayout to prevent pushing a TAB_ID for a static layer that may already be
// invalidated by the next layout.
StaticTabSceneLayerJni.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -88,11 +88,11 @@ public void pushLayers(
}

TabListSceneLayerJni.get().beginBuildingFrame(mNativePtr, TabListSceneLayer.this);
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// the tabs list content window is fixed at the top, where the top toolbar used to be
viewport.top = 0;
backgroundTopOffset = 0;
// }
}

// TODO(crbug.com/40126259): Use Supplier to get viewport and forward it to native, then
// updateLayer can become obsolete.
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -95,7 +95,7 @@ public void pushAndUpdateStrip(
int topControlsHeight) {
if (mNativePtr == 0) return;
boolean visible = yOffset > -layoutHelper.getHeight();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (DeviceFormFactor.isNonMultiDisplayContextOnTablet(ContextUtils.getApplicationContext())) {
// the list of open tabs is moved down, above the top
// toolbar which is also below.
Expand All @@ -104,7 +104,7 @@ public void pushAndUpdateStrip(
// and it disappears along with the moving toolbar with a higher range
visible = yOffset > (-layoutHelper.getHeight() - topControlsHeight);
}
// }
}

// This will hide the tab strips if necessary.
TabStripSceneLayerJni.get()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -171,11 +171,11 @@ private void setShowState(boolean show) {

if (show && getVisibility() != View.VISIBLE && mCurrentAnimation != mAnimationEnter) {
View anchorView = getRootView().findViewById(R.id.toolbar);
// if (!ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (!ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
FrameLayout.LayoutParams lp = (FrameLayout.LayoutParams) getLayoutParams();
lp.topMargin = anchorView.getBottom() - mYInsetPx;
setLayoutParams(lp);
// }
}
} else if (!show && getVisibility() != View.GONE && mCurrentAnimation != mAnimationLeave) {
nextAnimator = mAnimationLeave;
onHideAnimationStart();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -432,8 +432,8 @@ public int getTopControlsHeight() {
}
@Override
public int getTopControlsHeightRealOffset() {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
if(true)
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
// if(true)
return 0;
else
return mTopControlContainerHeight;
Expand Down Expand Up @@ -504,8 +504,8 @@ private void updateControlOffset() {

@Override
public float getTopVisibleContentOffset() {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
if(true)
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
// if(true)
return 0;
return getTopControlsHeight() + getTopControlOffset();
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -60,8 +60,8 @@ private void updateMargins() {
}
CoordinatorLayout.LayoutParams params =
(CoordinatorLayout.LayoutParams) mContainer.getLayoutParams();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
params.gravity = Gravity.START | Gravity.BOTTOM;
params.bottomMargin = getContainerTopOffset();
} else {
Expand Down Expand Up @@ -139,8 +139,8 @@ public void removeObserver(MessageContainerObserver observer) {

/** @return Offset of the message container from the top of the screen. */
private int getContainerTopOffset() {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
return mControlsManager.getContentOffset()
+ (mControlsManager.getBottomControlsHeight() - mControlsManager.getBottomControlOffset())
+ mContainer.getMessageShadowTopMargin();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -696,11 +696,11 @@ private void updateMargins() {
int bottomMargin =
mBrowserControlsStateProvider.getBottomControlsHeight()
- mBrowserControlsStateProvider.getBottomControlOffset();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// move the margin of the new tab page up if the top toolbar is at the bottom
bottomMargin += mBrowserControlsStateProvider.getTopControlsHeight();
topMargin = -mBrowserControlsStateProvider.getTopControlsHeight();
// }
}
if (topMargin != layoutParams.topMargin || bottomMargin != layoutParams.bottomMargin) {
layoutParams.topMargin = topMargin;
layoutParams.bottomMargin = bottomMargin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -197,12 +197,12 @@ protected void onFinishInflate() {
mMiddleSpacer = findViewById(R.id.ntp_middle_spacer);
mFakeSearchBoxLayout = findViewById(R.id.search_box);
insertSiteSectionView();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
FrameLayout.LayoutParams params =
new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT);
params.gravity = Gravity.BOTTOM;
setLayoutParams(params);
// }
}
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -100,9 +100,9 @@ public RecentTabsPage(

mView.addOnAttachStateChangeListener(this);

// if (!DeviceFormFactor.isNonMultiDisplayContextOnTablet(mActivity) ||
// ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (!DeviceFormFactor.isNonMultiDisplayContextOnTablet(mActivity) ||
ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
mBrowserControlsStateProvider = browserControlsStateProvider;
mBrowserControlsStateProvider.addObserver(this);
onBottomControlsHeightChanged(
Expand All @@ -115,8 +115,8 @@ public RecentTabsPage(
mTabStripHeightSupplier = tabStripHeightSupplier;
mView.setPadding(0, mTabStripHeightSupplier.get(), 0, 0);
if (ToolbarFeatures.isDynamicTopChromeEnabled()) {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
mView.setPadding(
mView.getPaddingLeft(),
0,
Expand Down Expand Up @@ -328,18 +328,18 @@ private void updateMargins() {

// If the content offset is different from the margin, we use translationY to position the
// view in line with the content offset.
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
topMargin = 0;
recentTabsRoot.setTranslationY(0);
} else {
recentTabsRoot.setTranslationY(contentOffset - topMargin);
}

int bottomMargin = mBrowserControlsStateProvider.getBottomControlsHeight();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
bottomMargin += mBrowserControlsStateProvider.getTopControlsHeight();
// }
}
if (topMargin != layoutParams.topMargin || bottomMargin != layoutParams.bottomMargin) {
layoutParams.topMargin = topMargin;
layoutParams.bottomMargin = bottomMargin;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -295,12 +295,12 @@ protected void triggerLayoutInflation() {
(SearchActivityLocationBarLayout)
contentView.findViewById(R.id.search_location_bar);
View anchorView = contentView.findViewById(R.id.toolbar);
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams)
anchorView.getLayoutParams();
layoutParams.gravity = Gravity.START | Gravity.BOTTOM;
anchorView.setLayoutParams(layoutParams);
// }
}

// Update the status bar's color based on the toolbar color.
Drawable anchorViewBackground = anchorView.getBackground();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -191,11 +191,11 @@ public static Class getSceneOverlayClass() {
private void initialize() {
final ViewStub stub = mActivity.findViewById(R.id.status_indicator_stub);
final ViewResourceFrameLayout root = (ViewResourceFrameLayout) stub.inflate();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// status messages (such as the offline indicator) are docked at the bottom
CoordinatorLayout.LayoutParams layoutParams = (CoordinatorLayout.LayoutParams)root.getLayoutParams();
layoutParams.gravity = Gravity.START | Gravity.BOTTOM;
// }
}
mResourceId = root.getId();
mSceneLayer.setResourceId(mResourceId);
mResourceAdapter = root.getResourceAdapter();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,9 +79,9 @@ public void setContentTree(SceneLayer contentTree) {
public SceneOverlayLayer getUpdatedSceneOverlayTree(
RectF viewport, RectF visibleViewport, ResourceManager resourceManager, float yOffset) {
int offset = mBrowserControlsStateProvider.getTopControlsMinHeightOffset();
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
offset = (int)viewport.bottom - offset;
// }
}
StatusIndicatorSceneLayerJni.get()
.updateStatusIndicatorLayer(
mNativePtr,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -658,7 +658,17 @@ public boolean isOfflinePage(Tab tab) {
});
mControlContainer = controlContainer;
mToolbarHairline = mControlContainer.findViewById(R.id.toolbar_hairline);
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
ViewGroup.MarginLayoutParams layoutParamsCC =
((ViewGroup.MarginLayoutParams) mControlContainer.getLayoutParams());
layoutParamsCC.bottomMargin = mToolbarHairline.getHeight();
mControlContainer.setLayoutParams(layoutParamsCC);

ViewGroup.MarginLayoutParams layoutParamsHR =
((ViewGroup.MarginLayoutParams) mToolbarHairline.getLayoutParams());
layoutParamsHR.topMargin = 0;
mToolbarHairline.setLayoutParams(layoutParamsHR);
}
mBookmarkModelSupplier = bookmarkModelSupplier;
// We need to capture a reference to setBookmarkModel/setCurrentProfile in order to remove
// them later; there is no guarantee in the JLS that referencing the same method later will
Expand Down Expand Up @@ -1672,9 +1682,9 @@ public String getUrlBarTextWithoutAutocomplete() {
View mBottomRoot;

private void MoveBottomBarOverTopBar() {
// if (mBottomRoot != null &&
// ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if(true){
if (mBottomRoot != null &&
ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// if(true){
// move up the container view of the ui
// below there is the toolbar
mBottomRoot.setTranslationY(-mBrowserControlsSizer.getTopControlsHeight());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -63,23 +63,23 @@ public void onControlsOffsetChanged(
}
@Override
public void onTopControlsHeightChanged(int topControlsHeight, int topControlsMinHeight) {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
setTranslationY(mBaseYOffset);
}

@Override
public void onAndroidControlsVisibilityChanged(int visibility) {
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled())
setTranslationY(mBaseYOffset);
}
@Override
public void setTranslationY(float y) {
mBaseYOffset = y;
// if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
if (ChromeFeatureList.sMoveTopToolbarToBottom.isEnabled()) {
// the snackbar container is moved up because there is the top toolbar at the bottom
mBaseYOffset = -(mBrowserControlsStateProvider.getTopControlsHeight()
+ mBrowserControlsStateProvider.getTopControlOffset());
// }
}
float offsetFromControls =
mBrowserControlsStateProvider.getBottomControlOffset()
- mBrowserControlsStateProvider.getBottomControlsHeight();
Expand Down
Loading

0 comments on commit 05decfd

Please sign in to comment.