mirror of
https://github.com/facebook/react-native.git
synced 2025-11-01 09:14:26 +00:00
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
This commit is contained in:
committed by
Facebook GitHub Bot
parent
25a40cbc61
commit
f829722b54
@@ -53,6 +53,7 @@ import com.facebook.yoga.YogaConstants;
|
||||
* Backing for a React View. Has support for borders, but since borders aren't common, lazy
|
||||
* initializes most of the storage needed for them.
|
||||
*/
|
||||
@TargetApi(Build.VERSION_CODES.KITKAT)
|
||||
public class ReactViewGroup extends ViewGroup
|
||||
implements ReactInterceptingViewGroup,
|
||||
ReactClippingViewGroup,
|
||||
@@ -145,10 +146,8 @@ public class ReactViewGroup extends ViewGroup
|
||||
|
||||
@Override
|
||||
public void onRtlPropertiesChanged(int layoutDirection) {
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
if (mReactBackgroundDrawable != null) {
|
||||
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
|
||||
}
|
||||
if (mReactBackgroundDrawable != null) {
|
||||
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -256,33 +255,11 @@ public class ReactViewGroup extends ViewGroup
|
||||
public void setBorderRadius(float borderRadius) {
|
||||
ReactViewBackgroundDrawable backgroundDrawable = getOrCreateReactViewBackground();
|
||||
backgroundDrawable.setRadius(borderRadius);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
final int UPDATED_LAYER_TYPE =
|
||||
backgroundDrawable.hasRoundedBorders()
|
||||
? View.LAYER_TYPE_SOFTWARE
|
||||
: View.LAYER_TYPE_HARDWARE;
|
||||
|
||||
if (UPDATED_LAYER_TYPE != getLayerType()) {
|
||||
setLayerType(UPDATED_LAYER_TYPE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorderRadius(float borderRadius, int position) {
|
||||
ReactViewBackgroundDrawable backgroundDrawable = getOrCreateReactViewBackground();
|
||||
backgroundDrawable.setRadius(borderRadius, position);
|
||||
|
||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.JELLY_BEAN_MR2) {
|
||||
final int UPDATED_LAYER_TYPE =
|
||||
backgroundDrawable.hasRoundedBorders()
|
||||
? View.LAYER_TYPE_SOFTWARE
|
||||
: View.LAYER_TYPE_HARDWARE;
|
||||
|
||||
if (UPDATED_LAYER_TYPE != getLayerType()) {
|
||||
setLayerType(UPDATED_LAYER_TYPE, null);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public void setBorderStyle(@Nullable String style) {
|
||||
@@ -656,13 +633,9 @@ public class ReactViewGroup extends ViewGroup
|
||||
updateBackgroundDrawable(layerDrawable);
|
||||
}
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
mLayoutDirection =
|
||||
I18nUtil.getInstance().isRTL(getContext())
|
||||
? LAYOUT_DIRECTION_RTL
|
||||
: LAYOUT_DIRECTION_LTR;
|
||||
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
|
||||
}
|
||||
mLayoutDirection =
|
||||
I18nUtil.getInstance().isRTL(getContext()) ? LAYOUT_DIRECTION_RTL : LAYOUT_DIRECTION_LTR;
|
||||
mReactBackgroundDrawable.setResolvedLayoutDirection(mLayoutDirection);
|
||||
}
|
||||
return mReactBackgroundDrawable;
|
||||
}
|
||||
@@ -764,76 +737,74 @@ public class ReactViewGroup extends ViewGroup
|
||||
mReactBackgroundDrawable.getBorderRadiusOrDefaultTo(
|
||||
borderRadius, ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_RIGHT);
|
||||
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR1) {
|
||||
final boolean isRTL = mLayoutDirection == View.LAYOUT_DIRECTION_RTL;
|
||||
float topStartBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_START);
|
||||
float topEndBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_END);
|
||||
float bottomStartBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_START);
|
||||
float bottomEndBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_END);
|
||||
final boolean isRTL = mLayoutDirection == View.LAYOUT_DIRECTION_RTL;
|
||||
float topStartBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_START);
|
||||
float topEndBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.TOP_END);
|
||||
float bottomStartBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_START);
|
||||
float bottomEndBorderRadius =
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_END);
|
||||
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(getContext())) {
|
||||
if (YogaConstants.isUndefined(topStartBorderRadius)) {
|
||||
topStartBorderRadius = topLeftBorderRadius;
|
||||
}
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(getContext())) {
|
||||
if (YogaConstants.isUndefined(topStartBorderRadius)) {
|
||||
topStartBorderRadius = topLeftBorderRadius;
|
||||
}
|
||||
|
||||
if (YogaConstants.isUndefined(topEndBorderRadius)) {
|
||||
topEndBorderRadius = topRightBorderRadius;
|
||||
}
|
||||
if (YogaConstants.isUndefined(topEndBorderRadius)) {
|
||||
topEndBorderRadius = topRightBorderRadius;
|
||||
}
|
||||
|
||||
if (YogaConstants.isUndefined(bottomStartBorderRadius)) {
|
||||
bottomStartBorderRadius = bottomLeftBorderRadius;
|
||||
}
|
||||
if (YogaConstants.isUndefined(bottomStartBorderRadius)) {
|
||||
bottomStartBorderRadius = bottomLeftBorderRadius;
|
||||
}
|
||||
|
||||
if (YogaConstants.isUndefined(bottomEndBorderRadius)) {
|
||||
bottomEndBorderRadius = bottomRightBorderRadius;
|
||||
}
|
||||
if (YogaConstants.isUndefined(bottomEndBorderRadius)) {
|
||||
bottomEndBorderRadius = bottomRightBorderRadius;
|
||||
}
|
||||
|
||||
final float directionAwareTopLeftRadius =
|
||||
isRTL ? topEndBorderRadius : topStartBorderRadius;
|
||||
final float directionAwareTopRightRadius =
|
||||
isRTL ? topStartBorderRadius : topEndBorderRadius;
|
||||
final float directionAwareBottomLeftRadius =
|
||||
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
|
||||
final float directionAwareBottomRightRadius =
|
||||
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
|
||||
final float directionAwareTopLeftRadius =
|
||||
isRTL ? topEndBorderRadius : topStartBorderRadius;
|
||||
final float directionAwareTopRightRadius =
|
||||
isRTL ? topStartBorderRadius : topEndBorderRadius;
|
||||
final float directionAwareBottomLeftRadius =
|
||||
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
|
||||
final float directionAwareBottomRightRadius =
|
||||
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
|
||||
|
||||
topLeftBorderRadius = directionAwareTopLeftRadius;
|
||||
topRightBorderRadius = directionAwareTopRightRadius;
|
||||
bottomLeftBorderRadius = directionAwareBottomLeftRadius;
|
||||
bottomRightBorderRadius = directionAwareBottomRightRadius;
|
||||
} else {
|
||||
final float directionAwareTopLeftRadius =
|
||||
isRTL ? topEndBorderRadius : topStartBorderRadius;
|
||||
final float directionAwareTopRightRadius =
|
||||
isRTL ? topStartBorderRadius : topEndBorderRadius;
|
||||
final float directionAwareBottomLeftRadius =
|
||||
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
|
||||
final float directionAwareBottomRightRadius =
|
||||
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareTopLeftRadius)) {
|
||||
topLeftBorderRadius = directionAwareTopLeftRadius;
|
||||
}
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareTopRightRadius)) {
|
||||
topRightBorderRadius = directionAwareTopRightRadius;
|
||||
}
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareBottomLeftRadius)) {
|
||||
bottomLeftBorderRadius = directionAwareBottomLeftRadius;
|
||||
}
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareBottomRightRadius)) {
|
||||
bottomRightBorderRadius = directionAwareBottomRightRadius;
|
||||
} else {
|
||||
final float directionAwareTopLeftRadius =
|
||||
isRTL ? topEndBorderRadius : topStartBorderRadius;
|
||||
final float directionAwareTopRightRadius =
|
||||
isRTL ? topStartBorderRadius : topEndBorderRadius;
|
||||
final float directionAwareBottomLeftRadius =
|
||||
isRTL ? bottomEndBorderRadius : bottomStartBorderRadius;
|
||||
final float directionAwareBottomRightRadius =
|
||||
isRTL ? bottomStartBorderRadius : bottomEndBorderRadius;
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareTopLeftRadius)) {
|
||||
topLeftBorderRadius = directionAwareTopLeftRadius;
|
||||
}
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareTopRightRadius)) {
|
||||
topRightBorderRadius = directionAwareTopRightRadius;
|
||||
}
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareBottomLeftRadius)) {
|
||||
bottomLeftBorderRadius = directionAwareBottomLeftRadius;
|
||||
}
|
||||
|
||||
if (!YogaConstants.isUndefined(directionAwareBottomRightRadius)) {
|
||||
bottomRightBorderRadius = directionAwareBottomRightRadius;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user