Ejemplo n.º 1
0
 @Override
 protected boolean onUpdateAnimation(long time, boolean jumpToEnd) {
   boolean parentAnimating = super.onUpdateAnimation(time, jumpToEnd);
   boolean panelAnimating =
       mReaderModePanel != null ? mReaderModePanel.onUpdateAnimation(time, jumpToEnd) : false;
   return panelAnimating || parentAnimating;
 }
Ejemplo n.º 2
0
  private void setStaticTab(final int id) {
    if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
      if (!mLayoutTabs[0].shouldStall()) setPostHideState();
      return;
    }
    TabModel model = mTabModelSelector.getModelForTabId(id);
    if (model == null) return;
    updateCacheVisibleIds(new LinkedList<Integer>(Arrays.asList(id)));
    if (mLayoutTabs == null || mLayoutTabs.length != 1) mLayoutTabs = new LayoutTab[1];
    mLayoutTabs[0] = createLayoutTab(id, model.isIncognito(), NO_CLOSE_BUTTON, NO_TITLE);
    mLayoutTabs[0].setDrawDecoration(false);
    if (mLayoutTabs[0].shouldStall()) {
      setPreHideState();
      mHandler.postDelayed(mUnstallRunnable, HIDE_TIMEOUT_MS);
    } else {
      setPostHideState();
    }
    mReaderModePanel = ReaderModePanel.getReaderModePanel(mTabModelSelector.getTabById(id));
    if (mReaderModePanel != null) {
      mReaderModePanel.setLayoutDelegate(
          new ReaderModePanelLayoutDelegate() {
            @Override
            public void requestUpdate() {
              StaticLayout.this.requestUpdate();
            }

            @Override
            public void setLayoutTabBrightness(float v) {
              if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
                mLayoutTabs[0].setBrightness(v);
              }
            }

            @Override
            public void setLayoutTabY(float v) {
              if (mLayoutTabs != null && mLayoutTabs.length > 0 && mLayoutTabs[0].getId() == id) {
                mLayoutTabs[0].setY(v);
              }
            }
          });
      final boolean isToolbarVisible = getHeight() == getHeightMinusTopControls();
      final float dpToPx = getContext().getResources().getDisplayMetrics().density;
      mReaderModePanel.onSizeChanged(getWidth(), getHeight(), isToolbarVisible, dpToPx);
    }
    requestRender();
  }
Ejemplo n.º 3
0
  @Override
  protected void notifySizeChanged(float width, float height, int orientation) {
    super.notifySizeChanged(width, height, orientation);
    if (mReaderModePanel == null) return;

    final boolean isToolbarVisible = getHeight() == getHeightMinusTopControls();
    final float dpToPx = getContext().getResources().getDisplayMetrics().density;
    mReaderModePanel.onSizeChanged(width, height, isToolbarVisible, dpToPx);
  }
Ejemplo n.º 4
0
  @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;

    mReaderModeSceneLayer.update(mReaderModePanel, resourceManager);

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

    // TODO(pedrosimonetti): Coordinate w/ dtrainor@ to improve integration with TreeProvider.
    SceneLayer overlayLayer = null;
    if (mSearchPanel.isShowing()) {
      overlayLayer = super.getSceneLayer();
    } else if (mReaderModePanel != null && mReaderModePanel.isShowing()) {
      overlayLayer = mReaderModeSceneLayer;
    }
    mSceneLayer.setContentSceneLayer(overlayLayer);

    // 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())) {
      TabModelBase.logPerceivedTabSwitchLatencyMetric();
    }
  }
Ejemplo n.º 5
0
 @Override
 public float getTopControlsOffset(float currentOffsetDp) {
   if (mReaderModePanel == null) return super.getTopControlsOffset(currentOffsetDp);
   return mReaderModePanel.getTopControlsOffset(currentOffsetDp);
 }