Chromium Code Reviews| OLD | NEW |
|---|---|
| 1 // Copyright 2015 The Chromium Authors. All rights reserved. | 1 // Copyright 2015 The Chromium Authors. All rights reserved. |
| 2 // Use of this source code is governed by a BSD-style license that can be | 2 // Use of this source code is governed by a BSD-style license that can be |
| 3 // found in the LICENSE file. | 3 // found in the LICENSE file. |
| 4 | 4 |
| 5 package org.chromium.chrome.browser; | 5 package org.chromium.chrome.browser; |
| 6 | 6 |
| 7 import android.annotation.SuppressLint; | 7 import android.annotation.SuppressLint; |
| 8 import android.annotation.TargetApi; | 8 import android.annotation.TargetApi; |
| 9 import android.app.Activity; | 9 import android.app.Activity; |
| 10 import android.app.SearchManager; | 10 import android.app.SearchManager; |
| (...skipping 187 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 198 // We have to instantiate the TouchExplorationStateChangeListner object in t he code. | 198 // We have to instantiate the TouchExplorationStateChangeListner object in t he code. |
| 199 @SuppressLint("NewApi") | 199 @SuppressLint("NewApi") |
| 200 private TouchExplorationStateChangeListener mTouchExplorationStateChangeList ener; | 200 private TouchExplorationStateChangeListener mTouchExplorationStateChangeList ener; |
| 201 | 201 |
| 202 // Observes when sync becomes ready to create the mContextReporter. | 202 // Observes when sync becomes ready to create the mContextReporter. |
| 203 private ProfileSyncService.SyncStateChangedListener mSyncStateChangedListene r; | 203 private ProfileSyncService.SyncStateChangedListener mSyncStateChangedListene r; |
| 204 | 204 |
| 205 private ActivityWindowAndroid mWindowAndroid; | 205 private ActivityWindowAndroid mWindowAndroid; |
| 206 private ChromeFullscreenManager mFullscreenManager; | 206 private ChromeFullscreenManager mFullscreenManager; |
| 207 private CompositorViewHolder mCompositorViewHolder; | 207 private CompositorViewHolder mCompositorViewHolder; |
| 208 private InsetConsumerView mInsetConsumerView; | |
| 208 private ContextualSearchManager mContextualSearchManager; | 209 private ContextualSearchManager mContextualSearchManager; |
| 209 private ReaderModeManager mReaderModeManager; | 210 private ReaderModeManager mReaderModeManager; |
| 210 private SnackbarManager mSnackbarManager; | 211 private SnackbarManager mSnackbarManager; |
| 211 private DataUseSnackbarController mDataUseSnackbarController; | 212 private DataUseSnackbarController mDataUseSnackbarController; |
| 212 private AppMenuPropertiesDelegate mAppMenuPropertiesDelegate; | 213 private AppMenuPropertiesDelegate mAppMenuPropertiesDelegate; |
| 213 private AppMenuHandler mAppMenuHandler; | 214 private AppMenuHandler mAppMenuHandler; |
| 214 private ToolbarManager mToolbarManager; | 215 private ToolbarManager mToolbarManager; |
| 215 private BookmarkModelObserver mBookmarkObserver; | 216 private BookmarkModelObserver mBookmarkObserver; |
| 216 | 217 |
| 217 // Time in ms that it took took us to inflate the initial layout | 218 // Time in ms that it took took us to inflate the initial layout |
| (...skipping 129 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 347 TraceEvent.end("onCreate->setContentView()"); | 348 TraceEvent.end("onCreate->setContentView()"); |
| 348 mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; | 349 mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; |
| 349 | 350 |
| 350 // Set the status bar color to black by default. This is an optimization for | 351 // Set the status bar color to black by default. This is an optimization for |
| 351 // Chrome not to draw under status and navigation bars when we use the d efault | 352 // Chrome not to draw under status and navigation bars when we use the d efault |
| 352 // black status bar | 353 // black status bar |
| 353 ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); | 354 ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); |
| 354 | 355 |
| 355 mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.composi tor_view_holder); | 356 mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.composi tor_view_holder); |
| 356 mCompositorViewHolder.setRootView(getWindow().getDecorView().getRootView ()); | 357 mCompositorViewHolder.setRootView(getWindow().getDecorView().getRootView ()); |
| 358 | |
| 359 // Iterate up the view hierarchy to find the eldest parent that consumes | |
| 360 // window insets. Stop it from consuming the insets and add a custom | |
| 361 // view right after it that consumes the insets and stores it to access | |
| 362 // later. ContentViewCore needs the insets to determine the portion of | |
| 363 // the screen obscured by non-content displaying things such as the OSK. | |
| 364 View parent = mCompositorViewHolder; | |
| 365 ViewGroup addAfter = null; | |
| 366 while (parent.getParent() instanceof View) { | |
| 367 parent = (View) parent.getParent(); | |
| 368 if (parent.getFitsSystemWindows()) { | |
| 369 addAfter = (ViewGroup) parent; | |
| 370 } | |
| 371 } | |
| 372 | |
| 373 // Transfer child view hierarchy to InsetConsumerView. This is needed to | |
| 374 // ensure that the insets are applied properly. | |
| 375 if (addAfter != null) { | |
| 376 // Setting fitsSystemWindows to false ensures that the view | |
| 377 // doesn't consume the insets. | |
| 378 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
| |
| 379 InsetConsumerView insetConsumerView = new InsetConsumerView(this); | |
| 380 insetConsumerView.setFitsSystemWindows(true); | |
| 381 while (addAfter.getChildCount() > 0) { | |
| 382 View currentChild = addAfter.getChildAt(0); | |
| 383 addAfter.removeView(currentChild); | |
| 384 insetConsumerView.addView(currentChild); | |
| 385 } | |
| 386 addAfter.addView(insetConsumerView); | |
| 387 mInsetConsumerView = insetConsumerView; | |
| 388 } | |
| 357 } | 389 } |
| 358 | 390 |
| 359 /** | 391 /** |
| 360 * Constructs {@link ToolbarManager} and the handler necessary for controlli ng the menu on the | 392 * Constructs {@link ToolbarManager} and the handler necessary for controlli ng the menu on the |
| 361 * {@link Toolbar}. Extending classes can override this call to avoid creati ng the toolbar. | 393 * {@link Toolbar}. Extending classes can override this call to avoid creati ng the toolbar. |
| 362 */ | 394 */ |
| 363 protected void initializeToolbar() { | 395 protected void initializeToolbar() { |
| 364 final View controlContainer = findViewById(R.id.control_container); | 396 final View controlContainer = findViewById(R.id.control_container); |
| 365 assert controlContainer != null; | 397 assert controlContainer != null; |
| 366 ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) con trolContainer; | 398 ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) con trolContainer; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 | 1084 |
| 1053 /** | 1085 /** |
| 1054 * {@link TabModelSelector} no longer implements TabModel. Use getTabModelS elector() or | 1086 * {@link TabModelSelector} no longer implements TabModel. Use getTabModelS elector() or |
| 1055 * getCurrentTabModel() depending on your needs. | 1087 * getCurrentTabModel() depending on your needs. |
| 1056 * @return The {@link TabModelSelector}, possibly null. | 1088 * @return The {@link TabModelSelector}, possibly null. |
| 1057 */ | 1089 */ |
| 1058 public TabModelSelector getTabModelSelector() { | 1090 public TabModelSelector getTabModelSelector() { |
| 1059 return mTabModelSelector; | 1091 return mTabModelSelector; |
| 1060 } | 1092 } |
| 1061 | 1093 |
| 1094 /** | |
| 1095 * Returns the {@link InsetConsumerView} that has the current system window | |
| 1096 * insets information. | |
| 1097 * @return The {@link InsetConsumerView}, possibly null. | |
| 1098 */ | |
| 1099 public InsetConsumerView getInsetConsumerView() { | |
| 1100 return mInsetConsumerView; | |
| 1101 } | |
| 1102 | |
| 1062 @Override | 1103 @Override |
| 1063 public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { | 1104 public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { |
| 1064 return incognito ? mIncognitoTabCreator : mRegularTabCreator; | 1105 return incognito ? mIncognitoTabCreator : mRegularTabCreator; |
| 1065 } | 1106 } |
| 1066 | 1107 |
| 1067 /** | 1108 /** |
| 1068 * Sets the {@link ChromeTabCreator}s owned by this {@link ChromeActivity}. | 1109 * Sets the {@link ChromeTabCreator}s owned by this {@link ChromeActivity}. |
| 1069 * @param regularTabCreator A {@link ChromeTabCreator} instance. | 1110 * @param regularTabCreator A {@link ChromeTabCreator} instance. |
| 1070 */ | 1111 */ |
| 1071 public void setTabCreators(TabCreatorManager.TabCreator regularTabCreator, | 1112 public void setTabCreators(TabCreatorManager.TabCreator regularTabCreator, |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1608 public static int getThemeId() { | 1649 public static int getThemeId() { |
| 1609 boolean useLowEndTheme = | 1650 boolean useLowEndTheme = |
| 1610 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP; | 1651 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP; |
| 1611 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme); | 1652 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme); |
| 1612 } | 1653 } |
| 1613 | 1654 |
| 1614 private void setLowEndTheme() { | 1655 private void setLowEndTheme() { |
| 1615 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd); | 1656 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd); |
| 1616 } | 1657 } |
| 1617 } | 1658 } |
| OLD | NEW |