Java Code Examples for android.graphics.Outline#setRect()

The following examples show how to use android.graphics.Outline#setRect() . 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: LineDrawable.java    From ProjectX with Apache License 2.0 6 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(Outline outline) {
    final int[] state = getState();
    final int backgroundColor = DrawableHelper.getColor(mBackgroundColor, state, mAlpha);
    final int backgroundAlpha = Color.alpha(backgroundColor);
    if (backgroundAlpha != 0) {
        outline.setRect(getBounds());
        outline.setAlpha(backgroundAlpha / 255f);
        return;
    }
    final int lineColor = DrawableHelper.getColor(mLineColor, state, mAlpha);
    final int lineAlpha = Color.alpha(lineColor);
    outline.setRect(Math.round(mLine.left - 0.5f), Math.round(mLine.top - 0.5f),
            Math.round(mLine.right + 0.5f), Math.round(mLine.bottom + 0.5f));
    outline.setAlpha(lineAlpha / 255f);
}
 
Example 2
Source File: HeaderElevationController.java    From LaunchEnr with GNU General Public License v3.0 6 votes vote down vote up
HeaderElevationController(View header) {
    mHeader = header;
    final Resources res = mHeader.getContext().getResources();
    mMaxElevation = res.getDimension(R.dimen.all_apps_header_max_elevation);
    mScrollToElevation = res.getDimension(R.dimen.all_apps_header_scroll_to_elevation);

    // We need to provide a custom outline so the shadow only appears on the bottom edge.
    // The top, left and right edges are all extended out, and the shadow is clipped
    // by the parent.
    final ViewOutlineProvider vop = new ViewOutlineProvider() {
        @Override
        public void getOutline(View view, Outline outline) {
            final View parent = (View) mHeader.getParent();

            final int left = parent.getLeft(); // Use the parent to account for offsets
            final int top = view.getTop();
            final int right = left + view.getWidth();
            final int bottom = view.getBottom();

            final int offset = Utilities.pxFromDp(mMaxElevation, res.getDisplayMetrics());
            outline.setRect(left - offset, top - offset, right + offset, bottom);
        }
    };
    mHeader.setOutlineProvider(vop);
}
 
Example 3
Source File: ViewOutlineProviderCompatUtilsLXX.java    From AOSP-Kayboard-7.1.2 with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(final View view, final Outline outline) {
    if (mLastVisibleTopInsets == NO_DATA) {
        // Call default implementation.
        ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
        return;
    }
    // TODO: Revisit this when floating/resize keyboard is supported.
    outline.setRect(
            view.getLeft(), mLastVisibleTopInsets, view.getRight(), view.getBottom());
}
 
Example 4
Source File: ViewOutlineProviderCompatUtilsLXX.java    From Indic-Keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(final View view, final Outline outline) {
    if (mLastVisibleTopInsets == NO_DATA) {
        // Call default implementation.
        ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
        return;
    }
    // TODO: Revisit this when floating/resize keyboard is supported.
    outline.setRect(
            view.getLeft(), mLastVisibleTopInsets, view.getRight(), view.getBottom());
}
 
Example 5
Source File: WXBackgroundDrawable.java    From weex with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(@NonNull Outline outline) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    super.getOutline(outline);
  } else {
    if ((!CSSConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) {
      updatePath();

      outline.setConvexPath(mPathForBorderRadiusOutline);
    } else {
      outline.setRect(getBounds());
    }
  }

}
 
Example 6
Source File: BaseShape.java    From libcommon with Apache License 2.0 5 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
   public void getOutline(final Outline outline) {
       final RectF rect = boundsRect();
       outline.setRect((int) Math.ceil(rect.left), (int) Math.ceil(rect.top),
               (int) Math.floor(rect.right), (int) Math.floor(rect.bottom));
   }
 
Example 7
Source File: ViewOutlineProvider.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    Drawable background = view.getBackground();
    if (background != null) {
        background.getOutline(outline);
    } else {
        outline.setRect(0, 0, view.getWidth(), view.getHeight());
        outline.setAlpha(0.0f);
    }
}
 
Example 8
Source File: ViewOutlineProviderCompatUtilsLXX.java    From simple-keyboard with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(final View view, final Outline outline) {
    if (mLastVisibleTopInsets == NO_DATA) {
        // Call default implementation.
        ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
        return;
    }
    // TODO: Revisit this when floating/resize keyboard is supported.
    outline.setRect(
            view.getLeft(), mLastVisibleTopInsets, view.getRight(), view.getBottom());
}
 
Example 9
Source File: ReactViewBackgroundDrawable.java    From react-native-GPay with MIT License 5 votes vote down vote up
@Override
public void getOutline(Outline outline) {
  if (Build.VERSION.SDK_INT < Build.VERSION_CODES.LOLLIPOP) {
    super.getOutline(outline);
    return;
  }
  if ((!YogaConstants.isUndefined(mBorderRadius) && mBorderRadius > 0) || mBorderCornerRadii != null) {
    updatePath();

    outline.setConvexPath(mPathForBorderRadiusOutline);
  } else {
    outline.setRect(getBounds());
  }
}
 
Example 10
Source File: ViewOutlineProviderCompatUtilsLXX.java    From LokiBoard-Android-Keylogger with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(final View view, final Outline outline) {
    if (mLastVisibleTopInsets == NO_DATA) {
        // Call default implementation.
        ViewOutlineProvider.BACKGROUND.getOutline(view, outline);
        return;
    }
    // TODO: Revisit this when floating/resize keyboard is supported.
    outline.setRect(
            view.getLeft(), mLastVisibleTopInsets, view.getRight(), view.getBottom());
}
 
Example 11
Source File: NotificationHeaderView.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    if (mBackground != null) {
        outline.setRect(0, 0, getWidth(), getHeight());
        outline.setAlpha(1f);
    }
}
 
Example 12
Source File: ViewOutlineProvider.java    From android_9.0.0_r45 with Apache License 2.0 5 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRect(view.getPaddingLeft(),
            view.getPaddingTop(),
            view.getWidth() - view.getPaddingRight(),
            view.getHeight() - view.getPaddingBottom());
}
 
Example 13
Source File: Coolbar.java    From SAI with GNU General Public License v3.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRect(0, 0, mWidth, mHeight);
}
 
Example 14
Source File: AbstractOverlayDialogView.java    From oversec with GNU General Public License v3.0 4 votes vote down vote up
public AbstractOverlayDialogView(Core core, String packageName, View anchor) {
    super(core, packageName);

    mAnchor = anchor;
    updateLayoutParams();

    ContextThemeWrapper ctw = new ContextThemeWrapper(core.getCtx(), R.style.AppTheme);
    mView = (ViewGroup) LayoutInflater.from(ctw)
            .inflate(R.layout.overlay_dialog, null);


    mBgDrawable = new TooltipBackgroundDrawable(core.getCtx());
    mPadding = core.dipToPixels(StandaloneTooltipView.DEFAULT_PADDING_DP);


    mView.findViewById(R.id.content).setBackground(mBgDrawable);
    //   mView.findViewById(R.id.content).setOutlineProvider();


    if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
        ViewOutlineProvider viewOutlineProvider = new ViewOutlineProvider() {
            @Override
            public void getOutline(View view, Outline outline) {
                if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
                    outline.setRect(mPadding, mPadding, view.getWidth() - mPadding, view.getHeight() - mPadding);
                }
            }
        };
        mView.findViewById(R.id.content).setOutlineProvider(viewOutlineProvider);
        mView.setElevation(mCore.dipToPixels(16));
    }

    addView(mView, new LayoutParams(getMyWidth(), getMyHeight(), 0, 0));

    mTvMsg = (TextView) mView.findViewById(R.id.text);
    mBtOk = (Button) mView.findViewById(R.id.buttonOK);
    mBtNeutral = (Button) mView.findViewById(R.id.buttonNeutral);
    mBtCancel = (Button) mView.findViewById(R.id.buttonCancel);
    mCustomContainer = (ViewGroup) mView.findViewById(R.id.custom_container);


    onOrientationChanged(getResources().getConfiguration().orientation, false);
}
 
Example 15
Source File: Util.java    From ThreePhasesBottomSheet with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRect(0, 0, width, height);
}
 
Example 16
Source File: IconDrawable.java    From edx-app-android with Apache License 2.0 4 votes vote down vote up
@Override
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
public void getOutline(@NonNull Outline outline) {
    outline.setRect(drawBounds);
}
 
Example 17
Source File: RadialGradientRippleAnimationDrawable.java    From ProjectX with Apache License 2.0 4 votes vote down vote up
@TargetApi(Build.VERSION_CODES.LOLLIPOP)
@Override
public void getOutline(Outline outline) {
    outline.setRect(getBounds());
    outline.setAlpha(1);
}
 
Example 18
Source File: Util.java    From bottomsheet with BSD 3-Clause "New" or "Revised" License 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRect(0, 0, width, height);
}
 
Example 19
Source File: ShadowHelperApi21.java    From adt-leanback-support with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRect(0, 0, view.getWidth(), view.getHeight());
    outline.setAlpha(1.0f);
}
 
Example 20
Source File: ViewOutlineProvider.java    From android_9.0.0_r45 with Apache License 2.0 4 votes vote down vote up
@Override
public void getOutline(View view, Outline outline) {
    outline.setRect(0, 0, view.getWidth(), view.getHeight());
}