mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-04-22 11:16:06 +08:00
Rename I18nManager Left/Right swap methods
Reviewed By: fkgozali Differential Revision: D6140072 fbshipit-source-id: 282dc614c036de8f217a729f21a1bbe92b8afd7d
This commit is contained in:
committed by
Facebook Github Bot
parent
90a42396b9
commit
efa4d3c222
@@ -10,14 +10,11 @@
|
||||
package com.facebook.react.modules.i18nmanager;
|
||||
|
||||
import android.content.Context;
|
||||
|
||||
import com.facebook.react.bridge.ContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.NativeModule;
|
||||
import com.facebook.react.bridge.ReactApplicationContext;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
|
||||
import java.util.Locale;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -45,7 +42,8 @@ public class I18nManagerModule extends ContextBaseJavaModule {
|
||||
|
||||
final Map<String, Object> constants = MapBuilder.newHashMap();
|
||||
constants.put("isRTL", sharedI18nUtilInstance.isRTL(context));
|
||||
constants.put("doesRTLFlipLeftAndRightStyles", sharedI18nUtilInstance.doesRTLFlipLeftAndRightStyles(context));
|
||||
constants.put(
|
||||
"doLeftAndRightSwapInRTL", sharedI18nUtilInstance.doLeftAndRightSwapInRTL(context));
|
||||
constants.put("localeIdentifier", locale.toString());
|
||||
return constants;
|
||||
}
|
||||
@@ -61,7 +59,7 @@ public class I18nManagerModule extends ContextBaseJavaModule {
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void makeRTLFlipLeftAndRightStyles(boolean value) {
|
||||
sharedI18nUtilInstance.makeRTLFlipLeftAndRightStyles(getContext(), value);
|
||||
public void swapLeftAndRightInRTL(boolean value) {
|
||||
sharedI18nUtilInstance.swapLeftAndRightInRTL(getContext(), value);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -11,10 +11,8 @@ package com.facebook.react.modules.i18nmanager;
|
||||
|
||||
import android.content.Context;
|
||||
import android.content.SharedPreferences;
|
||||
import android.content.SharedPreferences.Editor;
|
||||
import android.support.v4.text.TextUtilsCompat;
|
||||
import android.support.v4.view.ViewCompat;
|
||||
|
||||
import java.util.Locale;
|
||||
|
||||
public class I18nUtil {
|
||||
@@ -67,11 +65,11 @@ public class I18nUtil {
|
||||
setPref(context, KEY_FOR_PREFS_ALLOWRTL, allowRTL);
|
||||
}
|
||||
|
||||
public boolean doesRTLFlipLeftAndRightStyles(Context context) {
|
||||
public boolean doLeftAndRightSwapInRTL(Context context) {
|
||||
return isPrefSet(context, KEY_FOR_PERFS_MAKE_RTL_FLIP_LEFT_AND_RIGHT_STYLES, true);
|
||||
}
|
||||
|
||||
public void makeRTLFlipLeftAndRightStyles(Context context, boolean flip) {
|
||||
public void swapLeftAndRightInRTL(Context context, boolean flip) {
|
||||
setPref(context, KEY_FOR_PERFS_MAKE_RTL_FLIP_LEFT_AND_RIGHT_STYLES, flip);
|
||||
}
|
||||
|
||||
|
||||
@@ -680,7 +680,7 @@ public class LayoutShadowNode extends ReactShadowNodeImpl {
|
||||
}
|
||||
|
||||
private int maybeTransformLeftRightToStartEnd(int spacingType) {
|
||||
if (!I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(getThemedContext())) {
|
||||
if (!I18nUtil.getInstance().doLeftAndRightSwapInRTL(getThemedContext())) {
|
||||
return spacingType;
|
||||
}
|
||||
|
||||
|
||||
@@ -328,7 +328,7 @@ public class ReactViewBackgroundDrawable extends Drawable {
|
||||
int colorStart = getBorderColor(Spacing.START);
|
||||
int colorEnd = getBorderColor(Spacing.END);
|
||||
|
||||
if (I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(mContext)) {
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
|
||||
if (!isBorderColorDefined(Spacing.START)) {
|
||||
colorStart = colorLeft;
|
||||
}
|
||||
@@ -485,7 +485,7 @@ public class ReactViewBackgroundDrawable extends Drawable {
|
||||
float bottomStartRadius = getBorderRadius(BorderRadiusLocation.BOTTOM_START);
|
||||
float bottomEndRadius = getBorderRadius(BorderRadiusLocation.BOTTOM_END);
|
||||
|
||||
if (I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(mContext)) {
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
|
||||
if (YogaConstants.isUndefined(topStartRadius)) {
|
||||
topStartRadius = topLeftRadius;
|
||||
}
|
||||
@@ -935,7 +935,7 @@ public class ReactViewBackgroundDrawable extends Drawable {
|
||||
int colorStart = getBorderColor(Spacing.START);
|
||||
int colorEnd = getBorderColor(Spacing.END);
|
||||
|
||||
if (I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(mContext)) {
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
|
||||
if (!isBorderColorDefined(Spacing.START)) {
|
||||
colorStart = colorLeft;
|
||||
}
|
||||
@@ -1145,7 +1145,7 @@ public class ReactViewBackgroundDrawable extends Drawable {
|
||||
float borderStartWidth = mBorderWidth.getRaw(Spacing.START);
|
||||
float borderEndWidth = mBorderWidth.getRaw(Spacing.END);
|
||||
|
||||
if (I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(mContext)) {
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(mContext)) {
|
||||
if (YogaConstants.isUndefined(borderStartWidth)) {
|
||||
borderStartWidth = borderLeftWidth;
|
||||
}
|
||||
|
||||
@@ -685,7 +685,7 @@ public class ReactViewGroup extends ViewGroup implements
|
||||
mReactBackgroundDrawable.getBorderRadius(
|
||||
ReactViewBackgroundDrawable.BorderRadiusLocation.BOTTOM_END);
|
||||
|
||||
if (I18nUtil.getInstance().doesRTLFlipLeftAndRightStyles(getContext())) {
|
||||
if (I18nUtil.getInstance().doLeftAndRightSwapInRTL(getContext())) {
|
||||
if (YogaConstants.isUndefined(topStartBorderRadius)) {
|
||||
topStartBorderRadius = topLeftBorderRadius;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user