Skip to content

Commit 23f151d

Browse files
committed
chore: add working hardcoded Android config
1 parent 49bffb3 commit 23f151d

File tree

11 files changed

+64
-43
lines changed

11 files changed

+64
-43
lines changed

android/.settings/org.eclipse.buildship.core.prefs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ arguments=
22
auto.sync=false
33
build.scans.enabled=false
44
connection.gradle.distribution=GRADLE_DISTRIBUTION(WRAPPER)
5-
connection.project.dir=../example/android
5+
connection.project.dir=
66
eclipse.preferences.version=1
77
gradle.user.home=
88
java.home=/usr/lib/jvm/java-11-openjdk-amd64

android/build.gradle

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,7 @@ android {
4040
versionName "1.0"
4141
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
4242
multiDexEnabled true
43+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
4344
buildConfigField "Long", "ADB_COMMAND_TIMEOUT_MILLISECONDS", ADB_COMMAND_TIMEOUT_MILLISECONDS
4445
buildConfigField "Long", "PROMISE_TIMEOUT_MILLISECONDS", PROMISE_TIMEOUT_MILLISECONDS
4546
}
@@ -180,10 +181,10 @@ dependencies {
180181

181182
if (isNewArchitectureEnabled()) {
182183
react {
183-
codegenJavaPackageName = "io.deckers.blob_courier.spec"
184+
codegenJavaPackageName = "io.deckers.blob_courier"
184185
libraryName = "blob_courier"
185186
jsRootDir = file("../src/")
186-
reactRoot = rootProject.file("../node_modules/react-native/")
187-
codegenDir = rootProject.file("../node_modules/react-native-codegen/")
187+
// reactRoot = rootProject.file("../node_modules/react-native/")
188+
// codegenDir = rootProject.file("../node_modules/react-native-codegen/")
188189
}
189190
}

android/src/main/java/io/deckers/blob_courier/BlobCourierPackage.kt

Lines changed: 18 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
*/
77
package io.deckers.blob_courier
88

9+
import android.util.Log
910
import com.facebook.react.TurboReactPackage
1011
import com.facebook.react.bridge.ReactApplicationContext
1112
import com.facebook.react.bridge.NativeModule
@@ -14,18 +15,29 @@ import com.facebook.react.module.model.ReactModuleInfoProvider
1415
import com.facebook.react.module.model.ReactModuleInfo
1516
import java.util.HashMap
1617

18+
private val TAG = "BlobCourier"
19+
1720
class BlobCourierPackage : TurboReactPackage() {
21+
init {
22+
Log.i(TAG,"YYYYYYYYYYYYYYYYYY")
23+
}
24+
1825
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
19-
return if (name == LIBRARY_NAME) {
20-
BlobCourierModule(reactContext)
21-
} else {
22-
null
23-
}
26+
Log.i(TAG,"XXXXXXXXXXXXXXXXXXXXXXX")
27+
return TurboBlobCourierModule(reactContext)
28+
29+
// return if (name == LIBRARY_NAME) {
30+
// TurboBlobCourierModule(reactContext)
31+
// } else {
32+
// null
33+
// }
2434
}
2535

2636
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
27-
return ReactModuleInfoProvider {
37+
Log.i(TAG,"AAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA")
38+
return ReactModuleInfoProvider {
2839
val moduleInfos: MutableMap<String, ReactModuleInfo> = HashMap()
40+
Log.i(TAG,"BBBBBBBBBBBBBBBBBBBBBBBBBBBBBB")
2941
// val isTurboModule: Boolean = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
3042
val isTurboModule = true
3143
moduleInfos[LIBRARY_NAME] = ReactModuleInfo(

android/src/main/java/io/deckers/blob_courier/TurboBlobCourierModule.kt

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,7 @@ package io.deckers.blob_courier
88

99
import com.facebook.react.bridge.Promise
1010
import com.facebook.react.bridge.ReactApplicationContext
11-
import com.facebook.react.bridge.ReactContextBaseJavaModule
12-
import com.facebook.react.bridge.ReactMethod
1311
import com.facebook.react.bridge.ReadableMap
14-
import com.facebook.react.module.annotations.ReactModule
1512
import com.facebook.react.modules.network.OkHttpClientProvider
1613
import io.deckers.blob_courier.cancel.CancellationParameterFactory
1714
import io.deckers.blob_courier.cancel.RequestCanceller
@@ -33,7 +30,6 @@ import io.deckers.blob_courier.react.processUnexpectedException
3330
import io.deckers.blob_courier.react.toReactMap
3431
import io.deckers.blob_courier.upload.BlobUploader
3532
import io.deckers.blob_courier.upload.UploaderParameterFactory
36-
import io.deckers.blob_courier.spec.NativeBlobCourierSpec
3733
import java.net.UnknownHostException
3834
import kotlin.concurrent.thread
3935

@@ -58,10 +54,6 @@ class TurboBlobCourierModule(private val reactContext: ReactApplicationContext)
5854

5955
companion object {
6056
const val NAME = LIBRARY_NAME
61-
62-
init {
63-
System.loadLibrary("blob_courier_example_appmodules")
64-
}
6557
}
6658

6759
override fun getName(): String = LIBRARY_NAME

example/android/app/src/main/java/io/deckers/blob_courier_example/MainActivity.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,13 @@
11
package io.deckers.blob_courier_example;
22

3+
import android.util.Log;
34
import com.facebook.react.ReactActivity;
45
import com.facebook.react.ReactActivityDelegate;
56
import com.facebook.react.ReactRootView;
67

8+
79
public class MainActivity extends ReactActivity {
10+
private static final String TAG = "BlobCourier";
811

912
/**
1013
* Returns the name of the main component registered from JavaScript. This is used to schedule
@@ -21,6 +24,7 @@ protected String getMainComponentName() {
2124
*/
2225
@Override
2326
protected ReactActivityDelegate createReactActivityDelegate() {
27+
Log.i(TAG, "DDDDDDDDDDDDDDDDDD");
2428
return new MainActivityDelegate(this, getMainComponentName());
2529
}
2630

example/android/app/src/main/java/io/deckers/blob_courier_example/MainApplication.java

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,7 @@
22

33
import androidx.annotation.NonNull;
44

5+
import android.util.Log;
56
import android.app.Application;
67
import android.content.Context;
78
import com.facebook.react.PackageList;
@@ -17,9 +18,10 @@
1718
import java.lang.reflect.InvocationTargetException;
1819
import java.util.List;
1920

20-
// import io.deckers.blob_courier.BlobCourierPackage;
21+
import io.deckers.blob_courier.BlobCourierPackage;
2122

2223
public class MainApplication extends Application implements ReactApplication {
24+
private static final String TAG = "BlobCourier";
2325

2426
private final ReactNativeHost mReactNativeHost =
2527
new ReactNativeHost(this) {
@@ -34,37 +36,38 @@ protected List<ReactPackage> getPackages() {
3436
List<ReactPackage> packages = new PackageList(this).getPackages();
3537
// Packages that cannot be autolinked yet can be added manually here, for example:
3638
// packages.add(new MyReactNativePackage());
37-
// packages.add(new BlobCourierPackage());
39+
packages.add(new BlobCourierPackage());
3840
return packages;
3941
}
4042

4143
@Override
4244
protected String getJSMainModuleName() {
4345
return "index";
4446
}
45-
46-
@NonNull
47-
@Override
48-
protected ReactPackageTurboModuleManagerDelegate.Builder getReactPackageTurboModuleManagerDelegateBuilder() {
49-
return new MainApplicationTurboModuleManagerDelegate.Builder();
50-
}
47+
48+
// @NonNull
49+
// @Override
50+
// protected ReactPackageTurboModuleManagerDelegate.Builder getReactPackageTurboModuleManagerDelegateBuilder() {
51+
// return new MainApplicationTurboModuleManagerDelegate.Builder();
52+
// }
5153
};
5254

5355
private final ReactNativeHost mNewArchitectureNativeHost =
5456
new MainApplicationReactNativeHost(this);
5557

5658
@Override
5759
public ReactNativeHost getReactNativeHost() {
58-
if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
60+
// if (BuildConfig.IS_NEW_ARCHITECTURE_ENABLED) {
5961
return mNewArchitectureNativeHost;
60-
} else {
61-
return mReactNativeHost;
62-
}
62+
// } else {
63+
// return mReactNativeHost;
64+
// }
6365
}
6466

6567
@Override
6668
public void onCreate() {
6769
super.onCreate();
70+
Log.i(TAG,"CCCCCCCCCCCCCCCCCCCCCCCCCCC");
6871
// If you opted-in for the New Architecture, we enable the TurboModule system
6972
// ReactFeatureFlags.useTurboModules = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED;
7073
ReactFeatureFlags.useTurboModules = true;

example/android/app/src/main/java/io/deckers/blob_courier_example/newarchitecture/MainApplicationReactNativeHost.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,8 @@
2525
import java.util.ArrayList;
2626
import java.util.List;
2727

28+
import io.deckers.blob_courier.BlobCourierPackage;
29+
2830
/**
2931
* A {@link ReactNativeHost} that helps you load everything needed for the New Architecture, both
3032
* TurboModule delegates and the Fabric Renderer.
@@ -49,6 +51,9 @@ protected List<ReactPackage> getPackages() {
4951
// packages.add(new MyReactNativePackage());
5052
// TurboModules must also be loaded here providing a valid TurboReactPackage implementation:
5153
// packages.add(new TurboReactPackage() { ... });
54+
55+
packages.add(new BlobCourierPackage());
56+
5257
// If you have custom Fabric Components, their ViewManagers should also be loaded here
5358
// inside a ReactPackage.
5459
return packages;

example/android/app/src/main/jni/Android.mk

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ include $(REACT_ANDROID_DIR)/Android-prebuilt.mk
66
# will have to include the following autogenerated makefile.
77
# include $(GENERATED_SRC_DIR)/codegen/jni/Android.mk
88

9-
# Includes the MK file for `react-native-blob-courier`
9+
# Includes the MK file for `example-library`
1010

1111
include /home/ely/Projects/react-native-blob-courier/android/build/generated/source/codegen/jni/Android.mk
1212

@@ -25,9 +25,9 @@ LOCAL_EXPORT_C_INCLUDES := $(LOCAL_PATH)
2525
# will have to uncomment those lines to include the generated source
2626
# files from the codegen (placed in $(GENERATED_SRC_DIR)/codegen/jni)
2727
#
28-
LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
29-
LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)
30-
LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
28+
# LOCAL_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
29+
# LOCAL_SRC_FILES += $(wildcard $(GENERATED_SRC_DIR)/codegen/jni/*.cpp)
30+
# LOCAL_EXPORT_C_INCLUDES += $(GENERATED_SRC_DIR)/codegen/jni
3131

3232
# Here you should add any native library you wish to depend on.
3333
LOCAL_SHARED_LIBRARIES := \

example/android/app/src/main/jni/MainApplicationModuleProvider.cpp

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#include "MainApplicationModuleProvider.h"
2-
#include <blob_courier.h>
32

43
#include <rncore.h>
4+
#include <blob_courier.h>
55

66
namespace facebook {
77
namespace react {
@@ -13,16 +13,11 @@ std::shared_ptr<TurboModule> MainApplicationModuleProvider(
1313
// either your application or from external libraries. The approach to follow
1414
// is similar to the following (for a library called `samplelibrary`:
1515
//
16-
// auto module = samplelibrary_ModuleProvider(moduleName, params);
17-
// if (module != nullptr) {
18-
// return module;
19-
// }
20-
// return rncore_ModuleProvider(moduleName, params);
2116
auto module = blob_courier_ModuleProvider(moduleName, params);
2217
if (module != nullptr) {
23-
return module;
18+
return module;
2419
}
25-
20+
// return rncore_ModuleProvider(moduleName, params);
2621
return rncore_ModuleProvider(moduleName, params);
2722
}
2823

package.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -99,5 +99,14 @@
9999
"module",
100100
"typescript"
101101
]
102+
},
103+
"codegenConfig": {
104+
"libraries": [
105+
{
106+
"name": "RNBlobCourierSpec",
107+
"type": "modules",
108+
"jsSrcsDir": "src"
109+
}
110+
]
102111
}
103112
}

0 commit comments

Comments
 (0)