Skip to content

Commit

Permalink
Clean old code on ReactViewBackgroundDrawable
Browse files Browse the repository at this point in the history
Summary:
This diff removes unnecessary API checks in ReactViewBackgroundDrawable

changelog: [Android][Deprecated] Remove JellyBeans Android API checks in ReactViewBackgroundDrawable classes

Reviewed By: JoshuaGross

Differential Revision: D22771911

fbshipit-source-id: bbbf3dd3fd1c3cf3f5ce294fc32bd0a31ca0f67c
  • Loading branch information
mdvacca authored and facebook-github-bot committed Jul 31, 2020
1 parent 799654b commit 25a40cb
Showing 1 changed file with 30 additions and 32 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -378,43 +378,41 @@ private void drawRoundedBackgroundWithBorders(Canvas canvas) {
canvas.clipPath(mOuterClipPathForBorderRadius, Region.Op.INTERSECT);
canvas.clipPath(mInnerClipPathForBorderRadius, Region.Op.DIFFERENCE);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
int colorStart = getBorderColor(Spacing.START);
int colorEnd = getBorderColor(Spacing.END);
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
int colorStart = getBorderColor(Spacing.START);
int colorEnd = getBorderColor(Spacing.END);

if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
if (!isBorderColorDefined(Spacing.START)) {
colorStart = colorLeft;
}
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
if (!isBorderColorDefined(Spacing.START)) {
colorStart = colorLeft;
}

if (!isBorderColorDefined(Spacing.END)) {
colorEnd = colorRight;
}
if (!isBorderColorDefined(Spacing.END)) {
colorEnd = colorRight;
}

final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;

colorLeft = directionAwareColorLeft;
colorRight = directionAwareColorRight;
} else {
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;

final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;
final boolean isColorStartDefined = isBorderColorDefined(Spacing.START);
final boolean isColorEndDefined = isBorderColorDefined(Spacing.END);
final boolean isDirectionAwareColorLeftDefined =
isRTL ? isColorEndDefined : isColorStartDefined;
final boolean isDirectionAwareColorRightDefined =
isRTL ? isColorStartDefined : isColorEndDefined;

if (isDirectionAwareColorLeftDefined) {
colorLeft = directionAwareColorLeft;
}

if (isDirectionAwareColorRightDefined) {
colorRight = directionAwareColorRight;
} else {
final int directionAwareColorLeft = isRTL ? colorEnd : colorStart;
final int directionAwareColorRight = isRTL ? colorStart : colorEnd;

final boolean isColorStartDefined = isBorderColorDefined(Spacing.START);
final boolean isColorEndDefined = isBorderColorDefined(Spacing.END);
final boolean isDirectionAwareColorLeftDefined =
isRTL ? isColorEndDefined : isColorStartDefined;
final boolean isDirectionAwareColorRightDefined =
isRTL ? isColorStartDefined : isColorEndDefined;

if (isDirectionAwareColorLeftDefined) {
colorLeft = directionAwareColorLeft;
}

if (isDirectionAwareColorRightDefined) {
colorRight = directionAwareColorRight;
}
}
}

Expand Down Expand Up @@ -1255,7 +1253,7 @@ public RectF getDirectionAwareBorderInsets() {
float borderLeftWidth = getBorderWidthOrDefaultTo(borderWidth, Spacing.LEFT);
float borderRightWidth = getBorderWidthOrDefaultTo(borderWidth, Spacing.RIGHT);

if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1 && mBorderWidth != null) {
if (mBorderWidth != null) {
final boolean isRTL = getResolvedLayoutDirection() == View.LAYOUT_DIRECTION_RTL;
float borderStartWidth = mBorderWidth.getRaw(Spacing.START);
float borderEndWidth = mBorderWidth.getRaw(Spacing.END);
Expand Down

0 comments on commit 25a40cb

Please sign in to comment.