org.chromium.ui.resources.ResourceManager Java Examples

The following examples show how to use org.chromium.ui.resources.ResourceManager. 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: TabStripSceneLayer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Pushes all relevant {@link StripLayoutTab}s to the CC Layer tree.
 * This also pushes any other assets required to draw the Tab Strip.  This should only be called
 * when the Compositor has disabled ScheduleComposite calls as this will change the tree and
 * could subsequently cause unnecessary follow up renders.
 *
 * @param layoutHelper A layout helper for the tab strip.
 * @param layerTitleCache A layer title cache.
 * @param resourceManager A resource manager.
 * @param stripLayoutTabsToRender Array of strip layout tabs.
 * @param yOffset Current browser controls offset in dp.
 */
public void pushAndUpdateStrip(StripLayoutHelperManager layoutHelper,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager,
        StripLayoutTab[] stripLayoutTabsToRender, float yOffset, int selectedTabId) {
    if (mNativePtr == 0) return;

    final boolean visible = yOffset > -layoutHelper.getHeight();
    // This will hide the tab strips if necessary.
    nativeBeginBuildingFrame(mNativePtr, visible);
    // When strip tabs are completely off screen, we don't need to update it.
    if (visible) {
        pushButtonsAndBackground(layoutHelper, resourceManager, yOffset);
        pushStripTabs(layoutHelper, layerTitleCache, resourceManager, stripLayoutTabsToRender,
                selectedTabId);
    }
    nativeFinishBuildingFrame(mNativePtr);
}
 
Example #2
Source File: TabStripSceneLayer.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void pushStripTabs(StripLayoutHelperManager layoutHelper,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager,
        StripLayoutTab[] stripTabs, int selectedTabId) {
    final int tabsCount = stripTabs != null ? stripTabs.length : 0;

    for (int i = 0; i < tabsCount; i++) {
        final StripLayoutTab st = stripTabs[i];
        boolean isSelected = st.getId() == selectedTabId;
        nativePutStripTabLayer(mNativePtr, st.getId(), st.getCloseButton().getResourceId(),
                st.getResourceId(isSelected), isSelected, st.getClosePressed(),
                layoutHelper.getWidth() * mDpToPx, st.getDrawX() * mDpToPx,
                st.getDrawY() * mDpToPx, st.getWidth() * mDpToPx, st.getHeight() * mDpToPx,
                st.getContentOffsetX() * mDpToPx, st.getCloseButton().getOpacity(),
                st.isLoading(), st.getLoadingSpinnerRotation(), layoutHelper.getBorderOpacity(),
                layerTitleCache, resourceManager);
    }
}
 
Example #3
Source File: StaticLayout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
        return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mSceneLayer.update(dpToPx, contentViewport, layerTitleCache, tabContentManager,
            fullscreenManager, layoutTab);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null
            && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
        TabModelImpl.logPerceivedTabSwitchLatencyMetric();
    }
}
 
Example #4
Source File: TabStripSceneLayer.java    From delion with Apache License 2.0 6 votes vote down vote up
private void pushStripTabs(StripLayoutHelperManager layoutHelper,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager,
        StripLayoutTab[] stripTabs, int selectedTabId) {
    final int tabsCount = stripTabs != null ? stripTabs.length : 0;

    for (int i = 0; i < tabsCount; i++) {
        final StripLayoutTab st = stripTabs[i];
        boolean isSelected = st.getId() == selectedTabId;
        nativePutStripTabLayer(mNativePtr, st.getId(), st.getCloseButton().getResourceId(),
                st.getResourceId(isSelected), isSelected, st.getClosePressed(),
                layoutHelper.getWidth() * mDpToPx, st.getDrawX() * mDpToPx,
                st.getDrawY() * mDpToPx, st.getWidth() * mDpToPx, st.getHeight() * mDpToPx,
                st.getContentOffsetX() * mDpToPx, st.getCloseButton().getOpacity(),
                st.isLoading(), st.getLoadingSpinnerRotation(), layoutHelper.getBorderOpacity(),
                layerTitleCache, resourceManager);
    }
}
 
Example #5
Source File: StaticLayout.java    From delion with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
        return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mSceneLayer.update(dpToPx, contentViewport, layerTitleCache, tabContentManager,
            fullscreenManager, layoutTab);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null
            && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
        TabModelImpl.logPerceivedTabSwitchLatencyMetric();
    }
}
 
Example #6
Source File: Layout.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
 *
 * @param viewport          A viewport in which to display content.
 * @param contentViewport   The visible section of the viewport.
 * @param layerTitleCache   A layer title cache.
 * @param tabContentManager A tab content manager.
 * @param resourceManager   A resource manager.
 * @param fullscreenManager A fullscreen manager.
 * @return                  A {@link SceneLayer} that represents the content for this
 *                          {@link Layout}.
 */
public final SceneLayer getUpdatedSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);

    float offsetPx = fullscreenManager != null ? fullscreenManager.getControlOffset() : 0.f;
    float dpToPx = getContext().getResources().getDisplayMetrics().density;
    float offsetDp = offsetPx / dpToPx;

    SceneLayer content = getSceneLayer();
    for (int i = 0; i < mSceneOverlays.size(); i++) {
        // If the SceneOverlay is not showing, don't bother adding it to the tree.
        if (!mSceneOverlays.get(i).isSceneOverlayTreeShowing()) continue;

        SceneOverlayLayer overlayLayer = mSceneOverlays.get(i).getUpdatedSceneOverlayTree(
                layerTitleCache, resourceManager, offsetDp);

        overlayLayer.setContentTree(content);
        content = overlayLayer;
    }

    return content;
}
 
Example #7
Source File: TabStripSceneLayer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void pushStripTabs(StripLayoutHelperManager layoutHelper,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager,
        StripLayoutTab[] stripTabs, int selectedTabId) {
    final int tabsCount = stripTabs != null ? stripTabs.length : 0;

    for (int i = 0; i < tabsCount; i++) {
        final StripLayoutTab st = stripTabs[i];
        boolean isSelected = st.getId() == selectedTabId;
        nativePutStripTabLayer(mNativePtr, st.getId(), st.getCloseButton().getResourceId(),
                st.getResourceId(isSelected), isSelected, st.getClosePressed(),
                layoutHelper.getWidth() * mDpToPx, st.getDrawX() * mDpToPx,
                st.getDrawY() * mDpToPx, st.getWidth() * mDpToPx, st.getHeight() * mDpToPx,
                st.getContentOffsetX() * mDpToPx, st.getCloseButton().getOpacity(),
                st.isLoading(), st.getLoadingSpinnerRotation(), layoutHelper.getBorderOpacity(),
                layerTitleCache, resourceManager);
    }
}
 
Example #8
Source File: StaticLayout.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
protected void updateSceneLayer(RectF viewport, RectF contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;

    final LayoutTab[] tabs = getLayoutTabsToRender();
    if (tabs == null || tabs.length != 1 || tabs[0].getId() == Tab.INVALID_TAB_ID) {
        return;
    }
    LayoutTab layoutTab = tabs[0];
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;

    mSceneLayer.update(
            dpToPx, layerTitleCache, tabContentManager, fullscreenManager, layoutTab);

    // TODO(dtrainor): Find the best way to properly track this metric for cold starts.
    // We should probably erase the thumbnail when we select a tab that we need to restore.
    if (tabContentManager != null
            && tabContentManager.hasFullCachedThumbnail(layoutTab.getId())) {
        TabModelImpl.logPerceivedTabSwitchLatencyMetric();
    }
}
 
Example #9
Source File: Layout.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
/**
 * Build a {@link SceneLayer} if it hasn't already been built, and update it and return it.
 *
 * @param viewport          A viewport in which to display content.
 * @param contentViewport   The visible section of the viewport.
 * @param layerTitleCache   A layer title cache.
 * @param tabContentManager A tab content manager.
 * @param resourceManager   A resource manager.
 * @param fullscreenManager A fullscreen manager.
 * @return                  A {@link SceneLayer} that represents the content for this
 *                          {@link Layout}.
 */
public final SceneLayer getUpdatedSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);

    float offsetPx = fullscreenManager != null ? fullscreenManager.getTopControlOffset() : 0.f;
    float dpToPx = getContext().getResources().getDisplayMetrics().density;
    float offsetDp = offsetPx / dpToPx;

    SceneLayer content = getSceneLayer();
    for (int i = 0; i < mSceneOverlays.size(); i++) {
        // If the SceneOverlay is not showing, don't bother adding it to the tree.
        if (!mSceneOverlays.get(i).isSceneOverlayTreeShowing()) continue;

        SceneOverlayLayer overlayLayer = mSceneOverlays.get(i).getUpdatedSceneOverlayTree(
                layerTitleCache, resourceManager, offsetDp);

        overlayLayer.setContentTree(content);
        content = overlayLayer;
    }

    return content;
}
 
Example #10
Source File: ToolbarSceneLayer.java    From 365browser with Apache License 2.0 6 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(RectF viewport, RectF visibleViewport,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager, float yOffset) {
    boolean forceHideBrowserControlsAndroidView =
            mLayoutProvider.getActiveLayout().forceHideBrowserControlsAndroidView();
    ViewportMode viewportMode = mLayoutProvider.getActiveLayout().getViewportMode();

    // TODO(mdjones): Create a "theme provider" to handle cases like this.
    int color = mRenderHost.getBrowserControlsBackgroundColor();
    float alpha = mRenderHost.getBrowserControlsUrlBarAlpha();
    ChromeFullscreenManager fullscreenManager = mLayoutProvider.getFullscreenManager();
    if (fullscreenManager.areBrowserControlsAtBottom() && fullscreenManager.getTab() != null) {
        color = fullscreenManager.getTab().getDefaultThemeColor();
        if (!fullscreenManager.getTab().isIncognito()) alpha = 1f;
    }

    update(color, alpha, mLayoutProvider.getFullscreenManager(), resourceManager,
            forceHideBrowserControlsAndroidView, viewportMode, DeviceFormFactor.isTablet(),
            viewport.height());

    return this;
}
 
Example #11
Source File: LayoutManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public SceneLayer getUpdatedActiveSceneLayer(LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ResourceManager resourceManager,
        ChromeFullscreenManager fullscreenManager) {
    // Update the android browser controls state.
    if (fullscreenManager != null) {
        fullscreenManager.setHideBrowserControlsAndroidView(
                mActiveLayout.forceHideBrowserControlsAndroidView());
    }

    getViewportPixel(mCachedVisibleViewport);
    mHost.getWindowViewport(mCachedWindowViewport);
    return mActiveLayout.getUpdatedSceneLayer(mCachedWindowViewport, mCachedVisibleViewport,
            layerTitleCache, tabContentManager, resourceManager, fullscreenManager);
}
 
Example #12
Source File: ToolbarSceneLayer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private native void nativeUpdateToolbarLayer(
long nativeToolbarSceneLayer,
ResourceManager resourceManager,
int resourceId,
int toolbarBackgroundColor,
int urlBarResourceId,
float urlBarAlpha,
float topOffset,
float viewHeight,
boolean visible,
boolean showShadow,
boolean browserControlsAtBottom);
 
Example #13
Source File: TabStripSceneLayer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private void pushButtonsAndBackground(StripLayoutHelperManager layoutHelper,
        ResourceManager resourceManager, float yOffset) {
    final float width = layoutHelper.getWidth() * mDpToPx;
    final float height = layoutHelper.getHeight() * mDpToPx;
    nativeUpdateTabStripLayer(mNativePtr, width, height, yOffset * mDpToPx,
            layoutHelper.getBackgroundTabBrightness(), layoutHelper.getBrightness(),
            shouldReaddBackground(layoutHelper.getOrientation()));

    CompositorButton newTabButton = layoutHelper.getNewTabButton();
    CompositorButton modelSelectorButton = layoutHelper.getModelSelectorButton();
    boolean newTabButtonVisible = newTabButton.isVisible();
    boolean modelSelectorButtonVisible = modelSelectorButton.isVisible();

    nativeUpdateNewTabButton(mNativePtr, newTabButton.getResourceId(),
            newTabButton.getX() * mDpToPx, newTabButton.getY() * mDpToPx,
            newTabButton.getWidth() * mDpToPx, newTabButton.getHeight() * mDpToPx,
            newTabButtonVisible, resourceManager);

    nativeUpdateModelSelectorButton(mNativePtr, modelSelectorButton.getResourceId(),
            modelSelectorButton.getX() * mDpToPx, modelSelectorButton.getY() * mDpToPx,
            modelSelectorButton.getWidth() * mDpToPx, modelSelectorButton.getHeight() * mDpToPx,
            modelSelectorButton.isIncognito(), modelSelectorButtonVisible, resourceManager);

    int leftFadeDrawable = modelSelectorButtonVisible && LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;
    int rightFadeDrawable = modelSelectorButtonVisible && !LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;

    nativeUpdateTabStripLeftFade(mNativePtr, leftFadeDrawable,
            layoutHelper.getLeftFadeOpacity(), resourceManager);

    nativeUpdateTabStripRightFade(mNativePtr, rightFadeDrawable,
            layoutHelper.getRightFadeOpacity(), resourceManager);
}
 
Example #14
Source File: ToolbarSceneLayer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(LayerTitleCache layerTitleCache,
        ResourceManager resourceManager, float yOffset) {
    boolean forceHideBrowserControlsAndroidView =
            mLayoutProvider.getActiveLayout().forceHideBrowserControlsAndroidView();
    int flags = mLayoutProvider.getActiveLayout().getSizingFlags();

    update(mRenderHost.getBrowserControlsBackgroundColor(),
            mRenderHost.getBrowserControlsUrlBarAlpha(), mLayoutProvider.getFullscreenManager(),
            resourceManager, forceHideBrowserControlsAndroidView, flags,
            DeviceFormFactor.isTablet(mContext));

    return this;
}
 
Example #15
Source File: TabStripSceneLayer.java    From delion with Apache License 2.0 5 votes vote down vote up
private void pushButtonsAndBackground(StripLayoutHelperManager layoutHelper,
        ResourceManager resourceManager, float yOffset) {
    final float width = layoutHelper.getWidth() * mDpToPx;
    final float height = layoutHelper.getHeight() * mDpToPx;
    nativeUpdateTabStripLayer(mNativePtr, width, height, yOffset * mDpToPx,
            layoutHelper.getBackgroundTabBrightness(), layoutHelper.getBrightness(),
            shouldReaddBackground(layoutHelper.getOrientation()));

    CompositorButton newTabButton = layoutHelper.getNewTabButton();
    CompositorButton modelSelectorButton = layoutHelper.getModelSelectorButton();
    boolean newTabButtonVisible = newTabButton.isVisible();
    boolean modelSelectorButtonVisible = modelSelectorButton.isVisible();

    nativeUpdateNewTabButton(mNativePtr, newTabButton.getResourceId(),
            newTabButton.getX() * mDpToPx, newTabButton.getY() * mDpToPx,
            newTabButton.getWidth() * mDpToPx, newTabButton.getHeight() * mDpToPx,
            newTabButtonVisible, resourceManager);

    nativeUpdateModelSelectorButton(mNativePtr, modelSelectorButton.getResourceId(),
            modelSelectorButton.getX() * mDpToPx, modelSelectorButton.getY() * mDpToPx,
            modelSelectorButton.getWidth() * mDpToPx, modelSelectorButton.getHeight() * mDpToPx,
            modelSelectorButton.isIncognito(), modelSelectorButtonVisible, resourceManager);

    int leftFadeDrawable = modelSelectorButtonVisible && LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;
    int rightFadeDrawable = modelSelectorButtonVisible && !LocalizationUtils.isLayoutRtl()
            ? R.drawable.tab_strip_fade_for_model_selector : R.drawable.tab_strip_fade;

    nativeUpdateTabStripLeftFade(mNativePtr, leftFadeDrawable,
            layoutHelper.getLeftFadeOpacity(), resourceManager);

    nativeUpdateTabStripRightFade(mNativePtr, rightFadeDrawable,
            layoutHelper.getRightFadeOpacity(), resourceManager);
}
 
Example #16
Source File: StripLayoutHelperManager.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(RectF viewport, RectF visibleViewport,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager, float yOffset) {
    assert mTabStripTreeProvider != null;

    Tab selectedTab = mTabModelSelector.getCurrentModel().getTabAt(
            mTabModelSelector.getCurrentModel().index());
    int selectedTabId = selectedTab == null ? TabModel.INVALID_TAB_INDEX : selectedTab.getId();
    mTabStripTreeProvider.pushAndUpdateStrip(this, layerTitleCache, resourceManager,
            getActiveStripLayoutHelper().getStripLayoutTabsToRender(), yOffset,
            selectedTabId);
    return mTabStripTreeProvider;
}
 
Example #17
Source File: ContextualSearchPanel.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(LayerTitleCache layerTitleCache,
        ResourceManager resourceManager, float yOffset) {
    mSceneLayer.update(resourceManager, this,
            getSearchBarControl(),
            getPeekPromoControl(),
            getPromoControl(),
            getIconSpriteControl());

    return mSceneLayer;
}
 
Example #18
Source File: ReaderModePanel.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(LayerTitleCache layerTitleCache,
        ResourceManager resourceManager, float yOffset) {
    mSceneLayer.update(resourceManager, this, getBarTextViewId(), mReaderBarTextOpacity);

    return mSceneLayer;
}
 
Example #19
Source File: LayoutManagerChromeTablet.java    From delion with Apache License 2.0 5 votes vote down vote up
@Override
public SceneLayer getUpdatedActiveSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    return super.getUpdatedActiveSceneLayer(viewport, contentViewport, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #20
Source File: StripLayoutHelperManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(LayerTitleCache layerTitleCache,
        ResourceManager resourceManager, float yOffset) {
    assert mTabStripTreeProvider != null;

    Tab selectedTab = mTabModelSelector.getCurrentModel().getTabAt(
            mTabModelSelector.getCurrentModel().index());
    int selectedTabId = selectedTab == null ? TabModel.INVALID_TAB_INDEX : selectedTab.getId();
    mTabStripTreeProvider.pushAndUpdateStrip(this, layerTitleCache, resourceManager,
            getActiveStripLayoutHelper().getStripLayoutTabsToRender(), yOffset,
            selectedTabId);
    return mTabStripTreeProvider;
}
 
Example #21
Source File: StripLayoutTab.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private RectF getCloseRect() {
    if (!LocalizationUtils.isLayoutRtl()) {
        mClosePlacement.left = getWidth() - CLOSE_BUTTON_WIDTH_DP;
        mClosePlacement.right = mClosePlacement.left + CLOSE_BUTTON_WIDTH_DP;
    } else {
        mClosePlacement.left = 0;
        mClosePlacement.right = CLOSE_BUTTON_WIDTH_DP;
    }

    mClosePlacement.top = 0;
    mClosePlacement.bottom = getHeight();

    float xOffset = 0;
    ResourceManager manager = mRenderHost.getResourceManager();
    if (manager != null) {
        LayoutResource resource =
                manager.getResource(AndroidResourceType.STATIC, getResourceId(false));
        if (resource != null) {
            xOffset = LocalizationUtils.isLayoutRtl()
                    ? resource.getPadding().left
                    : -(resource.getBitmapSize().width() - resource.getPadding().right);
        }
    }

    mClosePlacement.offset(getDrawX() + xOffset, getDrawY());
    return mClosePlacement;
}
 
Example #22
Source File: ReaderModeSceneLayer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Update the scene layer to draw an OverlayPanel.
 * @param resourceManager Manager to get view and image resources.
 * @param panel The OverlayPanel to render.
 * @param barTextViewId The ID of the view containing the Reader Mode text.
 * @param barTextOpacity The opacity of the text specified by {@code barTextViewId}.
 */
public void update(ResourceManager resourceManager, OverlayPanel panel, int barTextViewId,
        float barTextOpacity) {
    // Don't try to update the layer if not initialized or showing.
    if (resourceManager == null || !panel.isShowing()) return;

    if (!mIsInitialized) {
        nativeCreateReaderModeLayer(mNativePtr, resourceManager);
        // TODO(mdjones): Rename contextual search resources below to be generic to overlay
        // panels.
        nativeSetResourceIds(mNativePtr,
                barTextViewId,
                R.drawable.contextual_search_bar_background,
                R.drawable.contextual_search_bar_shadow,
                R.drawable.infobar_mobile_friendly,
                R.drawable.btn_close);
        mIsInitialized = true;
    }

    WebContents panelWebContents = panel.getContentViewCore() != null
            ? panel.getContentViewCore().getWebContents() : null;

    nativeUpdate(mNativePtr,
            mDpToPx,
            panel.getBasePageBrightness(),
            panel.getBasePageY() * mDpToPx,
            panelWebContents,
            panel.getOffsetX() * mDpToPx,
            panel.getOffsetY() * mDpToPx,
            panel.getWidth() * mDpToPx,
            panel.getHeight() * mDpToPx,
            panel.getBarMarginSide() * mDpToPx,
            panel.getBarHeight() * mDpToPx,
            barTextOpacity,
            panel.isBarBorderVisible(),
            panel.getBarBorderHeight() * mDpToPx,
            panel.getBarShadowVisible(),
            panel.getBarShadowOpacity());
}
 
Example #23
Source File: ContextualSearchPanel.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(RectF viewport, RectF visibleViewport,
        LayerTitleCache layerTitleCache, ResourceManager resourceManager, float yOffset) {
    mSceneLayer.update(resourceManager, this,
            getSearchBarControl(),
            getPeekPromoControl(),
            getPromoControl(),
            getImageControl());

    return mSceneLayer;
}
 
Example #24
Source File: SimpleAnimationLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSceneLayer(RectF viewport, RectF contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;
    // The content viewport is intentionally sent as both params below.
    mSceneLayer.pushLayers(getContext(), contentViewport, contentViewport, this,
            layerTitleCache, tabContentManager, resourceManager, fullscreenManager);
}
 
Example #25
Source File: ToolbarSwipeLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;
    mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #26
Source File: ReaderModeSceneLayer.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Update the scene layer to draw an OverlayPanel.
 * @param resourceManager Manager to get view and image resources.
 * @param panel The OverlayPanel to render.
 * @param barTextViewId The ID of the view containing the Reader Mode text.
 * @param barTextOpacity The opacity of the text specified by {@code barTextViewId}.
 */
public void update(ResourceManager resourceManager, OverlayPanel panel, int barTextViewId,
        float barTextOpacity) {
    // Don't try to update the layer if not initialized or showing.
    if (resourceManager == null || !panel.isShowing()) return;

    if (!mIsInitialized) {
        nativeCreateReaderModeLayer(mNativePtr, resourceManager);
        // TODO(mdjones): Rename contextual search resources below to be generic to overlay
        // panels.
        nativeSetResourceIds(mNativePtr,
                barTextViewId,
                R.drawable.contextual_search_bar_background,
                R.drawable.contextual_search_bar_shadow,
                R.drawable.infobar_mobile_friendly,
                R.drawable.btn_close);
        mIsInitialized = true;
    }

    WebContents panelWebContents = panel.getContentViewCore() != null
            ? panel.getContentViewCore().getWebContents() : null;

    nativeUpdate(mNativePtr,
            mDpToPx,
            panel.getBasePageBrightness(),
            panel.getBasePageY() * mDpToPx,
            panelWebContents,
            panel.getOffsetX() * mDpToPx,
            panel.getOffsetY() * mDpToPx,
            panel.getWidth() * mDpToPx,
            panel.getHeight() * mDpToPx,
            panel.getBarMarginSide() * mDpToPx,
            panel.getBarHeight() * mDpToPx,
            barTextOpacity,
            panel.isBarBorderVisible(),
            panel.getBarBorderHeight() * mDpToPx,
            panel.getBarShadowVisible(),
            panel.getBarShadowOpacity());
}
 
Example #27
Source File: LayoutManager.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public SceneLayer getUpdatedActiveSceneLayer(Rect viewport, LayerTitleCache layerTitleCache,
        TabContentManager tabContentManager, ResourceManager resourceManager,
        ChromeFullscreenManager fullscreenManager) {
    getViewportPixel(mCachedVisibleViewport);
    // TODO(mdjones): The concept of visible viewport is pretty confising since |viewport| can
    // also take the browser controls into consideration; this should be made more clear.
    // Furthermore, the below adjustments should not be necessary.
    mCachedVisibleViewport.right = mCachedVisibleViewport.left + mHost.getWidth();
    mCachedVisibleViewport.bottom = mCachedVisibleViewport.top + mHost.getHeight();
    return mActiveLayout.getUpdatedSceneLayer(viewport, mCachedVisibleViewport, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #28
Source File: SimpleAnimationLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
protected void updateSceneLayer(Rect viewport, Rect contentViewport,
        LayerTitleCache layerTitleCache, TabContentManager tabContentManager,
        ResourceManager resourceManager, ChromeFullscreenManager fullscreenManager) {
    super.updateSceneLayer(viewport, contentViewport, layerTitleCache, tabContentManager,
            resourceManager, fullscreenManager);
    assert mSceneLayer != null;
    mSceneLayer.pushLayers(getContext(), viewport, contentViewport, this, layerTitleCache,
            tabContentManager, resourceManager, fullscreenManager);
}
 
Example #29
Source File: ReaderModePanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(LayerTitleCache layerTitleCache,
        ResourceManager resourceManager, float yOffset) {
    mSceneLayer.update(resourceManager, this, getBarTextViewId(), mReaderBarTextOpacity);

    return mSceneLayer;
}
 
Example #30
Source File: ContextualSearchPanel.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
@Override
public SceneOverlayLayer getUpdatedSceneOverlayTree(LayerTitleCache layerTitleCache,
        ResourceManager resourceManager, float yOffset) {
    mSceneLayer.update(resourceManager, this,
            getSearchBarControl(),
            getPeekPromoControl(),
            getPromoControl(),
            getImageControl());

    return mSceneLayer;
}