mirror of
https://github.com/status-im/react-native.git
synced 2025-01-27 01:40:08 +00:00
Remove the dependency of I18nManagerModule on ReactApplicationContext
Reviewed By: javache Differential Revision: D4809492 fbshipit-source-id: 775c6b95aab734568ea4750804477c04d13502b6
This commit is contained in:
parent
a893d0bb23
commit
af533ac7f1
@ -11,9 +11,9 @@ 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.ReactContextBaseJavaModule;
|
||||
import com.facebook.react.bridge.ReactMethod;
|
||||
import com.facebook.react.common.MapBuilder;
|
||||
import com.facebook.react.module.annotations.ReactModule;
|
||||
@ -25,12 +25,12 @@ import java.util.Map;
|
||||
* {@link NativeModule} that allows JS to set allowRTL and get isRTL status.
|
||||
*/
|
||||
@ReactModule(name = "I18nManager")
|
||||
public class I18nManagerModule extends ReactContextBaseJavaModule {
|
||||
public class I18nManagerModule extends ContextBaseJavaModule {
|
||||
|
||||
private final I18nUtil sharedI18nUtilInstance = I18nUtil.getInstance();
|
||||
|
||||
public I18nManagerModule(ReactApplicationContext reactContext) {
|
||||
super(reactContext);
|
||||
public I18nManagerModule(Context context) {
|
||||
super(context);
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -40,26 +40,22 @@ public class I18nManagerModule extends ReactContextBaseJavaModule {
|
||||
|
||||
@Override
|
||||
public Map<String, Object> getConstants() {
|
||||
final Context context = getReactApplicationContext().getBaseContext();
|
||||
final Context context = getContext();
|
||||
final Locale locale = context.getResources().getConfiguration().locale;
|
||||
|
||||
final Map<String, Object> constants = MapBuilder.newHashMap();
|
||||
constants.put("isRTL", sharedI18nUtilInstance.isRTL(getReactApplicationContext()));
|
||||
constants.put("isRTL", sharedI18nUtilInstance.isRTL(context));
|
||||
constants.put("localeIdentifier", locale.toString());
|
||||
return constants;
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void allowRTL(boolean value) {
|
||||
sharedI18nUtilInstance.allowRTL(
|
||||
getReactApplicationContext(),
|
||||
value);
|
||||
sharedI18nUtilInstance.allowRTL(getContext(), value);
|
||||
}
|
||||
|
||||
@ReactMethod
|
||||
public void forceRTL(boolean value) {
|
||||
sharedI18nUtilInstance.forceRTL(
|
||||
getReactApplicationContext(),
|
||||
value);
|
||||
sharedI18nUtilInstance.forceRTL(getContext(), value);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user