Skip to content

Commit f829722

Browse files
mdvaccafacebook-github-bot
authored andcommitted
Remove old android APIs code from ReactViewGroup
Summary: This diff removes code that was used to support android APIs < kitkat changelog: [Android][Deprecated] Remove calls to Android API < Kitkat Reviewed By: JoshuaGross Differential Revision: D22771913 fbshipit-source-id: b9bba9e94fbc8e18889b821050dcd6eace4c202d
1 parent 25a40cb commit f829722

File tree

1 file changed

+69
-98
lines changed

1 file changed

+69
-98
lines changed

ReactAndroid/src/main/java/com/facebook/react/views/view/ReactViewGroup.java

+69-98
Original file line numberDiff line numberDiff line change
@@ -53,6 +53,7 @@
5353
* Backing for a React View. Has support for borders, but since borders aren't common, lazy
5454
* initializes most of the storage needed for them.
5555
*/
56+
@TargetApi(Build.VERSION_CODES.KITKAT)
5657
public class ReactViewGroup extends ViewGroup
5758
implements ReactInterceptingViewGroup,
5859
ReactClippingViewGroup,
@@ -145,10 +146,8 @@ protected void onLayout(boolean changed, int left, int top, int right, int botto
145146

146147
@Override
147148
public void onRtlPropertiesChanged(int layoutDirection) {
148-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
149-
if (mReactBackgroundDrawable != null) {
150-
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
151-
}
149+
if (mReactBackgroundDrawable != null) {
150+
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
152151
}
153152
}
154153

@@ -256,33 +255,11 @@ public void setBorderColor(int position, float rgb, float alpha) {
256255
public void setBorderRadius(float borderRadius) {
257256
ReactViewBackgroundDrawable backgroundDrawable = getOrCreateReactViewBackground();
258257
backgroundDrawable.setRadius(borderRadius);
259-
260-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
261-
final int UPDATED_LAYER_TYPE =
262-
backgroundDrawable.hasRoundedBorders()
263-
? View.LAYER_TYPE_SOFTWARE
264-
: View.LAYER_TYPE_HARDWARE;
265-
266-
if (UPDATED_LAYER_TYPE != getLayerType()) {
267-
setLayerType(UPDATED_LAYER_TYPE, null);
268-
}
269-
}
270258
}
271259

272260
public void setBorderRadius(float borderRadius, int position) {
273261
ReactViewBackgroundDrawable backgroundDrawable = getOrCreateReactViewBackground();
274262
backgroundDrawable.setRadius(borderRadius, position);
275-
276-
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
277-
final int UPDATED_LAYER_TYPE =
278-
backgroundDrawable.hasRoundedBorders()
279-
? View.LAYER_TYPE_SOFTWARE
280-
: View.LAYER_TYPE_HARDWARE;
281-
282-
if (UPDATED_LAYER_TYPE != getLayerType()) {
283-
setLayerType(UPDATED_LAYER_TYPE, null);
284-
}
285-
}
286263
}
287264

288265
public void setBorderStyle(@Nullable String style) {
@@ -656,13 +633,9 @@ private ReactViewBackgroundDrawable getOrCreateReactViewBackground() {
656633
updateBackgroundDrawable(layerDrawable);
657634
}
658635

659-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
660-
mLayoutDirection =
661-
I18nUtil.getInstance().isRTL(getContext())
662-
? LAYOUT_DIRECTION_RTL
663-
: LAYOUT_DIRECTION_LTR;
664-
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
665-
}
636+
mLayoutDirection =
637+
I18nUtil.getInstance().isRTL(getContext()) ? LAYOUT_DIRECTION_RTL : LAYOUT_DIRECTION_LTR;
638+
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
666639
}
667640
return mReactBackgroundDrawable;
668641
}
@@ -764,76 +737,74 @@ private void dispatchOverflowDraw(Canvas canvas) {
764737
mReactBackgroundDrawable.getBorderRadiusOrDefaultTo(
765738
borderRadius, ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_RIGHT);
766739

767-
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
768-
final boolean isRTL = mLayoutDirection == View.LAYOUT_DIRECTION_RTL;
769-
float topStartBorderRadius =
770-
mReactBackgroundDrawable.getBorderRadius(
771-
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_START);
772-
float topEndBorderRadius =
773-
mReactBackgroundDrawable.getBorderRadius(
774-
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_END);
775-
float bottomStartBorderRadius =
776-
mReactBackgroundDrawable.getBorderRadius(
777-
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_START);
778-
float bottomEndBorderRadius =
779-
mReactBackgroundDrawable.getBorderRadius(
780-
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_END);
781-
782-
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(getContext())) {
783-
if (YogaConstants.isUndefined(topStartBorderRadius)) {
784-
topStartBorderRadius = topLeftBorderRadius;
785-
}
786-
787-
if (YogaConstants.isUndefined(topEndBorderRadius)) {
788-
topEndBorderRadius = topRightBorderRadius;
789-
}
790-
791-
if (YogaConstants.isUndefined(bottomStartBorderRadius)) {
792-
bottomStartBorderRadius = bottomLeftBorderRadius;
793-
}
794-
795-
if (YogaConstants.isUndefined(bottomEndBorderRadius)) {
796-
bottomEndBorderRadius = bottomRightBorderRadius;
797-
}
798-
799-
final float directionAwareTopLeftRadius =
800-
isRTL ? topEndBorderRadius : topStartBorderRadius;
801-
final float directionAwareTopRightRadius =
802-
isRTL ? topStartBorderRadius : topEndBorderRadius;
803-
final float directionAwareBottomLeftRadius =
804-
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
805-
final float directionAwareBottomRightRadius =
806-
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
740+
final boolean isRTL = mLayoutDirection == View.LAYOUT_DIRECTION_RTL;
741+
float topStartBorderRadius =
742+
mReactBackgroundDrawable.getBorderRadius(
743+
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_START);
744+
float topEndBorderRadius =
745+
mReactBackgroundDrawable.getBorderRadius(
746+
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_END);
747+
float bottomStartBorderRadius =
748+
mReactBackgroundDrawable.getBorderRadius(
749+
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_START);
750+
float bottomEndBorderRadius =
751+
mReactBackgroundDrawable.getBorderRadius(
752+
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_END);
753+
754+
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(getContext())) {
755+
if (YogaConstants.isUndefined(topStartBorderRadius)) {
756+
topStartBorderRadius = topLeftBorderRadius;
757+
}
807758

759+
if (YogaConstants.isUndefined(topEndBorderRadius)) {
760+
topEndBorderRadius = topRightBorderRadius;
761+
}
762+
763+
if (YogaConstants.isUndefined(bottomStartBorderRadius)) {
764+
bottomStartBorderRadius = bottomLeftBorderRadius;
765+
}
766+
767+
if (YogaConstants.isUndefined(bottomEndBorderRadius)) {
768+
bottomEndBorderRadius = bottomRightBorderRadius;
769+
}
770+
771+
final float directionAwareTopLeftRadius =
772+
isRTL ? topEndBorderRadius : topStartBorderRadius;
773+
final float directionAwareTopRightRadius =
774+
isRTL ? topStartBorderRadius : topEndBorderRadius;
775+
final float directionAwareBottomLeftRadius =
776+
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
777+
final float directionAwareBottomRightRadius =
778+
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
779+
780+
topLeftBorderRadius = directionAwareTopLeftRadius;
781+
topRightBorderRadius = directionAwareTopRightRadius;
782+
bottomLeftBorderRadius = directionAwareBottomLeftRadius;
783+
bottomRightBorderRadius = directionAwareBottomRightRadius;
784+
} else {
785+
final float directionAwareTopLeftRadius =
786+
isRTL ? topEndBorderRadius : topStartBorderRadius;
787+
final float directionAwareTopRightRadius =
788+
isRTL ? topStartBorderRadius : topEndBorderRadius;
789+
final float directionAwareBottomLeftRadius =
790+
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
791+
final float directionAwareBottomRightRadius =
792+
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
793+
794+
if (!YogaConstants.isUndefined(directionAwareTopLeftRadius)) {
808795
topLeftBorderRadius = directionAwareTopLeftRadius;
796+
}
797+
798+
if (!YogaConstants.isUndefined(directionAwareTopRightRadius)) {
809799
topRightBorderRadius = directionAwareTopRightRadius;
800+
}
801+
802+
if (!YogaConstants.isUndefined(directionAwareBottomLeftRadius)) {
810803
bottomLeftBorderRadius = directionAwareBottomLeftRadius;
804+
}
805+
806+
if (!YogaConstants.isUndefined(directionAwareBottomRightRadius)) {
811807
bottomRightBorderRadius = directionAwareBottomRightRadius;
812-
} else {
813-
final float directionAwareTopLeftRadius =
814-
isRTL ? topEndBorderRadius : topStartBorderRadius;
815-
final float directionAwareTopRightRadius =
816-
isRTL ? topStartBorderRadius : topEndBorderRadius;
817-
final float directionAwareBottomLeftRadius =
818-
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
819-
final float directionAwareBottomRightRadius =
820-
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
821-
822-
if (!YogaConstants.isUndefined(directionAwareTopLeftRadius)) {
823-
topLeftBorderRadius = directionAwareTopLeftRadius;
824-
}
825-
826-
if (!YogaConstants.isUndefined(directionAwareTopRightRadius)) {
827-
topRightBorderRadius = directionAwareTopRightRadius;
828-
}
829-
830-
if (!YogaConstants.isUndefined(directionAwareBottomLeftRadius)) {
831-
bottomLeftBorderRadius = directionAwareBottomLeftRadius;
832-
}
833-
834-
if (!YogaConstants.isUndefined(directionAwareBottomRightRadius)) {
835-
bottomRightBorderRadius = directionAwareBottomRightRadius;
836-
}
837808
}
838809
}
839810

0 commit comments

Comments
 (0)