Java Code Examples for org.chromium.chrome.browser.tab.Tab#getView()

The following examples show how to use org.chromium.chrome.browser.tab.Tab#getView() . 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: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
private void setTab(Tab tab) {
    if (tab != null) tab.loadIfNeeded();

    View newView = tab != null ? tab.getView() : null;
    if (mView == newView) return;

    // TODO(dtrainor): Look into changing this only if the views differ, but still parse the
    // ContentViewCore list even if they're the same.
    updateContentOverlayVisibility(false);

    if (mTabVisible != tab) {
        if (mTabVisible != null) mTabVisible.removeObserver(mTabObserver);
        if (tab != null) tab.addObserver(mTabObserver);
    }

    mTabVisible = tab;
    mView = newView;

    updateContentOverlayVisibility(mContentOverlayVisiblity);

    if (mTabVisible != null) initializeTab(mTabVisible);
}
 
Example 2
Source File: CompositorViewHolder.java    From delion with Apache License 2.0 6 votes vote down vote up
/**
 * Sets the correct size for all {@link View}s on {@code tab} and sets the correct rendering
 * parameters on all {@link ContentViewCore}s on {@code tab}.
 * @param tab The {@link Tab} to initialize.
 */
private void initializeTab(Tab tab) {
    sCachedCVCList.clear();
    if (mLayoutManager != null) {
        mLayoutManager.getActiveLayout().getAllContentViewCores(sCachedCVCList);
    }

    for (int i = 0; i < sCachedCVCList.size(); i++) {
        initializeContentViewCore(sCachedCVCList.get(i));
    }
    sCachedCVCList.clear();

    sCachedViewList.clear();
    tab.getAllContentViews(sCachedViewList);

    for (int i = 0; i < sCachedViewList.size(); i++) {
        View view = sCachedViewList.get(i);
        // Calling View#measure() and View#layout() on a View before adding it to the view
        // hierarchy seems to cause issues with compound drawables on some versions of Android.
        // We don't need to proactively size the NTP as we don't need the Android view to render
        // if it's not actually attached to the view hierarchy (http://crbug.com/462114).
        if (view == tab.getView() && tab.isNativePage()) continue;
        setSizeOfUnattachedView(view);
    }
    sCachedViewList.clear();
}
 
Example 3
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 6 votes vote down vote up
private void setTab(Tab tab) {
    if (tab != null) tab.loadIfNeeded();

    TabContentViewParent newView = tab != null ? tab.getView() : null;
    if (mView == newView) return;

    // TODO(dtrainor): Look into changing this only if the views differ, but still parse the
    // ContentViewCore list even if they're the same.
    updateContentOverlayVisibility(false);

    if (mTabVisible != tab) {
        if (mTabVisible != null) mTabVisible.removeObserver(mTabObserver);
        if (tab != null) tab.addObserver(mTabObserver);
    }

    mTabVisible = tab;
    mView = newView;

    updateContentOverlayVisibility(mContentOverlayVisiblity);

    if (mTabVisible != null) initializeTab(mTabVisible);
}
 
Example 4
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 6 votes vote down vote up
private void setTab(Tab tab) {
    if (tab != null) tab.loadIfNeeded();

    View newView = tab != null ? tab.getView() : null;
    if (mView == newView) return;

    // TODO(dtrainor): Look into changing this only if the views differ, but still parse the
    // ContentViewCore list even if they're the same.
    updateContentOverlayVisibility(false);

    if (mTabVisible != tab) {
        if (mTabVisible != null) mTabVisible.removeObserver(mTabObserver);
        if (tab != null) tab.addObserver(mTabObserver);
    }

    mTabVisible = tab;
    mView = newView;

    updateContentOverlayVisibility(mContentOverlayVisiblity);

    if (mTabVisible != null) initializeTab(mTabVisible);
}
 
Example 5
Source File: Layout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return A {@link View} that should be the one the user can interact with.  This can be
 *         {@code null} if there is no {@link View} representing {@link Tab} content that should
 *         be interacted with at this time.
 */
public View getViewForInteraction() {
    if (!shouldDisplayContentOverlay()) return null;

    Tab tab = mTabModelSelector.getCurrentTab();
    if (tab == null) return null;

    return tab.getView();
}
 
Example 6
Source File: StackViewAnimation.java    From delion with Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 7
Source File: ToolbarLayout.java    From delion with Apache License 2.0 5 votes vote down vote up
/**
 * @return The current View showing in the Tab.
 */
protected View getCurrentTabView() {
    Tab tab = mToolbarDataProvider.getTab();
    if (tab != null) {
        return tab.getView();
    }
    return null;
}
 
Example 8
Source File: CompositorViewHolder.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the correct size for {@link View} on {@code tab} and sets the correct rendering
 * parameters on {@link ContentViewCore} on {@code tab}.
 * @param tab The {@link Tab} to initialize.
 */
private void initializeTab(Tab tab) {
    ContentViewCore content = tab.getActiveContentViewCore();
    if (content != null) initializeContentViewCore(content);

    View view = tab.getContentView();
    if (view != tab.getView() || !tab.isNativePage()) setSizeOfUnattachedView(view);
}
 
Example 9
Source File: Layout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return A {@link View} that should be the one the user can interact with.  This can be
 *         {@code null} if there is no {@link View} representing {@link Tab} content that should
 *         be interacted with at this time.
 */
public View getViewForInteraction() {
    if (!shouldDisplayContentOverlay()) return null;

    Tab tab = mTabModelSelector.getCurrentTab();
    if (tab == null) return null;

    return tab.getView();
}
 
Example 10
Source File: StackViewAnimation.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 11
Source File: ToolbarLayout.java    From AndroidChromium with Apache License 2.0 5 votes vote down vote up
/**
 * @return The current View showing in the Tab.
 */
protected View getCurrentTabView() {
    Tab tab = mToolbarDataProvider.getTab();
    if (tab != null) {
        return tab.getView();
    }
    return null;
}
 
Example 12
Source File: CompositorViewHolder.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * Sets the correct size for {@link View} on {@code tab} and sets the correct rendering
 * parameters on {@link ContentViewCore} on {@code tab}.
 * @param tab The {@link Tab} to initialize.
 */
private void initializeTab(Tab tab) {
    ContentViewCore content = tab.getActiveContentViewCore();
    if (content != null) initializeContentViewCore(content);

    View view = tab.getContentView();
    if (view != tab.getView() || !tab.isNativePage()) setSizeOfUnattachedView(view);
}
 
Example 13
Source File: StackViewAnimation.java    From 365browser with Apache License 2.0 5 votes vote down vote up
private Animator createNewTabOpenedAnimator(
        StackTab[] tabs, ViewGroup container, TabModel model, int focusIndex) {
    Tab tab = model.getTabAt(focusIndex);
    if (tab == null || !tab.isNativePage()) return null;

    View view = tab.getView();
    if (view == null) return null;

    // Set up the view hierarchy
    if (view.getParent() != null) ((ViewGroup) view.getParent()).removeView(view);
    ViewGroup bgView = new FrameLayout(view.getContext());
    bgView.setBackgroundColor(tab.getBackgroundColor());
    bgView.addView(view);
    container.addView(
            bgView, new LayoutParams(LayoutParams.MATCH_PARENT, LayoutParams.MATCH_PARENT));

    // Update any compositor state that needs to change
    if (tabs != null && focusIndex >= 0 && focusIndex < tabs.length) {
        tabs[focusIndex].setAlpha(0.f);
    }

    // Build the view animations
    PropertyValuesHolder xScale = PropertyValuesHolder.ofFloat(View.SCALE_X, 0.f, 1.f);
    PropertyValuesHolder yScale = PropertyValuesHolder.ofFloat(View.SCALE_Y, 0.f, 1.f);
    PropertyValuesHolder alpha = PropertyValuesHolder.ofFloat(View.ALPHA, 0.f, 1.f);
    ObjectAnimator animator = ObjectAnimator.ofPropertyValuesHolder(
            bgView, xScale, yScale, alpha);

    animator.setDuration(TAB_OPENED_ANIMATION_DURATION);
    animator.setInterpolator(BakedBezierInterpolator.TRANSFORM_FOLLOW_THROUGH_CURVE);

    float insetPx = TAB_OPENED_PIVOT_INSET_DP * mDpToPx;

    bgView.setPivotY(TAB_OPENED_PIVOT_INSET_DP);
    bgView.setPivotX(LocalizationUtils.isLayoutRtl() ? mWidthDp * mDpToPx - insetPx : insetPx);
    return animator;
}
 
Example 14
Source File: ToolbarLayout.java    From 365browser with Apache License 2.0 5 votes vote down vote up
/**
 * @return The current View showing in the Tab.
 */
protected View getCurrentTabView() {
    Tab tab = mToolbarDataProvider.getTab();
    if (tab != null) {
        return tab.getView();
    }
    return null;
}
 
Example 15
Source File: InfoBarContainer.java    From 365browser with Apache License 2.0 5 votes vote down vote up
public InfoBarContainer(Context context, final ViewGroup parentView, Tab tab) {
    super(context, null);
    tab.addObserver(mTabObserver);
    mTabView = tab.getView();
    mTab = tab;

    // TODO(newt): move this workaround into the infobar views if/when they're scrollable.
    // Workaround for http://crbug.com/407149. See explanation in onMeasure() below.
    setVerticalScrollBarEnabled(false);

    FrameLayout.LayoutParams lp = new FrameLayout.LayoutParams(
            LayoutParams.MATCH_PARENT, LayoutParams.WRAP_CONTENT, Gravity.BOTTOM);
    int topMarginDp = DeviceFormFactor.isTablet() ? TOP_MARGIN_TABLET_DP : TOP_MARGIN_PHONE_DP;
    lp.topMargin = Math.round(topMarginDp * getResources().getDisplayMetrics().density);
    setLayoutParams(lp);

    mParentView = parentView;

    mLayout = new InfoBarContainerLayout(context);
    addView(mLayout, new FrameLayout.LayoutParams(LayoutParams.MATCH_PARENT,
            LayoutParams.WRAP_CONTENT, Gravity.CENTER_HORIZONTAL));

    mIPHSupport = new IPHInfoBarSupport(context);
    mLayout.addAnimationListener(mIPHSupport);
    addObserver(mIPHSupport);

    // Chromium's InfoBarContainer may add an InfoBar immediately during this initialization
    // call, so make sure everything in the InfoBarContainer is completely ready beforehand.
    mNativeInfoBarContainer = nativeInit();
}
 
Example 16
Source File: InfoBarContainer.java    From 365browser with Apache License 2.0 4 votes vote down vote up
@Override
public void onContentChanged(Tab tab) {
    mTabView.removeOnAttachStateChangeListener(mAttachedStateListener);
    mTabView = tab.getView();
    mTabView.addOnAttachStateChangeListener(mAttachedStateListener);
}