Java Code Examples for org.chromium.base.ApiCompatibilityUtils#setStatusBarColor()
The following examples show how to use
org.chromium.base.ApiCompatibilityUtils#setStatusBarColor() .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ChromeTabbedActivity.java From delion with Apache License 2.0 | 5 votes |
@Override public void onOverviewModeStartedShowing(boolean showToolbar) { if (mFindToolbarManager != null) mFindToolbarManager.hideToolbar(); if (getAssistStatusHandler() != null) getAssistStatusHandler().updateAssistState(); if (getAppMenuHandler() != null) getAppMenuHandler().hideAppMenu(); ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); StartupMetrics.getInstance().recordOpenedTabSwitcher(); }
Example 2
Source File: CustomTabActivity.java From delion with Apache License 2.0 | 5 votes |
@Override public void postInflationStartup() { super.postInflationStartup(); setTabModelSelector(new TabModelSelectorImpl(this, TabModelSelectorImpl.CUSTOM_TABS_SELECTOR_INDEX, getWindowAndroid(), false)); getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable()); getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState() == CustomTabsIntent.SHOW_PAGE_TITLE); if (CustomTabsConnection.getInstance(getApplication()) .shouldHideDomainForSession(mSession)) { getToolbarManager().setUrlBarHidden(true); } int toolbarColor = mIntentDataProvider.getToolbarColor(); getToolbarManager().updatePrimaryColor(toolbarColor, false); if (!mIntentDataProvider.isOpenedByChrome()) { getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); } if (toolbarColor != ApiCompatibilityUtils.getColor( getResources(), R.color.default_primary_color)) { ApiCompatibilityUtils.setStatusBarColor(getWindow(), ColorUtils.getDarkenedColorForStatusBar(toolbarColor)); } // Setting task title and icon to be null will preserve the client app's title and icon. ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor); showCustomButtonOnToolbar(); mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider); mBottomBarDelegate.showBottomBarIfNecessary(); }
Example 3
Source File: WebappActivity.java From delion with Apache License 2.0 | 5 votes |
private void updateTaskDescription() { String title = null; if (!TextUtils.isEmpty(mWebappInfo.shortName())) { title = mWebappInfo.shortName(); } else if (getActivityTab() != null) { title = getActivityTab().getTitle(); } Bitmap icon = null; if (mWebappInfo.icon() != null) { icon = mWebappInfo.icon(); } else if (getActivityTab() != null) { icon = mLargestFavicon; } if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { mBrandColor = (int) mWebappInfo.themeColor(); } int taskDescriptionColor = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color); int statusBarColor = Color.BLACK; if (mBrandColor != null) { taskDescriptionColor = mBrandColor; statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor); } ApiCompatibilityUtils.setTaskDescription(this, title, icon, ColorUtils.getOpaqueColor(taskDescriptionColor)); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 4
Source File: ChromeTabbedActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void onOverviewModeStartedShowing(boolean showToolbar) { if (mFindToolbarManager != null) mFindToolbarManager.hideToolbar(); if (getAssistStatusHandler() != null) getAssistStatusHandler().updateAssistState(); if (getAppMenuHandler() != null) getAppMenuHandler().hideAppMenu(); ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); StartupMetrics.getInstance().recordOpenedTabSwitcher(); }
Example 5
Source File: CustomTabActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void postInflationStartup() { super.postInflationStartup(); getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable()); getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState() == CustomTabsIntent.SHOW_PAGE_TITLE); if (CustomTabsConnection.getInstance(getApplication()) .shouldHideDomainForSession(mSession)) { getToolbarManager().setUrlBarHidden(true); } int toolbarColor = mIntentDataProvider.getToolbarColor(); getToolbarManager().updatePrimaryColor(toolbarColor, false); if (!mIntentDataProvider.isOpenedByChrome()) { getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); } if (toolbarColor != ApiCompatibilityUtils.getColor( getResources(), R.color.default_primary_color)) { ApiCompatibilityUtils.setStatusBarColor(getWindow(), ColorUtils.getDarkenedColorForStatusBar(toolbarColor)); } // Setting task title and icon to be null will preserve the client app's title and icon. ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor); showCustomButtonOnToolbar(); mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider); mBottomBarDelegate.showBottomBarIfNecessary(); }
Example 6
Source File: WebappActivity.java From AndroidChromium with Apache License 2.0 | 5 votes |
private void updateTaskDescription() { String title = null; if (!TextUtils.isEmpty(mWebappInfo.shortName())) { title = mWebappInfo.shortName(); } else if (getActivityTab() != null) { title = getActivityTab().getTitle(); } Bitmap icon = null; if (mWebappInfo.icon() != null) { icon = mWebappInfo.icon(); } else if (getActivityTab() != null) { icon = mLargestFavicon; } if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { mBrandColor = (int) mWebappInfo.themeColor(); } int taskDescriptionColor = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color); int statusBarColor = Color.BLACK; if (mBrandColor != null) { taskDescriptionColor = mBrandColor; statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor); } ApiCompatibilityUtils.setTaskDescription(this, title, icon, ColorUtils.getOpaqueColor(taskDescriptionColor)); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 7
Source File: ChromeTabbedActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void onOverviewModeStartedShowing(boolean showToolbar) { if (mFindToolbarManager != null) mFindToolbarManager.hideToolbar(); if (getAssistStatusHandler() != null) getAssistStatusHandler().updateAssistState(); if (getAppMenuHandler() != null) getAppMenuHandler().hideAppMenu(); ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); StartupMetrics.getInstance().recordOpenedTabSwitcher(); }
Example 8
Source File: CustomTabActivity.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void postInflationStartup() { super.postInflationStartup(); getToolbarManager().setCloseButtonDrawable(mIntentDataProvider.getCloseButtonDrawable()); getToolbarManager().setShowTitle(mIntentDataProvider.getTitleVisibilityState() == CustomTabsIntent.SHOW_PAGE_TITLE); if (CustomTabsConnection.getInstance(getApplication()) .shouldHideDomainForSession(mSession)) { getToolbarManager().setUrlBarHidden(true); } int toolbarColor = mIntentDataProvider.getToolbarColor(); getToolbarManager().updatePrimaryColor(toolbarColor, false); if (!mIntentDataProvider.isOpenedByChrome()) { getToolbarManager().setShouldUpdateToolbarPrimaryColor(false); } if (toolbarColor != ApiCompatibilityUtils.getColor( getResources(), R.color.default_primary_color)) { ApiCompatibilityUtils.setStatusBarColor(getWindow(), ColorUtils.getDarkenedColorForStatusBar(toolbarColor)); } // Properly attach tab's infobar to the view hierarchy, as the main tab might have been // initialized prior to inflation. if (mMainTab != null) { ViewGroup bottomContainer = (ViewGroup) findViewById(R.id.bottom_container); mMainTab.getInfoBarContainer().setParentView(bottomContainer); } // Setting task title and icon to be null will preserve the client app's title and icon. ApiCompatibilityUtils.setTaskDescription(this, null, null, toolbarColor); showCustomButtonOnToolbar(); mBottomBarDelegate = new CustomTabBottomBarDelegate(this, mIntentDataProvider, getFullscreenManager()); mBottomBarDelegate.showBottomBarIfNecessary(); }
Example 9
Source File: WebappActivity.java From 365browser with Apache License 2.0 | 5 votes |
private void updateTaskDescription() { String title = null; if (!TextUtils.isEmpty(mWebappInfo.shortName())) { title = mWebappInfo.shortName(); } else if (getActivityTab() != null) { title = getActivityTab().getTitle(); } Bitmap icon = null; if (mWebappInfo.icon() != null) { icon = mWebappInfo.icon(); } else if (getActivityTab() != null) { icon = mLargestFavicon; } if (mBrandColor == null && mWebappInfo.hasValidThemeColor()) { mBrandColor = (int) mWebappInfo.themeColor(); } int taskDescriptionColor = ApiCompatibilityUtils.getColor(getResources(), R.color.default_primary_color); // Don't use the brand color for the status bars if we're in display: fullscreen. This works // around an issue where the status bars go transparent and can't be seen on top of the page // content when users swipe them in or they appear because the on-screen keyboard was // triggered. int statusBarColor = Color.BLACK; if (mBrandColor != null && mWebappInfo.displayMode() != WebDisplayMode.FULLSCREEN) { taskDescriptionColor = mBrandColor; statusBarColor = ColorUtils.getDarkenedColorForStatusBar(mBrandColor); } ApiCompatibilityUtils.setTaskDescription(this, title, icon, ColorUtils.getOpaqueColor(taskDescriptionColor)); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 10
Source File: ChromeActivity.java From delion with Apache License 2.0 | 4 votes |
/** * This function builds the {@link CompositorViewHolder}. Subclasses *must* call * super.setContentView() before using {@link #getTabModelSelector()} or * {@link #getCompositorViewHolder()}. */ @Override protected final void setContentView() { final long begin = SystemClock.elapsedRealtime(); TraceEvent.begin("onCreate->setContentView()"); enableHardwareAcceleration(); setLowEndTheme(); int controlContainerLayoutId = getControlContainerLayoutId(); WarmupManager warmupManager = WarmupManager.getInstance(); if (warmupManager.hasBuiltOrClearViewHierarchyWithToolbar(controlContainerLayoutId)) { View placeHolderView = new View(this); setContentView(placeHolderView); ViewGroup contentParent = (ViewGroup) placeHolderView.getParent(); WarmupManager.getInstance().transferViewHierarchyTo(contentParent); contentParent.removeView(placeHolderView); } else { setContentView(R.layout.main); if (controlContainerLayoutId != NO_CONTROL_CONTAINER) { ViewStub toolbarContainerStub = ((ViewStub) findViewById(R.id.control_container_stub)); toolbarContainerStub.setLayoutResource(controlContainerLayoutId); toolbarContainerStub.inflate(); } } TraceEvent.end("onCreate->setContentView()"); mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; // Set the status bar color to black by default. This is an optimization for // Chrome not to draw under status and navigation bars when we use the default // black status bar ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView(); mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder); mCompositorViewHolder.setRootView(rootView); // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets. rootView.setFitsSystemWindows(false); // Add a custom view right after the root view that stores the insets to access later. // ContentViewCore needs the insets to determine the portion of the screen obscured by // non-content displaying things such as the OSK. mInsetObserverView = InsetObserverView.create(this); rootView.addView(mInsetObserverView, 0); }
Example 11
Source File: ChromeActivity.java From delion with Apache License 2.0 | 4 votes |
/** * Set device status bar to a given color. * @param tab The tab that is currently showing. * @param color The color that the status bar should be set to. */ protected void setStatusBarColor(Tab tab, int color) { int statusBarColor = (tab != null && tab.isDefaultThemeColor()) ? Color.BLACK : ColorUtils.getDarkenedColorForStatusBar(color); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 12
Source File: ChromeActivity.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * This function builds the {@link CompositorViewHolder}. Subclasses *must* call * super.setContentView() before using {@link #getTabModelSelector()} or * {@link #getCompositorViewHolder()}. */ @Override protected final void setContentView() { final long begin = SystemClock.elapsedRealtime(); TraceEvent.begin("onCreate->setContentView()"); enableHardwareAcceleration(); setLowEndTheme(); int controlContainerLayoutId = getControlContainerLayoutId(); WarmupManager warmupManager = WarmupManager.getInstance(); if (warmupManager.hasViewHierarchyWithToolbar(controlContainerLayoutId)) { View placeHolderView = new View(this); setContentView(placeHolderView); ViewGroup contentParent = (ViewGroup) placeHolderView.getParent(); warmupManager.transferViewHierarchyTo(contentParent); contentParent.removeView(placeHolderView); } else { warmupManager.clearViewHierarchy(); // Allow disk access for the content view and toolbar container setup. // On certain android devices this setup sequence results in disk writes outside // of our control, so we have to disable StrictMode to work. See crbug.com/639352. StrictMode.ThreadPolicy oldPolicy = StrictMode.allowThreadDiskWrites(); try { setContentView(R.layout.main); if (controlContainerLayoutId != NO_CONTROL_CONTAINER) { ViewStub toolbarContainerStub = ((ViewStub) findViewById(R.id.control_container_stub)); toolbarContainerStub.setLayoutResource(controlContainerLayoutId); toolbarContainerStub.inflate(); } // It cannot be assumed that the result of toolbarContainerStub.inflate() will be // the control container since it may be wrapped in another view. ControlContainer controlContainer = (ControlContainer) findViewById(R.id.control_container); // Inflate the correct toolbar layout for the device. int toolbarLayoutId = getToolbarLayoutId(); if (toolbarLayoutId != NO_TOOLBAR_LAYOUT && controlContainer != null) { controlContainer.initWithToolbar(toolbarLayoutId); } } finally { StrictMode.setThreadPolicy(oldPolicy); } } TraceEvent.end("onCreate->setContentView()"); mInflateInitialLayoutDurationMs = SystemClock.elapsedRealtime() - begin; // Set the status bar color to black by default. This is an optimization for // Chrome not to draw under status and navigation bars when we use the default // black status bar ApiCompatibilityUtils.setStatusBarColor(getWindow(), Color.BLACK); ViewGroup rootView = (ViewGroup) getWindow().getDecorView().getRootView(); mCompositorViewHolder = (CompositorViewHolder) findViewById(R.id.compositor_view_holder); mCompositorViewHolder.setRootView(rootView); // Setting fitsSystemWindows to false ensures that the root view doesn't consume the insets. rootView.setFitsSystemWindows(false); // Add a custom view right after the root view that stores the insets to access later. // ContentViewCore needs the insets to determine the portion of the screen obscured by // non-content displaying things such as the OSK. mInsetObserverView = InsetObserverView.create(this); rootView.addView(mInsetObserverView, 0); }
Example 13
Source File: ChromeActivity.java From AndroidChromium with Apache License 2.0 | 4 votes |
/** * Set device status bar to a given color. * @param tab The tab that is currently showing. * @param color The color that the status bar should be set to. */ protected void setStatusBarColor(Tab tab, int color) { int statusBarColor = (tab != null && tab.isDefaultThemeColor()) ? Color.BLACK : ColorUtils.getDarkenedColorForStatusBar(color); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }
Example 14
Source File: ChromeActivity.java From 365browser with Apache License 2.0 | 4 votes |
/** * Set device status bar to a given color. * @param tab The tab that is currently showing. * @param color The color that the status bar should be set to. */ protected void setStatusBarColor(Tab tab, int color) { int statusBarColor = (tab != null && tab.isDefaultThemeColor()) ? Color.BLACK : ColorUtils.getDarkenedColorForStatusBar(color); ApiCompatibilityUtils.setStatusBarColor(getWindow(), statusBarColor); }