Index: chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
diff --git a/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java b/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
index 5a235403892d3e7e74557f8c8981a3beecefce8f..2cc2649049dbaa4f145d0de27e49740df0f584c3 100644 |
--- a/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
+++ b/chrome/android/java/src/org/chromium/chrome/browser/widget/BottomSheet.java |
@@ -138,6 +138,20 @@ public class BottomSheet |
*/ |
private float mLastPeekToHalfRatioSent; |
+ /** The FrameLayout used to hold the bottom sheet toolbar. */ |
+ private FrameLayout mToolbarHolder; |
+ |
+ /** |
+ * The default toolbar view. This is shown when the current bottom sheet content doesn't have |
+ * its own toolbar and when the bottom sheet is closed. |
+ */ |
+ private View mDefaultToolbarView; |
+ |
+ /** |
+ * The last non-default toolbar view that was attached to mToolbarHolder. |
mdjones
2017/03/14 20:08:36
nit: comment can be made single-line
Theresa
2017/03/14 20:40:02
Done.
|
+ */ |
+ private View mLastToolbarView; |
+ |
/** |
* An interface defining content that can be displayed inside of the bottom sheet for Chrome |
* Home. |
@@ -391,6 +405,8 @@ public class BottomSheet |
mPlaceholder.setBackgroundColor( |
ApiCompatibilityUtils.getColor(getResources(), android.R.color.white)); |
mBottomSheetContentContainer.addView(mPlaceholder, placeHolderParams); |
+ |
+ mToolbarHolder = (FrameLayout) mControlContainer.findViewById(R.id.toolbar_holder); |
} |
@Override |
@@ -476,6 +492,25 @@ public class BottomSheet |
mBottomSheetContentContainer.removeView(mPlaceholder); |
mSheetContent = content; |
mBottomSheetContentContainer.addView(mSheetContent.getContentView()); |
+ |
+ // This class is initialized before the toolbar is inflated, so mDefaultToolbar is |
+ // initialized here rather than in #init(). |
+ if (mDefaultToolbarView == null) { |
mdjones
2017/03/14 20:08:36
It looks like it should be possible to swap the in
Theresa
2017/03/14 20:40:02
Done.
|
+ mDefaultToolbarView = mControlContainer.findViewById(R.id.toolbar); |
+ } |
+ |
+ if (mLastToolbarView != null) { |
+ mToolbarHolder.removeView(mLastToolbarView); |
+ mLastToolbarView = null; |
+ } |
+ |
+ if (mSheetContent.getToolbarView() != null) { |
+ mLastToolbarView = mSheetContent.getToolbarView(); |
+ mToolbarHolder.addView(mSheetContent.getToolbarView()); |
+ mDefaultToolbarView.setVisibility(View.GONE); |
+ } else { |
+ mDefaultToolbarView.setVisibility(View.VISIBLE); |
+ } |
} |
/** |