Skip to content

Commit

Permalink
Breaking changes in android V3 (#7)
Browse files Browse the repository at this point in the history
* update example to use 2.0.0 version

* added android configs

* v2.0.0-rc-1.0

* android configs

* update example
  • Loading branch information
csath authored Apr 10, 2019
1 parent ef85643 commit 408b49f
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 6 deletions.
6 changes: 4 additions & 2 deletions android/src/main/java/com/csath/RNConfigReaderModule.java
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,12 @@
public class RNConfigReaderModule extends ReactContextBaseJavaModule {

private final ReactApplicationContext reactContext;
private final Class buildConfigClass;

public RNConfigReaderModule(ReactApplicationContext reactContext) {
public RNConfigReaderModule(ReactApplicationContext reactContext, Class buildConfigClass) {
super(reactContext);
this.reactContext = reactContext;
this.buildConfigClass = buildConfigClass;
}

@Override
Expand All @@ -29,7 +31,7 @@ public String getName() {
@Override
public Map<String, Object> getConstants() {
final Map<String, Object> constants = new HashMap<>();
Field[] fields = BuildConfig.class.getDeclaredFields();
Field[] fields = this.buildConfigClass.getDeclaredFields();
for (Field f : fields) {
if (Modifier.isStatic(f.getModifiers())) {
Object value = null;
Expand Down
7 changes: 6 additions & 1 deletion android/src/main/java/com/csath/RNConfigReaderPackage.java
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,14 @@
import com.facebook.react.bridge.JavaScriptModule;

public class RNConfigReaderPackage implements ReactPackage {
private final Class buildConfigclass;

public RNConfigReaderPackage(Class buildConfigclass) {
this.buildConfigclass = buildConfigclass;
}
@Override
public List<NativeModule> createNativeModules(ReactApplicationContext reactContext) {
return Arrays.<NativeModule>asList(new RNConfigReaderModule(reactContext));
return Arrays.<NativeModule>asList(new RNConfigReaderModule(reactContext, this.buildConfigclass));
}

// Deprecated from RN 0.47
Expand Down
17 changes: 17 additions & 0 deletions example/android/.project
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<projectDescription>
<name>android</name>
<comment>Project android created by Buildship.</comment>
<projects>
</projects>
<buildSpec>
<buildCommand>
<name>org.eclipse.buildship.core.gradleprojectbuilder</name>
<arguments>
</arguments>
</buildCommand>
</buildSpec>
<natures>
<nature>org.eclipse.buildship.core.gradleprojectnature</nature>
</natures>
</projectDescription>
2 changes: 2 additions & 0 deletions example/android/.settings/org.eclipse.buildship.core.prefs
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
connection.project.dir=
eclipse.preferences.version=1
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ public boolean getUseDeveloperSupport() {
protected List<ReactPackage> getPackages() {
return Arrays.<ReactPackage>asList(
new MainReactPackage(),
new RNConfigReaderPackage()
new RNConfigReaderPackage(BuildConfig.class)
);
}

Expand Down
2 changes: 1 addition & 1 deletion example/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
"dependencies": {
"react": "16.8.3",
"react-native": "0.59.3",
"react-native-config-reader": "^2.0.0"
"react-native-config-reader": "^3.0.0"
},
"devDependencies": {
"@babel/core": "^7.4.3",
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-config-reader",
"version": "2.0.0",
"version": "2.0.0-rc-1.0",
"description": "Simply access android build configs and ios info.plist values in JS",
"main": "index.js",
"scripts": {
Expand Down

0 comments on commit 408b49f

Please sign in to comment.