@woshapp/react-native-background-upload 6.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (106) hide show
  1. package/.gitattributes +1 -0
  2. package/LICENSE +21 -0
  3. package/README.md +53 -0
  4. package/android/build.gradle +82 -0
  5. package/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  6. package/android/gradle/wrapper/gradle-wrapper.properties +6 -0
  7. package/android/gradle.properties +6 -0
  8. package/android/gradlew +185 -0
  9. package/android/gradlew.bat +89 -0
  10. package/android/src/main/AndroidManifest.xml +1 -0
  11. package/android/src/main/java/com/appfolio/extensions/ContextExtensions.kt +63 -0
  12. package/android/src/main/java/com/appfolio/extensions/UploadExtensions.kt +57 -0
  13. package/android/src/main/java/com/appfolio/uploader/GlobalRequestObserverDelegate.kt +62 -0
  14. package/android/src/main/java/com/appfolio/uploader/ModifiedBinaryUploadRequest.kt +29 -0
  15. package/android/src/main/java/com/appfolio/uploader/ModifiedHttpUploadRequest.kt +57 -0
  16. package/android/src/main/java/com/appfolio/uploader/ModifiedMultipartUploadRequest.kt +60 -0
  17. package/android/src/main/java/com/appfolio/uploader/UploaderModule.kt +384 -0
  18. package/android/src/main/java/com/appfolio/uploader/UploaderReactPackage.java +32 -0
  19. package/android/src/main/java/com/appfolio/work/TaskCompletionNotifier.kt +47 -0
  20. package/android/src/main/java/com/appfolio/work/UploadManager.kt +109 -0
  21. package/android/src/main/java/com/appfolio/work/UploadWorker.kt +20 -0
  22. package/bitbucket-pipelines.yml +14 -0
  23. package/example/RNBackgroundExample/.buckconfig +6 -0
  24. package/example/RNBackgroundExample/.eslintrc.js +4 -0
  25. package/example/RNBackgroundExample/.flowconfig +74 -0
  26. package/example/RNBackgroundExample/.gitattributes +1 -0
  27. package/example/RNBackgroundExample/.prettierrc.js +6 -0
  28. package/example/RNBackgroundExample/.watchmanconfig +1 -0
  29. package/example/RNBackgroundExample/App.js +325 -0
  30. package/example/RNBackgroundExample/README.md +50 -0
  31. package/example/RNBackgroundExample/__tests__/App-test.js +14 -0
  32. package/example/RNBackgroundExample/android/app/BUCK +55 -0
  33. package/example/RNBackgroundExample/android/app/build.gradle +225 -0
  34. package/example/RNBackgroundExample/android/app/build_defs.bzl +19 -0
  35. package/example/RNBackgroundExample/android/app/debug.keystore +0 -0
  36. package/example/RNBackgroundExample/android/app/proguard-rules.pro +10 -0
  37. package/example/RNBackgroundExample/android/app/src/androidTest/java/com/rnbackgroundexample/DetoxTest.java +24 -0
  38. package/example/RNBackgroundExample/android/app/src/debug/AndroidManifest.xml +8 -0
  39. package/example/RNBackgroundExample/android/app/src/debug/java/com/rnbackgroundexample/ReactNativeFlipper.java +72 -0
  40. package/example/RNBackgroundExample/android/app/src/main/AndroidManifest.xml +33 -0
  41. package/example/RNBackgroundExample/android/app/src/main/java/com/rnbackgroundexample/MainActivity.java +15 -0
  42. package/example/RNBackgroundExample/android/app/src/main/java/com/rnbackgroundexample/MainApplication.java +76 -0
  43. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-hdpi/ic_launcher.png +0 -0
  44. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-hdpi/ic_launcher_round.png +0 -0
  45. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-mdpi/ic_launcher.png +0 -0
  46. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-mdpi/ic_launcher_round.png +0 -0
  47. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher.png +0 -0
  48. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-xhdpi/ic_launcher_round.png +0 -0
  49. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher.png +0 -0
  50. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-xxhdpi/ic_launcher_round.png +0 -0
  51. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher.png +0 -0
  52. package/example/RNBackgroundExample/android/app/src/main/res/mipmap-xxxhdpi/ic_launcher_round.png +0 -0
  53. package/example/RNBackgroundExample/android/app/src/main/res/values/strings.xml +3 -0
  54. package/example/RNBackgroundExample/android/app/src/main/res/values/styles.xml +9 -0
  55. package/example/RNBackgroundExample/android/build.gradle +42 -0
  56. package/example/RNBackgroundExample/android/gradle/wrapper/gradle-wrapper.jar +0 -0
  57. package/example/RNBackgroundExample/android/gradle/wrapper/gradle-wrapper.properties +5 -0
  58. package/example/RNBackgroundExample/android/gradle.properties +23 -0
  59. package/example/RNBackgroundExample/android/gradlew +183 -0
  60. package/example/RNBackgroundExample/android/gradlew.bat +103 -0
  61. package/example/RNBackgroundExample/android/settings.gradle +3 -0
  62. package/example/RNBackgroundExample/app.json +4 -0
  63. package/example/RNBackgroundExample/babel.config.js +3 -0
  64. package/example/RNBackgroundExample/e2e/config.json +8 -0
  65. package/example/RNBackgroundExample/e2e/detox.pathbuilder.android.js +4 -0
  66. package/example/RNBackgroundExample/e2e/detox.pathbuilder.ios.js +4 -0
  67. package/example/RNBackgroundExample/e2e/detox.pathbuilder.js +21 -0
  68. package/example/RNBackgroundExample/e2e/environment.js +23 -0
  69. package/example/RNBackgroundExample/e2e/firstTest.spec.js +56 -0
  70. package/example/RNBackgroundExample/e2e/server.js +69 -0
  71. package/example/RNBackgroundExample/e2e/start-server.js +2 -0
  72. package/example/RNBackgroundExample/index.js +9 -0
  73. package/example/RNBackgroundExample/ios/App.swift +9 -0
  74. package/example/RNBackgroundExample/ios/Podfile +24 -0
  75. package/example/RNBackgroundExample/ios/Podfile.lock +387 -0
  76. package/example/RNBackgroundExample/ios/RNBackgroundExample/AppDelegate.h +15 -0
  77. package/example/RNBackgroundExample/ios/RNBackgroundExample/AppDelegate.m +42 -0
  78. package/example/RNBackgroundExample/ios/RNBackgroundExample/Images.xcassets/AppIcon.appiconset/Contents.json +38 -0
  79. package/example/RNBackgroundExample/ios/RNBackgroundExample/Images.xcassets/Contents.json +6 -0
  80. package/example/RNBackgroundExample/ios/RNBackgroundExample/Info.plist +65 -0
  81. package/example/RNBackgroundExample/ios/RNBackgroundExample/LaunchScreen.storyboard +58 -0
  82. package/example/RNBackgroundExample/ios/RNBackgroundExample/main.m +16 -0
  83. package/example/RNBackgroundExample/ios/RNBackgroundExample-Bridging-Header.h +4 -0
  84. package/example/RNBackgroundExample/ios/RNBackgroundExample-tvOS/Info.plist +53 -0
  85. package/example/RNBackgroundExample/ios/RNBackgroundExample-tvOSTests/Info.plist +24 -0
  86. package/example/RNBackgroundExample/ios/RNBackgroundExample.xcodeproj/project.pbxproj +991 -0
  87. package/example/RNBackgroundExample/ios/RNBackgroundExample.xcodeproj/xcshareddata/xcschemes/RNBackgroundExample-tvOS.xcscheme +88 -0
  88. package/example/RNBackgroundExample/ios/RNBackgroundExample.xcodeproj/xcshareddata/xcschemes/RNBackgroundExample.xcscheme +88 -0
  89. package/example/RNBackgroundExample/ios/RNBackgroundExample.xcworkspace/contents.xcworkspacedata +10 -0
  90. package/example/RNBackgroundExample/ios/RNBackgroundExample.xcworkspace/xcshareddata/IDEWorkspaceChecks.plist +8 -0
  91. package/example/RNBackgroundExample/ios/RNBackgroundExampleTests/Info.plist +24 -0
  92. package/example/RNBackgroundExample/ios/RNBackgroundExampleTests/RNBackgroundExampleTests.m +72 -0
  93. package/example/RNBackgroundExample/metro.config.js +22 -0
  94. package/example/RNBackgroundExample/package.json +71 -0
  95. package/example/RNBackgroundExample/scripts/deploy-android.sh +14 -0
  96. package/example/RNBackgroundExample/scripts/deploy-ios.sh +11 -0
  97. package/example/RNBackgroundExample/scripts/postinstall.sh +13 -0
  98. package/example/RNBackgroundExample/wait-for-emulator.sh +39 -0
  99. package/example/RNBackgroundExample/yarn.lock +8165 -0
  100. package/index.d.ts +154 -0
  101. package/ios/VydiaRNFileUploader.h +10 -0
  102. package/ios/VydiaRNFileUploader.m +457 -0
  103. package/ios/VydiaRNFileUploader.xcodeproj/project.pbxproj +254 -0
  104. package/package.json +37 -0
  105. package/react-native-upload.podspec +23 -0
  106. package/src/index.js +151 -0
@@ -0,0 +1,225 @@
1
+ apply plugin: "com.android.application"
2
+
3
+ import com.android.build.OutputFile
4
+
5
+ /**
6
+ * The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
7
+ * and bundleReleaseJsAndAssets).
8
+ * These basically call `react-native bundle` with the correct arguments during the Android build
9
+ * cycle. By default, bundleDebugJsAndAssets is skipped, as in debug/dev mode we prefer to load the
10
+ * bundle directly from the development server. Below you can see all the possible configurations
11
+ * and their defaults. If you decide to add a configuration block, make sure to add it before the
12
+ * `apply from: "../../node_modules/react-native/react.gradle"` line.
13
+ *
14
+ * project.ext.react = [
15
+ * // the name of the generated asset file containing your JS bundle
16
+ * bundleAssetName: "index.android.bundle",
17
+ *
18
+ * // the entry file for bundle generation
19
+ * entryFile: "index.android.js",
20
+ *
21
+ * // https://facebook.github.io/react-native/docs/performance#enable-the-ram-format
22
+ * bundleCommand: "ram-bundle",
23
+ *
24
+ * // whether to bundle JS and assets in debug mode
25
+ * bundleInDebug: false,
26
+ *
27
+ * // whether to bundle JS and assets in release mode
28
+ * bundleInRelease: true,
29
+ *
30
+ * // whether to bundle JS and assets in another build variant (if configured).
31
+ * // See http://tools.android.com/tech-docs/new-build-system/user-guide#TOC-Build-Variants
32
+ * // The configuration property can be in the following formats
33
+ * // 'bundleIn${productFlavor}${buildType}'
34
+ * // 'bundleIn${buildType}'
35
+ * // bundleInFreeDebug: true,
36
+ * // bundleInPaidRelease: true,
37
+ * // bundleInBeta: true,
38
+ *
39
+ * // whether to disable dev mode in custom build variants (by default only disabled in release)
40
+ * // for example: to disable dev mode in the staging build type (if configured)
41
+ * devDisabledInStaging: true,
42
+ * // The configuration property can be in the following formats
43
+ * // 'devDisabledIn${productFlavor}${buildType}'
44
+ * // 'devDisabledIn${buildType}'
45
+ *
46
+ * // the root of your project, i.e. where "package.json" lives
47
+ * root: "../../",
48
+ *
49
+ * // where to put the JS bundle asset in debug mode
50
+ * jsBundleDirDebug: "$buildDir/intermediates/assets/debug",
51
+ *
52
+ * // where to put the JS bundle asset in release mode
53
+ * jsBundleDirRelease: "$buildDir/intermediates/assets/release",
54
+ *
55
+ * // where to put drawable resources / React Native assets, e.g. the ones you use via
56
+ * // require('./image.png')), in debug mode
57
+ * resourcesDirDebug: "$buildDir/intermediates/res/merged/debug",
58
+ *
59
+ * // where to put drawable resources / React Native assets, e.g. the ones you use via
60
+ * // require('./image.png')), in release mode
61
+ * resourcesDirRelease: "$buildDir/intermediates/res/merged/release",
62
+ *
63
+ * // by default the gradle tasks are skipped if none of the JS files or assets change; this means
64
+ * // that we don't look at files in android/ or ios/ to determine whether the tasks are up to
65
+ * // date; if you have any other folders that you want to ignore for performance reasons (gradle
66
+ * // indexes the entire tree), add them here. Alternatively, if you have JS files in android/
67
+ * // for example, you might want to remove it from here.
68
+ * inputExcludes: ["android/**", "ios/**"],
69
+ *
70
+ * // override which node gets called and with what additional arguments
71
+ * nodeExecutableAndArgs: ["node"],
72
+ *
73
+ * // supply additional arguments to the packager
74
+ * extraPackagerArgs: []
75
+ * ]
76
+ */
77
+
78
+ project.ext.react = [
79
+ entryFile: "index.js",
80
+ enableHermes: false, // clean and rebuild if changing
81
+ bundleInDebug: false,
82
+ ]
83
+
84
+ apply from: "../../node_modules/react-native/react.gradle"
85
+
86
+ /**
87
+ * Set this to true to create two separate APKs instead of one:
88
+ * - An APK that only works on ARM devices
89
+ * - An APK that only works on x86 devices
90
+ * The advantage is the size of the APK is reduced by about 4MB.
91
+ * Upload all the APKs to the Play Store and people will download
92
+ * the correct one based on the CPU architecture of their device.
93
+ */
94
+ def enableSeparateBuildPerCPUArchitecture = false
95
+
96
+ /**
97
+ * Run Proguard to shrink the Java bytecode in release builds.
98
+ */
99
+ def enableProguardInReleaseBuilds = false
100
+
101
+ /**
102
+ * The preferred build flavor of JavaScriptCore.
103
+ *
104
+ * For example, to use the international variant, you can use:
105
+ * `def jscFlavor = 'org.webkit:android-jsc-intl:+'`
106
+ *
107
+ * The international variant includes ICU i18n library and necessary data
108
+ * allowing to use e.g. `Date.toLocaleString` and `String.localeCompare` that
109
+ * give correct results when using with locales other than en-US. Note that
110
+ * this variant is about 6MiB larger per architecture than default.
111
+ */
112
+ def jscFlavor = 'org.webkit:android-jsc:+'
113
+
114
+ /**
115
+ * Whether to enable the Hermes VM.
116
+ *
117
+ * This should be set on project.ext.react and mirrored here. If it is not set
118
+ * on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
119
+ * and the benefits of using Hermes will therefore be sharply reduced.
120
+ */
121
+ def enableHermes = project.ext.react.get("enableHermes", false);
122
+
123
+ android {
124
+ compileSdkVersion rootProject.ext.compileSdkVersion
125
+
126
+ compileOptions {
127
+ sourceCompatibility JavaVersion.VERSION_1_8
128
+ targetCompatibility JavaVersion.VERSION_1_8
129
+ }
130
+
131
+ defaultConfig {
132
+ applicationId "com.rnbackgroundexample"
133
+ minSdkVersion rootProject.ext.minSdkVersion
134
+ targetSdkVersion rootProject.ext.targetSdkVersion
135
+ versionCode 1
136
+ versionName "1.0"
137
+ testBuildType System.getProperty('testBuildType', 'debug') // This will later be used to control the test apk build type
138
+ testInstrumentationRunner 'androidx.test.runner.AndroidJUnitRunner'
139
+ }
140
+ splits {
141
+ abi {
142
+ reset()
143
+ enable enableSeparateBuildPerCPUArchitecture
144
+ universalApk false // If true, also generate a universal APK
145
+ include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
146
+ }
147
+ }
148
+ signingConfigs {
149
+ debug {
150
+ storeFile file('debug.keystore')
151
+ storePassword 'android'
152
+ keyAlias 'androiddebugkey'
153
+ keyPassword 'android'
154
+ }
155
+ }
156
+ buildTypes {
157
+ debug {
158
+ signingConfig signingConfigs.debug
159
+ }
160
+ release {
161
+ // Caution! In production, you need to generate your own keystore file.
162
+ // see https://facebook.github.io/react-native/docs/signed-apk-android.
163
+ signingConfig signingConfigs.debug
164
+ minifyEnabled enableProguardInReleaseBuilds
165
+ proguardFiles getDefaultProguardFile("proguard-android.txt"), "proguard-rules.pro"
166
+ }
167
+ }
168
+ // applicationVariants are e.g. debug, release
169
+ applicationVariants.all { variant ->
170
+ variant.outputs.each { output ->
171
+ // For each separate APK per architecture, set a unique version code as described here:
172
+ // https://developer.android.com/studio/build/configure-apk-splits.html
173
+ def versionCodes = ["armeabi-v7a": 1, "x86": 2, "arm64-v8a": 3, "x86_64": 4]
174
+ def abi = output.getFilter(OutputFile.ABI)
175
+ if (abi != null) { // null for the universal-debug, universal-release variants
176
+ output.versionCodeOverride =
177
+ versionCodes.get(abi) * 1048576 + defaultConfig.versionCode
178
+ }
179
+
180
+ }
181
+ }
182
+ }
183
+
184
+ dependencies {
185
+ implementation fileTree(dir: "libs", include: ["*.jar"])
186
+
187
+ implementation 'androidx.appcompat:appcompat:1.1.0'
188
+ //noinspection GradleDynamicVersion
189
+ implementation "com.facebook.react:react-native:+" // From node_modules
190
+
191
+ implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
192
+
193
+ debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
194
+ exclude group:'com.facebook.fbjni'
195
+ }
196
+
197
+ debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
198
+ exclude group:'com.facebook.flipper'
199
+ exclude group:'com.squareup.okhttp3', module:'okhttp'
200
+ }
201
+
202
+ debugImplementation("com.facebook.flipper:flipper-fresco-plugin:${FLIPPER_VERSION}") {
203
+ exclude group:'com.facebook.flipper'
204
+ }
205
+
206
+ if (enableHermes) {
207
+ def hermesPath = "../../node_modules/hermes-engine/android/";
208
+ debugImplementation files(hermesPath + "hermes-debug.aar")
209
+ releaseImplementation files(hermesPath + "hermes-release.aar")
210
+ } else {
211
+ implementation jscFlavor
212
+ }
213
+
214
+ androidTestImplementation ('com.wix:detox:+') { transitive = true }
215
+ androidTestImplementation 'junit:junit:4.12'
216
+ }
217
+
218
+ // Run this once to be able to run the application with BUCK
219
+ // puts all compile dependencies into folder libs for BUCK to use
220
+ task copyDownloadableDepsToLibs(type: Copy) {
221
+ from configurations.compile
222
+ into 'libs'
223
+ }
224
+
225
+ apply from: file("../../node_modules/@react-native-community/cli-platform-android/native_modules.gradle"); applyNativeModulesAppBuildGradle(project)
@@ -0,0 +1,19 @@
1
+ """Helper definitions to glob .aar and .jar targets"""
2
+
3
+ def create_aar_targets(aarfiles):
4
+ for aarfile in aarfiles:
5
+ name = "aars__" + aarfile[aarfile.rindex("/") + 1:aarfile.rindex(".aar")]
6
+ lib_deps.append(":" + name)
7
+ android_prebuilt_aar(
8
+ name = name,
9
+ aar = aarfile,
10
+ )
11
+
12
+ def create_jar_targets(jarfiles):
13
+ for jarfile in jarfiles:
14
+ name = "jars__" + jarfile[jarfile.rindex("/") + 1:jarfile.rindex(".jar")]
15
+ lib_deps.append(":" + name)
16
+ prebuilt_jar(
17
+ name = name,
18
+ binary_jar = jarfile,
19
+ )
@@ -0,0 +1,10 @@
1
+ # Add project specific ProGuard rules here.
2
+ # By default, the flags in this file are appended to flags specified
3
+ # in /usr/local/Cellar/android-sdk/24.3.3/tools/proguard/proguard-android.txt
4
+ # You can edit the include path and order by changing the proguardFiles
5
+ # directive in build.gradle.
6
+ #
7
+ # For more details, see
8
+ # http://developer.android.com/guide/developing/tools/proguard.html
9
+
10
+ # Add any project specific keep options here:
@@ -0,0 +1,24 @@
1
+ package com.rnbackgroundexample;
2
+
3
+ import androidx.test.filters.LargeTest;
4
+ import androidx.test.rule.ActivityTestRule;
5
+ import androidx.test.runner.AndroidJUnit4;
6
+
7
+ import com.wix.detox.Detox;
8
+
9
+ import org.junit.Rule;
10
+ import org.junit.Test;
11
+ import org.junit.runner.RunWith;
12
+
13
+ @RunWith(AndroidJUnit4.class)
14
+ @LargeTest
15
+ public class DetoxTest {
16
+
17
+ @Rule
18
+ public ActivityTestRule<MainActivity> mActivityRule = new ActivityTestRule<>(MainActivity.class, false, false);
19
+
20
+ @Test
21
+ public void runDetoxTests() throws InterruptedException {
22
+ Detox.runTests(mActivityRule);
23
+ }
24
+ }
@@ -0,0 +1,8 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
3
+ xmlns:tools="http://schemas.android.com/tools">
4
+
5
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
6
+
7
+ <application android:usesCleartextTraffic="true" tools:targetApi="28" tools:ignore="GoogleAppIndexingWarning" />
8
+ </manifest>
@@ -0,0 +1,72 @@
1
+ /**
2
+ * Copyright (c) Facebook, Inc. and its affiliates.
3
+ *
4
+ * <p>This source code is licensed under the MIT license found in the LICENSE file in the root
5
+ * directory of this source tree.
6
+ */
7
+ package com.rnbackgroundexample;
8
+
9
+ import android.content.Context;
10
+ import com.facebook.flipper.android.AndroidFlipperClient;
11
+ import com.facebook.flipper.android.utils.FlipperUtils;
12
+ import com.facebook.flipper.core.FlipperClient;
13
+ import com.facebook.flipper.plugins.crashreporter.CrashReporterPlugin;
14
+ import com.facebook.flipper.plugins.databases.DatabasesFlipperPlugin;
15
+ import com.facebook.flipper.plugins.fresco.FrescoFlipperPlugin;
16
+ import com.facebook.flipper.plugins.inspector.DescriptorMapping;
17
+ import com.facebook.flipper.plugins.inspector.InspectorFlipperPlugin;
18
+ import com.facebook.flipper.plugins.network.FlipperOkhttpInterceptor;
19
+ import com.facebook.flipper.plugins.network.NetworkFlipperPlugin;
20
+ import com.facebook.flipper.plugins.react.ReactFlipperPlugin;
21
+ import com.facebook.flipper.plugins.sharedpreferences.SharedPreferencesFlipperPlugin;
22
+ import com.facebook.react.ReactInstanceManager;
23
+ import com.facebook.react.bridge.ReactContext;
24
+ import com.facebook.react.modules.network.NetworkingModule;
25
+ import okhttp3.OkHttpClient;
26
+
27
+ public class ReactNativeFlipper {
28
+ public static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
29
+ if (FlipperUtils.shouldEnableFlipper(context)) {
30
+ final FlipperClient client = AndroidFlipperClient.getInstance(context);
31
+
32
+ client.addPlugin(new InspectorFlipperPlugin(context, DescriptorMapping.withDefaults()));
33
+ client.addPlugin(new ReactFlipperPlugin());
34
+ client.addPlugin(new DatabasesFlipperPlugin(context));
35
+ client.addPlugin(new SharedPreferencesFlipperPlugin(context));
36
+ client.addPlugin(CrashReporterPlugin.getInstance());
37
+
38
+ NetworkFlipperPlugin networkFlipperPlugin = new NetworkFlipperPlugin();
39
+ NetworkingModule.setCustomClientBuilder(
40
+ new NetworkingModule.CustomClientBuilder() {
41
+ @Override
42
+ public void apply(OkHttpClient.Builder builder) {
43
+ builder.addNetworkInterceptor(new FlipperOkhttpInterceptor(networkFlipperPlugin));
44
+ }
45
+ });
46
+ client.addPlugin(networkFlipperPlugin);
47
+ client.start();
48
+
49
+ // Fresco Plugin needs to ensure that ImagePipelineFactory is initialized
50
+ // Hence we run if after all native modules have been initialized
51
+ ReactContext reactContext = reactInstanceManager.getCurrentReactContext();
52
+ if (reactContext == null) {
53
+ reactInstanceManager.addReactInstanceEventListener(
54
+ new ReactInstanceManager.ReactInstanceEventListener() {
55
+ @Override
56
+ public void onReactContextInitialized(ReactContext reactContext) {
57
+ reactInstanceManager.removeReactInstanceEventListener(this);
58
+ reactContext.runOnNativeModulesQueueThread(
59
+ new Runnable() {
60
+ @Override
61
+ public void run() {
62
+ client.addPlugin(new FrescoFlipperPlugin());
63
+ }
64
+ });
65
+ }
66
+ });
67
+ } else {
68
+ client.addPlugin(new FrescoFlipperPlugin());
69
+ }
70
+ }
71
+ }
72
+ }
@@ -0,0 +1,33 @@
1
+ <manifest xmlns:android="http://schemas.android.com/apk/res/android"
2
+ package="com.rnbackgroundexample">
3
+
4
+ <uses-permission android:name="android.permission.INTERNET" />
5
+ <uses-permission android:name="android.permission.FOREGROUND_SERVICE" />
6
+
7
+ <uses-permission android:name="android.permission.SYSTEM_ALERT_WINDOW"/>
8
+ <uses-permission android:name="android.permission.CAMERA" />
9
+ <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
10
+
11
+ <application
12
+ android:name=".MainApplication"
13
+ android:label="@string/app_name"
14
+ android:usesCleartextTraffic="true"
15
+ android:icon="@mipmap/ic_launcher"
16
+ android:roundIcon="@mipmap/ic_launcher_round"
17
+ android:allowBackup="false"
18
+ android:theme="@style/AppTheme">
19
+ <activity
20
+ android:name=".MainActivity"
21
+ android:label="@string/app_name"
22
+ android:configChanges="keyboard|keyboardHidden|orientation|screenSize|uiMode"
23
+ android:launchMode="singleTask"
24
+ android:windowSoftInputMode="adjustResize">
25
+ <intent-filter>
26
+ <action android:name="android.intent.action.MAIN" />
27
+ <category android:name="android.intent.category.LAUNCHER" />
28
+ </intent-filter>
29
+ </activity>
30
+ <activity android:name="com.facebook.react.devsupport.DevSettingsActivity" />
31
+ </application>
32
+
33
+ </manifest>
@@ -0,0 +1,15 @@
1
+ package com.rnbackgroundexample;
2
+
3
+ import com.facebook.react.ReactActivity;
4
+
5
+ public class MainActivity extends ReactActivity {
6
+
7
+ /**
8
+ * Returns the name of the main component registered from JavaScript. This is used to schedule
9
+ * rendering of the component.
10
+ */
11
+ @Override
12
+ protected String getMainComponentName() {
13
+ return "RNBackgroundExample";
14
+ }
15
+ }
@@ -0,0 +1,76 @@
1
+ package com.rnbackgroundexample;
2
+
3
+ import android.app.Application;
4
+ import android.content.Context;
5
+ import com.facebook.react.PackageList;
6
+ import com.facebook.react.ReactApplication;
7
+ import com.facebook.react.ReactInstanceManager;
8
+ import com.facebook.react.ReactNativeHost;
9
+ import com.facebook.react.ReactPackage;
10
+ import com.facebook.soloader.SoLoader;
11
+ import java.lang.reflect.InvocationTargetException;
12
+ import java.util.List;
13
+
14
+ public class MainApplication extends Application implements ReactApplication {
15
+
16
+ private final ReactNativeHost mReactNativeHost =
17
+ new ReactNativeHost(this) {
18
+ @Override
19
+ public boolean getUseDeveloperSupport() {
20
+ return BuildConfig.DEBUG;
21
+ }
22
+
23
+ @Override
24
+ protected List<ReactPackage> getPackages() {
25
+ @SuppressWarnings("UnnecessaryLocalVariable")
26
+ List<ReactPackage> packages = new PackageList(this).getPackages();
27
+ // Packages that cannot be autolinked yet can be added manually here, for example:
28
+ // packages.add(new MyReactNativePackage());
29
+ return packages;
30
+ }
31
+
32
+ @Override
33
+ protected String getJSMainModuleName() {
34
+ return "index";
35
+ }
36
+ };
37
+
38
+ @Override
39
+ public ReactNativeHost getReactNativeHost() {
40
+ return mReactNativeHost;
41
+ }
42
+
43
+ @Override
44
+ public void onCreate() {
45
+ super.onCreate();
46
+ SoLoader.init(this, /* native exopackage */ false);
47
+ initializeFlipper(this, getReactNativeHost().getReactInstanceManager()); // Remove this line if you don't want Flipper enabled
48
+ }
49
+
50
+ /**
51
+ * Loads Flipper in React Native templates.
52
+ *
53
+ * @param context
54
+ * @param reactInstanceManager
55
+ */
56
+ private static void initializeFlipper(Context context, ReactInstanceManager reactInstanceManager) {
57
+ if (BuildConfig.DEBUG) {
58
+ try {
59
+ /*
60
+ We use reflection here to pick up the class that initializes Flipper,
61
+ since Flipper library is not available in release mode
62
+ */
63
+ Class<?> aClass = Class.forName("com.rnbackgroundexample.ReactNativeFlipper");
64
+ aClass.getMethod("initializeFlipper", Context.class, ReactInstanceManager.class).invoke(null, context, reactInstanceManager);
65
+ } catch (ClassNotFoundException e) {
66
+ e.printStackTrace();
67
+ } catch (NoSuchMethodException e) {
68
+ e.printStackTrace();
69
+ } catch (IllegalAccessException e) {
70
+ e.printStackTrace();
71
+ } catch (InvocationTargetException e) {
72
+ e.printStackTrace();
73
+ }
74
+ }
75
+ }
76
+ }
@@ -0,0 +1,3 @@
1
+ <resources>
2
+ <string name="app_name">RNBackgroundExample</string>
3
+ </resources>
@@ -0,0 +1,9 @@
1
+ <resources>
2
+
3
+ <!-- Base application theme. -->
4
+ <style name="AppTheme" parent="Theme.AppCompat.Light.NoActionBar">
5
+ <!-- Customize your theme here. -->
6
+ <item name="android:textColor">#000000</item>
7
+ </style>
8
+
9
+ </resources>
@@ -0,0 +1,42 @@
1
+ // Top-level build file where you can add configuration options common to all sub-projects/modules.
2
+
3
+ buildscript {
4
+ ext {
5
+ buildToolsVersion = "29.0.2"
6
+ minSdkVersion = 21
7
+ compileSdkVersion = 29
8
+ targetSdkVersion = 29
9
+ ext.kotlinVersion = '1.3.41' // Your app's version
10
+ ext.detoxKotlinVersion = ext.kotlinVersion // Detox' version: should be 1.1.0 or higher!
11
+ }
12
+ repositories {
13
+ google()
14
+ mavenCentral()
15
+ }
16
+ dependencies {
17
+ classpath("com.android.tools.build:gradle:3.5.3")
18
+ classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlinVersion"
19
+
20
+ // NOTE: Do not place your application dependencies here; they belong
21
+ // in the individual module build.gradle files
22
+ }
23
+ }
24
+
25
+ allprojects {
26
+ repositories {
27
+ mavenLocal()
28
+ maven {
29
+ // All of React Native (JS, Obj-C sources, Android binaries) is installed from npm
30
+ url("$rootDir/../node_modules/react-native/android")
31
+ }
32
+ maven {
33
+ // Android JSC is installed from npm
34
+ url("$rootDir/../node_modules/jsc-android/dist")
35
+ }
36
+
37
+ google()
38
+ jcenter()
39
+ maven { url 'https://www.jitpack.io' }
40
+ maven { url "$rootDir/../node_modules/detox/Detox-android" }
41
+ }
42
+ }
@@ -0,0 +1,5 @@
1
+ distributionBase=GRADLE_USER_HOME
2
+ distributionPath=wrapper/dists
3
+ distributionUrl=https\://services.gradle.org/distributions/gradle-6.2-all.zip
4
+ zipStoreBase=GRADLE_USER_HOME
5
+ zipStorePath=wrapper/dists
@@ -0,0 +1,23 @@
1
+ # Project-wide Gradle settings.
2
+
3
+ # IDE (e.g. Android Studio) users:
4
+ # Gradle settings configured through the IDE *will override*
5
+ # any settings specified in this file.
6
+
7
+ # For more details on how to configure your build environment visit
8
+ # http://www.gradle.org/docs/current/userguide/build_environment.html
9
+
10
+ # Specifies the JVM arguments used for the daemon process.
11
+ # The setting is particularly useful for tweaking memory settings.
12
+ # Default value: -Xmx10248m -XX:MaxPermSize=256m
13
+ org.gradle.jvmargs=-Xmx6192m -XX:MaxPermSize=512m -XX:+HeapDumpOnOutOfMemoryError -Dfile.encoding=UTF-8
14
+
15
+ # When configured, Gradle will run in incubating parallel mode.
16
+ # This option should only be used with decoupled projects. More details, visit
17
+ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects
18
+ # org.gradle.parallel=true
19
+
20
+ android.useAndroidX=true
21
+ android.enableJetifier=true
22
+
23
+ FLIPPER_VERSION=0.37.0