Chromium Code Reviews| Index: chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| diff --git a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| index 162d1fa3d260bacf4d5b0edd52bc7e306bf99bb9..61f578d68ecb225945f04bf8e69963c658c92403 100644 |
| --- a/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| +++ b/chrome/android/java/src/org/chromium/chrome/browser/ChromeActivity.java |
| @@ -205,6 +205,7 @@ public abstract class ChromeActivity extends AsyncInitializationActivity |
| private ActivityWindowAndroid mWindowAndroid; |
| private ChromeFullscreenManager mFullscreenManager; |
| private CompositorViewHolder mCompositorViewHolder; |
| + private InsetConsumerView mInsetConsumerView; |
| private ContextualSearchManager mContextualSearchManager; |
| private ReaderModeManager mReaderModeManager; |
| private SnackbarManager mSnackbarManager; |
| @@ -354,6 +355,37 @@ public abstract class ChromeActivity extends AsyncInitializationActivity |
| mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder); |
| mCompositorViewHolder.setRootView(getWindow().getDecorView().getRootView()); |
| + |
| + // Iterate up the view hierarchy to find the eldest parent that consumes |
| + // window insets. Stop it from consuming the insets and add a custom |
| + // view right after it that consumes the insets and stores it to access |
| + // later. ContentViewCore needs the insets to determine the portion of |
| + // the screen obscured by non-content displaying things such as the OSK. |
| + View parent = mCompositorViewHolder; |
| + ViewGroup addAfter = null; |
| + while (parent.getParent() instanceof View) { |
| + parent = (View) parent.getParent(); |
| + if (parent.getFitsSystemWindows()) { |
| + addAfter = (ViewGroup) parent; |
| + } |
| + } |
| + |
| + // Transfer child view hierarchy to InsetConsumerView. This is needed to |
| + // ensure that the insets are applied properly. |
| + if (addAfter != null) { |
| + // Setting fitsSystemWindows to false ensures that the view |
| + // doesn't consume the insets. |
| + addAfter.setFitsSystemWindows(false); |
|
aelias_OOO_until_Jul13
2016/03/09 01:34:43
Hmm, this algorithm is more complicated than I'd l
ymalik
2016/03/09 16:47:14
Yes with the current view hierarchy it will work i
aelias_OOO_until_Jul13
2016/03/09 22:18:59
I don't think the worry the root View might captur
|
| + InsetConsumerView insetConsumerView = new InsetConsumerView(this); |
| + insetConsumerView.setFitsSystemWindows(true); |
| + while (addAfter.getChildCount() > 0) { |
| + View currentChild = addAfter.getChildAt(0); |
| + addAfter.removeView(currentChild); |
| + insetConsumerView.addView(currentChild); |
| + } |
| + addAfter.addView(insetConsumerView); |
| + mInsetConsumerView = insetConsumerView; |
| + } |
| } |
| /** |
| @@ -1059,6 +1091,15 @@ public abstract class ChromeActivity extends AsyncInitializationActivity |
| return mTabModelSelector; |
| } |
| + /** |
| + * Returns the {@link InsetConsumerView} that has the current system window |
| + * insets information. |
| + * @return The {@link InsetConsumerView}, possibly null. |
| + */ |
| + public InsetConsumerView getInsetConsumerView() { |
| + return mInsetConsumerView; |
| + } |
| + |
| @Override |
| public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { |
| return incognito ? mIncognitoTabCreator : mRegularTabCreator; |