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 // Add a custom view right after the root view that consumes the insets | |
| 360 // and stores it to access later. ContentViewCore needs the insets to | |
| 361 // determine the portion of the screen obscured by non-content | |
|
Ted C
2016/03/12 00:01:43
I don't really like mucking with the view hierarch
ymalik
2016/03/14 22:19:01
Done.
| |
| 362 // displaying things such as the OSK. | |
| 363 ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView( ); | |
|
Ted C
2016/03/12 00:01:43
this is also needed above in setRootView, so let's
ymalik
2016/03/14 22:19:01
Done.
| |
| 364 // Setting fitsSystemWindows to false ensures that the root view | |
| 365 // doesn't consume the insets. | |
| 366 rootView.setFitsSystemWindows(false); | |
|
Ted C
2016/03/12 00:01:43
this didn't seem necessary in my prototyping
ymalik
2016/03/14 22:19:01
I had this in case the compat lib was ever changed
| |
| 367 // Transfer child view hierarchy to InsetConsumerView. This is needed to | |
| 368 // ensure that the insets are applied properly. | |
| 369 InsetConsumerView insetConsumerView = new InsetConsumerView(this); | |
| 370 insetConsumerView.setFitsSystemWindows(true); | |
|
Ted C
2016/03/12 00:01:44
move this to the constructor
ymalik
2016/03/14 22:19:01
I don't think we need this with the sibling approa
| |
| 371 while (rootView.getChildCount() > 0) { | |
| 372 View currentChild = rootView.getChildAt(0); | |
| 373 rootView.removeView(currentChild); | |
| 374 insetConsumerView.addView(currentChild); | |
| 375 } | |
| 376 rootView.addView(insetConsumerView); | |
| 377 mInsetConsumerView = insetConsumerView; | |
| 357 } | 378 } |
| 358 | 379 |
| 359 /** | 380 /** |
| 360 * Constructs {@link ToolbarManager} and the handler necessary for controlli ng the menu on the | 381 * 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. | 382 * {@link Toolbar}. Extending classes can override this call to avoid creati ng the toolbar. |
| 362 */ | 383 */ |
| 363 protected void initializeToolbar() { | 384 protected void initializeToolbar() { |
| 364 final View controlContainer = findViewById(R.id.control_container); | 385 final View controlContainer = findViewById(R.id.control_container); |
| 365 assert controlContainer != null; | 386 assert controlContainer != null; |
| 366 ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) con trolContainer; | 387 ToolbarControlContainer toolbarContainer = (ToolbarControlContainer) con trolContainer; |
| (...skipping 685 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1052 | 1073 |
| 1053 /** | 1074 /** |
| 1054 * {@link TabModelSelector} no longer implements TabModel. Use getTabModelS elector() or | 1075 * {@link TabModelSelector} no longer implements TabModel. Use getTabModelS elector() or |
| 1055 * getCurrentTabModel() depending on your needs. | 1076 * getCurrentTabModel() depending on your needs. |
| 1056 * @return The {@link TabModelSelector}, possibly null. | 1077 * @return The {@link TabModelSelector}, possibly null. |
| 1057 */ | 1078 */ |
| 1058 public TabModelSelector getTabModelSelector() { | 1079 public TabModelSelector getTabModelSelector() { |
| 1059 return mTabModelSelector; | 1080 return mTabModelSelector; |
| 1060 } | 1081 } |
| 1061 | 1082 |
| 1083 /** | |
| 1084 * Returns the {@link InsetConsumerView} that has the current system window | |
| 1085 * insets information. | |
| 1086 * @return The {@link InsetConsumerView}, possibly null. | |
| 1087 */ | |
| 1088 public InsetConsumerView getInsetConsumerView() { | |
| 1089 return mInsetConsumerView; | |
| 1090 } | |
| 1091 | |
| 1062 @Override | 1092 @Override |
| 1063 public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { | 1093 public TabCreatorManager.TabCreator getTabCreator(boolean incognito) { |
| 1064 return incognito ? mIncognitoTabCreator : mRegularTabCreator; | 1094 return incognito ? mIncognitoTabCreator : mRegularTabCreator; |
| 1065 } | 1095 } |
| 1066 | 1096 |
| 1067 /** | 1097 /** |
| 1068 * Sets the {@link ChromeTabCreator}s owned by this {@link ChromeActivity}. | 1098 * Sets the {@link ChromeTabCreator}s owned by this {@link ChromeActivity}. |
| 1069 * @param regularTabCreator A {@link ChromeTabCreator} instance. | 1099 * @param regularTabCreator A {@link ChromeTabCreator} instance. |
| 1070 */ | 1100 */ |
| 1071 public void setTabCreators(TabCreatorManager.TabCreator regularTabCreator, | 1101 public void setTabCreators(TabCreatorManager.TabCreator regularTabCreator, |
| (...skipping 536 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... | |
| 1608 public static int getThemeId() { | 1638 public static int getThemeId() { |
| 1609 boolean useLowEndTheme = | 1639 boolean useLowEndTheme = |
| 1610 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP; | 1640 SysUtils.isLowEndDevice() && Build.VERSION.SDK_INT >= Build.VERS ION_CODES.LOLLIPOP; |
| 1611 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme); | 1641 return (useLowEndTheme ? R.style.MainTheme_LowEnd : R.style.MainTheme); |
| 1612 } | 1642 } |
| 1613 | 1643 |
| 1614 private void setLowEndTheme() { | 1644 private void setLowEndTheme() { |
| 1615 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd); | 1645 if (getThemeId() == R.style.MainTheme_LowEnd) setTheme(R.style.MainTheme _LowEnd); |
| 1616 } | 1646 } |
| 1617 } | 1647 } |
| OLD | NEW |