Commit 085be8a6 authored by Mei Liang's avatar Mei Liang Committed by Commit Bot

Add LayoutType to identify each Layout

This CL adds the LayoutType identifier to each Layout via the
Layout#getLayoutType. This is not use anywhere yet. The potential caller
of this API should be the LayoutManager, then LayoutManager pass the
identifier to features that are observing the Layouts. Features then can
use this identifier to determine what to react with a specific type of
Layout being shown and hidden.

Change-Id: Ie5e38c5f0c6edf5fdc8949fd20ad1c20e1e3832f
Bug: 1108496
Reviewed-on: https://chromium-review.googlesource.com/c/chromium/src/+/2419851
Auto-Submit: Mei Liang <meiliang@chromium.org>
Reviewed-by: default avatarMatthew Jones <mdjones@chromium.org>
Reviewed-by: default avatarTheresa  <twellington@chromium.org>
Commit-Queue: Mei Liang <meiliang@chromium.org>
Cr-Commit-Position: refs/heads/master@{#817775}
parent 51416681
......@@ -503,6 +503,11 @@ public class StartSurfaceLayout extends Layout implements StartSurface.OverviewM
mLastFrameTime = SystemClock.elapsedRealtime();
}
@Override
public int getLayoutType() {
return LayoutType.TAB_SWITCHER;
}
@Override
public boolean onUpdateAnimation(long time, boolean jumpToEnd) {
return mTabToSwitcherAnimation == null && !mIsAnimating;
......
......@@ -259,4 +259,9 @@ public class OverviewListLayout extends Layout
mTabModelWrapper.sendAccessibilityEvent(AccessibilityEvent.TYPE_WINDOW_CONTENT_CHANGED);
}
}
@Override
public int getLayoutType() {
return LayoutType.TAB_SWITCHER;
}
}
......@@ -38,6 +38,19 @@ import java.util.List;
*/
public abstract class Layout implements TabContentManager.ThumbnailChangeListener {
/**
* The type info of the Layout.
*/
@IntDef({LayoutType.BROWSING, LayoutType.TAB_SWITCHER, LayoutType.TOOLBAR_SWIPE,
LayoutType.SIMPLE_ANIMATION})
@Retention(RetentionPolicy.SOURCE)
public @interface LayoutType {
int BROWSING = 0;
int TAB_SWITCHER = 1;
int TOOLBAR_SWIPE = 2;
int SIMPLE_ANIMATION = 3;
}
/**
* The orientation of the device.
*/
......@@ -800,4 +813,10 @@ public abstract class Layout implements TabContentManager.ThumbnailChangeListene
protected void updateSceneLayer(RectF viewport, RectF contentViewport,
LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
ResourceManager resourceManager, BrowserControlsStateProvider browserControls) {}
/**
* @return The {@link LayoutType}.
*/
@LayoutType
public abstract int getLayoutType();
}
......@@ -450,6 +450,11 @@ public class StaticLayout extends Layout {
}
}
@Override
public int getLayoutType() {
return LayoutType.BROWSING;
}
@Override
public void destroy() {
if (mSceneLayer != null) {
......
......@@ -393,6 +393,11 @@ public class ToolbarSwipeLayout extends Layout {
SceneLayer.INVALID_RESOURCE_ID, 0, 0);
}
@Override
public int getLayoutType() {
return LayoutType.TOOLBAR_SWIPE;
}
/**
* Perform the tabs sliding animations. If the new tab's index is smaller than the old one, new
* tab slide in from left, and old one slide out to right, and vice versa.
......
......@@ -465,4 +465,9 @@ public class SimpleAnimationLayout extends Layout {
layerTitleCache, tabContentManager, resourceManager, browserControls,
SceneLayer.INVALID_RESOURCE_ID, 0, 0);
}
@Override
public int getLayoutType() {
return LayoutType.SIMPLE_ANIMATION;
}
}
......@@ -1678,6 +1678,11 @@ public abstract class StackLayoutBase extends Layout {
0, 0);
}
@Override
public int getLayoutType() {
return LayoutType.TAB_SWITCHER;
}
/**
* Creates an {@link CompositorAnimator} and adds it to the animation.
* Automatically sets the start value at the beginning of the animation.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment