org.chromium.chrome.browser.util.ViewUtils Java Examples
The following examples show how to use
org.chromium.chrome.browser.util.ViewUtils.
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: ChromeFullscreenManager.java From AndroidChromium with Apache License 2.0 | 6 votes |
/** * @param e The dispatched motion event * @return Whether or not this motion event is in the top control container area and should be * consumed. */ public boolean onInterceptMotionEvent(MotionEvent e) { int bottomPosition; int topPosition = 0; float offset; if (mIsBottomControls) { int[] position = new int[2]; ViewUtils.getRelativeLayoutPosition(mControlContainer.getView().getRootView(), mControlContainer.getView(), position); topPosition = position[1]; bottomPosition = topPosition + getBottomControlsHeight(); offset = getBottomControlOffset(); } else { bottomPosition = getTopControlsHeight(); offset = getTopControlOffset(); } return e.getY() < topPosition + offset && e.getY() > bottomPosition + offset && !mBrowserControlsAndroidViewHidden; }
Example #2
Source File: CardViewHolder.java From AndroidChromium with Apache License 2.0 | 6 votes |
@Override public void updateLayoutParams() { // Nothing to do for dismissed cards. if (getAdapterPosition() == RecyclerView.NO_POSITION) return; NewTabPageAdapter adapter = mRecyclerView.getNewTabPageAdapter(); // Each card has the full elevation effect (the shadow) in the 9-patch. If the next item is // a card a negative bottom margin is set so the next card is overlaid slightly on top of // this one and hides the bottom shadow. int abovePosition = getAdapterPosition() - 1; boolean hasCardAbove = abovePosition >= 0 && isCard(adapter.getItemViewType(abovePosition)); int belowPosition = getAdapterPosition() + 1; boolean hasCardBelow = belowPosition < adapter.getItemCount() && isCard(adapter.getItemViewType(belowPosition)); getParams().bottomMargin = hasCardBelow ? -mCards9PatchAdjustment : 0; @DrawableRes int selectedBackground = selectBackground(hasCardAbove, hasCardBelow); if (mBackground != selectedBackground) { mBackground = selectedBackground; ViewUtils.setNinePatchBackgroundResource(itemView, selectedBackground); } }
Example #3
Source File: ToolbarLayout.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void getLocationBarContentRect(Rect outRect) { View container = getLocationBar().getContainerView(); outRect.set(container.getPaddingLeft(), container.getPaddingTop(), container.getWidth() - container.getPaddingRight(), container.getHeight() - container.getPaddingBottom()); ViewUtils.getRelativeDrawPosition( this, getLocationBar().getContainerView(), mTempPosition); outRect.offset(mTempPosition[0], mTempPosition[1]); }
Example #4
Source File: ToolbarControlContainer.java From 365browser with Apache License 2.0 | 5 votes |
@Override public boolean gatherTransparentRegion(Region region) { // Reset the translation on the control container before attempting to compute the // transparent region. float translateY = getTranslationY(); setTranslationY(0); ViewUtils.gatherTransparentRegionsForOpaqueView(this, region); setTranslationY(translateY); return true; }
Example #5
Source File: ToolbarLayout.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void getLocationBarContentRect(Rect outRect) { View container = getLocationBar().getContainerView(); outRect.set(container.getPaddingLeft(), container.getPaddingTop(), container.getWidth() - container.getPaddingRight(), container.getHeight() - container.getPaddingBottom()); ViewUtils.getRelativeDrawPosition( this, getLocationBar().getContainerView(), mTempPosition); outRect.offset(mTempPosition[0], mTempPosition[1]); }
Example #6
Source File: IncognitoNewTabPageView.java From 365browser with Apache License 2.0 | 5 votes |
/** * @see org.chromium.chrome.browser.compositor.layouts.content. * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas) */ void captureThumbnail(Canvas canvas) { ViewUtils.captureBitmap(this, canvas); mSnapshotWidth = getWidth(); mSnapshotHeight = getHeight(); mSnapshotScrollY = mScrollView.getScrollY(); }
Example #7
Source File: NewTabPageView.java From 365browser with Apache License 2.0 | 5 votes |
/** * @see org.chromium.chrome.browser.compositor.layouts.content. * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas) */ void captureThumbnail(Canvas canvas) { mSearchProviderLogoView.endFadeAnimation(); ViewUtils.captureBitmap(this, canvas); mSnapshotWidth = getWidth(); mSnapshotHeight = getHeight(); mSnapshotScrollY = mRecyclerView.computeVerticalScrollOffset(); mSnapshotTileGridChanged = false; mNewTabPageRecyclerViewChanged = false; }
Example #8
Source File: NewTabPageView.java From 365browser with Apache License 2.0 | 5 votes |
/** * Updates the opacity of the search box when scrolling. * * @param alpha opacity (alpha) value to use. */ public void setSearchBoxAlpha(float alpha) { mSearchBoxView.setAlpha(alpha); // Disable the search box contents if it is the process of being animated away. ViewUtils.setEnabledRecursive(mSearchBoxView, mSearchBoxView.getAlpha() == 1.0f); }
Example #9
Source File: CardViewHolder.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void updateLayoutParams() { // Nothing to do for dismissed cards. if (getAdapterPosition() == RecyclerView.NO_POSITION) return; NewTabPageAdapter adapter = mRecyclerView.getNewTabPageAdapter(); // Each card has the full elevation effect (the shadow) in the 9-patch. If the next item is // a card a negative bottom margin is set so the next card is overlaid slightly on top of // this one and hides the bottom shadow. int abovePosition = getAdapterPosition() - 1; boolean hasCardAbove = abovePosition >= 0 && isCard(adapter.getItemViewType(abovePosition)); int belowPosition = getAdapterPosition() + 1; boolean hasCardBelow = false; if (belowPosition < adapter.getItemCount()) { // The PROMO card has an empty margin and will not be right against the preceding card, // so we don't consider it a card from the point of view of the preceding one. @ItemViewType int belowViewType = adapter.getItemViewType(belowPosition); hasCardBelow = isCard(belowViewType) && belowViewType != ItemViewType.PROMO; } @DrawableRes int selectedBackground = selectBackground(hasCardAbove, hasCardBelow); if (mBackground == selectedBackground) return; mBackground = selectedBackground; ViewUtils.setNinePatchBackgroundResource(itemView, selectedBackground); // By default the apparent distance between two cards is the sum of the bottom and top // height of their shadows. We want |mCardGap| instead, so we set the bottom margin to // the difference. // noinspection ResourceType getParams().bottomMargin = hasCardBelow ? (mCardGap - (mCardShadow.top + mCardShadow.bottom)) : 0; }
Example #10
Source File: RecentTabsPage.java From 365browser with Apache License 2.0 | 5 votes |
@Override public void captureThumbnail(Canvas canvas) { ViewUtils.captureBitmap(mView, canvas); mSnapshotContentChanged = false; mSnapshotListPosition = mListView.getFirstVisiblePosition(); View topItem = mListView.getChildAt(0); mSnapshotListTop = topItem == null ? 0 : topItem.getTop(); mSnapshotWidth = mView.getWidth(); mSnapshotHeight = mView.getHeight(); }
Example #11
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The right offset for the suggestion text. */ private int getSuggestionTextRightPosition() { if (mLocationBar == null) return 0; int leftOffset = getUrlBarLeftOffset(); View contentView = getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, this, mViewPositionHolder); return leftOffset + mUrlBar.getWidth() - mUrlBar.getPaddingRight() - mViewPositionHolder[0]; }
Example #12
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 5 votes |
/** * @return The left offset for the suggestion text. */ private int getSuggestionTextLeftPosition() { if (mLocationBar == null) return 0; int leftOffset = getUrlBarLeftOffset(); View contentView = getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, this, mViewPositionHolder); return leftOffset + mUrlBar.getPaddingLeft() - mViewPositionHolder[0]; }
Example #13
Source File: SuggestionView.java From 365browser with Apache License 2.0 | 5 votes |
private int getUrlBarLeftOffset() { if (mLocationBar.mustQueryUrlBarLocationForSuggestions()) { View contentView = getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mUrlBar, mViewPositionHolder); return mViewPositionHolder[0]; } else { return ApiCompatibilityUtils.isLayoutRtl(this) ? mPhoneUrlBarLeftOffsetRtlPx : mPhoneUrlBarLeftOffsetPx; } }
Example #14
Source File: ToolbarControlContainer.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public boolean gatherTransparentRegion(Region region) { // Reset the translation on the control container before attempting to compute the // transparent region. float translateY = getTranslationY(); setTranslationY(0); ViewUtils.gatherTransparentRegionsForOpaqueView(this, region); setTranslationY(translateY); return true; }
Example #15
Source File: RecentTabsPage.java From delion with Apache License 2.0 | 5 votes |
@Override public void captureThumbnail(Canvas canvas) { ViewUtils.captureBitmap(mView, canvas); mSnapshotContentChanged = false; mSnapshotListPosition = mListView.getFirstVisiblePosition(); View topItem = mListView.getChildAt(0); mSnapshotListTop = topItem == null ? 0 : topItem.getTop(); mSnapshotWidth = mView.getWidth(); mSnapshotHeight = mView.getHeight(); }
Example #16
Source File: NewTabPageView.java From delion with Apache License 2.0 | 5 votes |
/** * @see org.chromium.chrome.browser.compositor.layouts.content. * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas) */ void captureThumbnail(Canvas canvas) { mSearchProviderLogoView.endFadeAnimation(); ViewUtils.captureBitmap(this, canvas); mSnapshotWidth = getWidth(); mSnapshotHeight = getHeight(); mSnapshotScrollY = getVerticalScroll(); mSnapshotMostVisitedChanged = false; }
Example #17
Source File: IncognitoNewTabPageView.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @see org.chromium.chrome.browser.compositor.layouts.content. * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas) */ void captureThumbnail(Canvas canvas) { ViewUtils.captureBitmap(this, canvas); mSnapshotWidth = getWidth(); mSnapshotHeight = getHeight(); mSnapshotScrollY = mScrollView.getScrollY(); }
Example #18
Source File: NewTabPageView.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * @see org.chromium.chrome.browser.compositor.layouts.content. * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas) */ void captureThumbnail(Canvas canvas) { mSearchProviderLogoView.endFadeAnimation(); ViewUtils.captureBitmap(this, canvas); mSnapshotWidth = getWidth(); mSnapshotHeight = getHeight(); mSnapshotScrollY = getVerticalScroll(); mSnapshotMostVisitedChanged = false; mNewTabPageRecyclerViewChanged = false; }
Example #19
Source File: NewTabPageView.java From AndroidChromium with Apache License 2.0 | 5 votes |
/** * Updates the opacity of the search box when scrolling. * * @param alpha opacity (alpha) value to use. */ public void setSearchBoxAlpha(float alpha) { mSearchBoxView.setAlpha(alpha); // Disable the search box contents if it is the process of being animated away. ViewUtils.setEnabledRecursive(mSearchBoxView, mSearchBoxView.getAlpha() == 1.0f); }
Example #20
Source File: RecentTabsPage.java From AndroidChromium with Apache License 2.0 | 5 votes |
@Override public void captureThumbnail(Canvas canvas) { ViewUtils.captureBitmap(mView, canvas); mSnapshotContentChanged = false; mSnapshotListPosition = mListView.getFirstVisiblePosition(); View topItem = mListView.getChildAt(0); mSnapshotListTop = topItem == null ? 0 : topItem.getTop(); mSnapshotWidth = mView.getWidth(); mSnapshotHeight = mView.getHeight(); }
Example #21
Source File: IncognitoNewTabPageView.java From delion with Apache License 2.0 | 5 votes |
/** * @see org.chromium.chrome.browser.compositor.layouts.content. * InvalidationAwareThumbnailProvider#captureThumbnail(Canvas) */ void captureThumbnail(Canvas canvas) { ViewUtils.captureBitmap(this, canvas); mSnapshotWidth = getWidth(); mSnapshotHeight = getHeight(); mSnapshotScrollY = mScrollView.getScrollY(); }
Example #22
Source File: ToolbarLayout.java From delion with Apache License 2.0 | 5 votes |
@Override public void getLocationBarContentRect(Rect outRect) { View container = getLocationBar().getContainerView(); outRect.set(container.getPaddingLeft(), container.getPaddingTop(), container.getWidth() - container.getPaddingRight(), container.getHeight() - container.getPaddingBottom()); ViewUtils.getRelativeDrawPosition( this, getLocationBar().getContainerView(), mTempPosition); outRect.offset(mTempPosition[0], mTempPosition[1]); }
Example #23
Source File: NewTabPageRecyclerView.java From 365browser with Apache License 2.0 | 4 votes |
@Override public boolean gatherTransparentRegion(Region region) { ViewUtils.gatherTransparentRegionsForOpaqueView(this, region); return true; }
Example #24
Source File: ToolbarLayout.java From 365browser with Apache License 2.0 | 4 votes |
@Override public void getPositionRelativeToContainer(View containerView, int[] position) { ViewUtils.getRelativeDrawPosition(containerView, this, position); }
Example #25
Source File: SignInPreference.java From 365browser with Apache License 2.0 | 4 votes |
@Override protected void onBindView(View view) { super.onBindView(view); ViewUtils.setEnabledRecursive(view, mViewEnabled); }
Example #26
Source File: ToolbarLayout.java From delion with Apache License 2.0 | 4 votes |
@Override public void getPositionRelativeToContainer(View containerView, int[] position) { ViewUtils.getRelativeDrawPosition(containerView, this, position); }
Example #27
Source File: LocationBarLayout.java From AndroidChromium with Apache License 2.0 | 4 votes |
private void updateLayoutParams() { boolean updateLayout = false; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams(); if (layoutParams == null) { layoutParams = new FrameLayout.LayoutParams(0, 0); setLayoutParams(layoutParams); } // Compare the relative positions of the anchor view to the list parent view to // determine the offset to apply to the suggestions list. By using layout positioning, // this avoids issues where getLocationInWindow can be inaccurate on certain devices. View contentView = LocationBarLayout.this.getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); int anchorX = mTempPosition[0]; int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, (View) getParent(), mTempPosition); int parentY = mTempPosition[1]; int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int desiredTopMargin = anchorBottomRelativeToContent - parentY; if (layoutParams.topMargin != desiredTopMargin) { layoutParams.topMargin = desiredTopMargin; updateLayout = true; } int contentLeft = contentView.getLeft(); int anchorLeftRelativeToContent = anchorX - contentLeft; if (layoutParams.leftMargin != anchorLeftRelativeToContent) { layoutParams.leftMargin = anchorLeftRelativeToContent; updateLayout = true; } getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); int decorHeight = getWindowDelegate().getDecorViewHeight(); int availableViewportHeight = Math.min(mTempRect.height(), decorHeight); int availableListHeight = availableViewportHeight - anchorBottomRelativeToContent; int desiredHeight = Math.min(availableListHeight, getIdealHeight()); if (layoutParams.height != desiredHeight) { layoutParams.height = desiredHeight; updateLayout = true; } int desiredWidth = getDesiredWidth(); if (layoutParams.width != desiredWidth) { layoutParams.width = desiredWidth; updateLayout = true; } if (updateLayout) requestLayout(); }
Example #28
Source File: LocationBarLayout.java From 365browser with Apache License 2.0 | 4 votes |
private void updateLayoutParams() { boolean updateLayout = false; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams(); if (layoutParams == null) { layoutParams = new FrameLayout.LayoutParams(0, 0); setLayoutParams(layoutParams); } // Compare the relative positions of the anchor view to the list parent view to // determine the offset to apply to the suggestions list. By using layout positioning, // this avoids issues where getLocationInWindow can be inaccurate on certain devices. View contentView = LocationBarLayout.this.getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); int anchorX = mTempPosition[0]; int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, (View) getParent(), mTempPosition); int parentY = mTempPosition[1]; int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int desiredTopMargin = anchorBottomRelativeToContent - parentY; if (layoutParams.topMargin != desiredTopMargin) { layoutParams.topMargin = desiredTopMargin; updateLayout = true; } int contentLeft = contentView.getLeft(); int anchorLeftRelativeToContent = anchorX - contentLeft; if (layoutParams.leftMargin != anchorLeftRelativeToContent) { layoutParams.leftMargin = anchorLeftRelativeToContent; updateLayout = true; } getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); int decorHeight = getWindowDelegate().getDecorViewHeight(); int availableViewportHeight = Math.min(mTempRect.height(), decorHeight); int availableListHeight = availableViewportHeight - anchorBottomRelativeToContent; // If the bottom sheet is used, the suggestions should consume all available space. int desiredHeight = mBottomSheet != null ? availableListHeight : Math.min(availableListHeight, getIdealHeight()); if (layoutParams.height != desiredHeight) { layoutParams.height = desiredHeight; updateLayout = true; } int desiredWidth = getDesiredWidth(); if (layoutParams.width != desiredWidth) { layoutParams.width = desiredWidth; updateLayout = true; } if (updateLayout) requestLayout(); }
Example #29
Source File: NewTabPageRecyclerView.java From AndroidChromium with Apache License 2.0 | 4 votes |
@Override public boolean gatherTransparentRegion(Region region) { ViewUtils.gatherTransparentRegionsForOpaqueView(this, region); return true; }
Example #30
Source File: LocationBarLayout.java From delion with Apache License 2.0 | 4 votes |
private void updateLayoutParams() { boolean updateLayout = false; FrameLayout.LayoutParams layoutParams = (FrameLayout.LayoutParams) getLayoutParams(); if (layoutParams == null) { layoutParams = new FrameLayout.LayoutParams(0, 0); setLayoutParams(layoutParams); } // Compare the relative positions of the anchor view to the list parent view to // determine the offset to apply to the suggestions list. By using layout positioning, // this avoids issues where getLocationInWindow can be inaccurate on certain devices. View contentView = LocationBarLayout.this.getRootView().findViewById(android.R.id.content); ViewUtils.getRelativeLayoutPosition(contentView, mAnchorView, mTempPosition); int anchorX = mTempPosition[0]; int anchorY = mTempPosition[1]; ViewUtils.getRelativeLayoutPosition(contentView, (View) getParent(), mTempPosition); int parentY = mTempPosition[1]; int anchorBottomRelativeToContent = anchorY + mAnchorView.getMeasuredHeight(); int desiredTopMargin = anchorBottomRelativeToContent - parentY; if (layoutParams.topMargin != desiredTopMargin) { layoutParams.topMargin = desiredTopMargin; updateLayout = true; } int contentLeft = contentView.getLeft(); int anchorLeftRelativeToContent = anchorX - contentLeft; if (layoutParams.leftMargin != anchorLeftRelativeToContent) { layoutParams.leftMargin = anchorLeftRelativeToContent; updateLayout = true; } getWindowDelegate().getWindowVisibleDisplayFrame(mTempRect); int decorHeight = getWindowDelegate().getDecorViewHeight(); int availableViewportHeight = Math.min(mTempRect.height(), decorHeight); int availableListHeight = availableViewportHeight - anchorBottomRelativeToContent; int desiredHeight = Math.min(availableListHeight, getIdealHeight()); if (layoutParams.height != desiredHeight) { layoutParams.height = desiredHeight; updateLayout = true; } int desiredWidth = getDesiredWidth(); if (layoutParams.width != desiredWidth) { layoutParams.width = desiredWidth; updateLayout = true; } if (updateLayout) requestLayout(); }