Skip to content

Commit ccdcd70

Browse files
Merge branch 'develop' of https://github.com/GetStream/stream-chat-react-native into v5.0.0-beta
2 parents af0faa9 + 54e1354 commit ccdcd70

File tree

111 files changed

+8850
-77002
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

111 files changed

+8850
-77002
lines changed

.github/workflows/next-release.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ jobs:
1010
runs-on: ubuntu-latest
1111
strategy:
1212
matrix:
13-
node-version: [12.x]
13+
node-version: [14.x]
1414
steps:
1515
- uses: actions/checkout@v2
1616
with:

docusaurus/docs/reactnative/basics/getting_started.mdx

Lines changed: 47 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,6 @@ Most if not all of the required packages now support auto-linking so setup shoul
6060
- [`react-native-safe-area-context`](https://github.com/th3rdwave/react-native-safe-area-context)
6161
- [`react-native-share`](https://github.com/react-native-share/react-native-share)
6262
- [`react-native-svg`](https://github.com/react-native-svg/react-native-svg)
63-
- [`react-native-video`](https://github.com/react-native-video/react-native-video)
6463

6564
<Tabs
6665
defaultValue='yarn'
@@ -72,14 +71,14 @@ Most if not all of the required packages now support auto-linking so setup shoul
7271
<TabItem value='yarn'>
7372

7473
```bash
75-
yarn add @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg react-native-video
74+
yarn add @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg
7675
```
7776

7877
</TabItem>
7978
<TabItem value='npm'>
8079

8180
```bash
82-
npm install @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg react-native-video
81+
npm install @react-native-community/cameraroll @react-native-community/netinfo @stream-io/flat-list-mvcp react-native-document-picker react-native-fs react-native-gesture-handler react-native-haptic-feedback react-native-haptic-feedback react-native-image-crop-picker react-native-image-resizer react-native-reanimated react-native-safe-area-context react-native-share react-native-svg
8382
```
8483

8584
</TabItem>
@@ -161,12 +160,43 @@ If you are planning to use file picker functionality, make sure you enable iClou
161160

162161
### Add Optional Dependencies
163162

164-
- `react-native-video` - [additional installation steps](https://github.com/react-native-video/react-native-video/blob/master/API.md#installation)
163+
#### Video playing support
165164

166-
> Available in stream-chat-react-native >= v4.7.0
165+
Install `react-native-video` in your React Native project.
167166

168-
Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default
169-
browser of the device.
167+
> Available in stream-chat-react-native >= v4.7.0
168+
169+
Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default browser of the device.
170+
171+
<Tabs
172+
defaultValue='yarn'
173+
values={[
174+
{ label: 'Yarn', value: 'yarn' },
175+
{ label: 'npm', value: 'npm' },
176+
]}
177+
>
178+
<TabItem value='yarn'>
179+
180+
```bash
181+
yarn add react-native-video
182+
```
183+
184+
</TabItem>
185+
<TabItem value='npm'>
186+
187+
```bash
188+
npm install react-native-video
189+
```
190+
191+
</TabItem>
192+
</Tabs>
193+
194+
We require [exoplayer](https://github.com/google/ExoPlayer) to be the media player on Android. To make `react-native-video` to use exoplayer, add the following in `android/settings.gradle`:
195+
196+
```
197+
include ':react-native-video'
198+
project(':react-native-video').projectDir = new File(rootProject.projectDir, '../node_modules/react-native-video/android-exoplayer')
199+
```
170200

171201
### AndroidX Support
172202

@@ -187,7 +217,7 @@ Stream Chat for React Native is set up for parity on Expo, expo requires a diffe
187217

188218
```bash
189219
expo install stream-chat-expo
190-
expo install @react-native-community/netinfo expo-document-picker expo-file-system expo-haptics expo-image-manipulator expo-image-picker expo-media-library expo-sharing react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg expo-av
220+
expo install @react-native-community/netinfo expo-document-picker expo-file-system expo-haptics expo-image-manipulator expo-image-picker expo-media-library expo-sharing react-native-gesture-handler react-native-reanimated react-native-safe-area-context react-native-svg
191221
```
192222

193223
### Additional Steps
@@ -239,9 +269,14 @@ For some of the packages listed below, there are additional steps required to se
239269

240270
### Add Optional Dependencies
241271

242-
- `expo-av` - [additional installation steps](https://docs.expo.dev/versions/v45.0.0/sdk/video/)
272+
#### Video playing support
273+
274+
Install `expo-av` in your React Native project.
243275

244-
> Available in stream-chat-expo >= v4.7.0
276+
> Available in stream-chat-expo >= v4.7.0
245277

246-
Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default
247-
browser of the device.
278+
Installing this package allows you to play the video files/attachments in the chat. Otherwise by default, video files will be opened in default browser of the device.
279+
280+
```bash
281+
expo install expo-av
282+
```

examples/ExpoMessaging/.gitignore

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -71,5 +71,6 @@ buck-out/
7171
.expo/
7272
web-build/
7373
dist/
74-
75-
# @end expo-cli
74+
ios/
75+
android/
76+
# @end expo-cli

examples/ExpoMessaging/android/app/build.gradle

Lines changed: 155 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
apply plugin: "com.android.application"
22

33
import com.android.build.OutputFile
4+
import org.apache.tools.ant.taskdefs.condition.Os
45

56
/**
67
* The react.gradle file registers a task for each build variant (e.g. bundleDebugJsAndAssets
@@ -77,14 +78,19 @@ import com.android.build.OutputFile
7778
* ]
7879
*/
7980

81+
def projectRoot = rootDir.getAbsoluteFile().getParentFile().getAbsolutePath()
82+
83+
def reactNativeRoot = new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath()
84+
8085
project.ext.react = [
86+
entryFile: ["node", "-e", "require('expo/scripts/resolveAppEntry')", projectRoot, "android"].execute(null, rootDir).text.trim(),
8187
enableHermes: (findProperty('expo.jsEngine') ?: "jsc") == "hermes",
82-
cliPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/cli.js",
83-
hermesCommand: new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/%OS-BIN%/hermesc",
84-
composeSourceMapsPath: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/scripts/compose-source-maps.js",
88+
hermesCommand: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim()).getParentFile().getAbsolutePath() + "/sdks/hermesc/%OS-BIN%/hermesc",
89+
cliPath: "${reactNativeRoot}/cli.js",
90+
composeSourceMapsPath: "${reactNativeRoot}/scripts/compose-source-maps.js",
8591
]
8692

87-
apply from: new File(["node", "--print", "require.resolve('react-native/package.json')"].execute(null, rootDir).text.trim(), "../react.gradle")
93+
apply from: new File(reactNativeRoot, "react.gradle")
8894

8995
/**
9096
* Set this to true to create two separate APKs instead of one:
@@ -99,7 +105,7 @@ def enableSeparateBuildPerCPUArchitecture = false
99105
/**
100106
* Run Proguard to shrink the Java bytecode in release builds.
101107
*/
102-
def enableProguardInReleaseBuilds = false
108+
def enableProguardInReleaseBuilds = (findProperty('android.enableProguardInReleaseBuilds') ?: false).toBoolean()
103109

104110
/**
105111
* The preferred build flavor of JavaScriptCore.
@@ -117,33 +123,112 @@ def jscFlavor = 'org.webkit:android-jsc:+'
117123
/**
118124
* Whether to enable the Hermes VM.
119125
*
120-
* This should be set on project.ext.react and mirrored here. If it is not set
126+
* This should be set on project.ext.react and that value will be read here. If it is not set
121127
* on project.ext.react, JavaScript will not be compiled to Hermes Bytecode
122128
* and the benefits of using Hermes will therefore be sharply reduced.
123129
*/
124130
def enableHermes = project.ext.react.get("enableHermes", false);
125131

132+
/**
133+
* Architectures to build native code for.
134+
*/
135+
def reactNativeArchitectures() {
136+
def value = project.getProperties().get("reactNativeArchitectures")
137+
return value ? value.split(",") : ["armeabi-v7a", "x86", "x86_64", "arm64-v8a"]
138+
}
139+
126140
android {
127-
compileSdkVersion rootProject.ext.compileSdkVersion
141+
ndkVersion rootProject.ext.ndkVersion
128142

129-
compileOptions {
130-
sourceCompatibility JavaVersion.VERSION_1_8
131-
targetCompatibility JavaVersion.VERSION_1_8
132-
}
143+
compileSdkVersion rootProject.ext.compileSdkVersion
133144

134145
defaultConfig {
135146
applicationId 'io.stream.expomessaging'
136147
minSdkVersion rootProject.ext.minSdkVersion
137148
targetSdkVersion rootProject.ext.targetSdkVersion
138149
versionCode 1
139150
versionName "1.0.0"
151+
buildConfigField "boolean", "IS_NEW_ARCHITECTURE_ENABLED", isNewArchitectureEnabled().toString()
152+
153+
if (isNewArchitectureEnabled()) {
154+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
155+
externalNativeBuild {
156+
ndkBuild {
157+
arguments "APP_PLATFORM=android-21",
158+
"APP_STL=c++_shared",
159+
"NDK_TOOLCHAIN_VERSION=clang",
160+
"GENERATED_SRC_DIR=$buildDir/generated/source",
161+
"PROJECT_BUILD_DIR=$buildDir",
162+
"REACT_ANDROID_DIR=${reactNativeRoot}/ReactAndroid",
163+
"REACT_ANDROID_BUILD_DIR=${reactNativeRoot}/ReactAndroid/build",
164+
"NODE_MODULES_DIR=$rootDir/../node_modules"
165+
cFlags "-Wall", "-Werror", "-fexceptions", "-frtti", "-DWITH_INSPECTOR=1"
166+
cppFlags "-std=c++17"
167+
// Make sure this target name is the same you specify inside the
168+
// src/main/jni/Android.mk file for the `LOCAL_MODULE` variable.
169+
targets "expomessaging_appmodules"
170+
171+
// Fix for windows limit on number of character in file paths and in command lines
172+
if (Os.isFamily(Os.FAMILY_WINDOWS)) {
173+
arguments "NDK_APP_SHORT_COMMANDS=true"
174+
}
175+
}
176+
}
177+
if (!enableSeparateBuildPerCPUArchitecture) {
178+
ndk {
179+
abiFilters (*reactNativeArchitectures())
180+
}
181+
}
182+
}
183+
}
184+
185+
if (isNewArchitectureEnabled()) {
186+
// We configure the NDK build only if you decide to opt-in for the New Architecture.
187+
externalNativeBuild {
188+
ndkBuild {
189+
path "$projectDir/src/main/jni/Android.mk"
190+
}
191+
}
192+
def reactAndroidProjectDir = project(':ReactAndroid').projectDir
193+
def packageReactNdkDebugLibs = tasks.register("packageReactNdkDebugLibs", Copy) {
194+
dependsOn(":ReactAndroid:packageReactNdkDebugLibsForBuck")
195+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
196+
into("$buildDir/react-ndk/exported")
197+
}
198+
def packageReactNdkReleaseLibs = tasks.register("packageReactNdkReleaseLibs", Copy) {
199+
dependsOn(":ReactAndroid:packageReactNdkReleaseLibsForBuck")
200+
from("$reactAndroidProjectDir/src/main/jni/prebuilt/lib")
201+
into("$buildDir/react-ndk/exported")
202+
}
203+
afterEvaluate {
204+
// If you wish to add a custom TurboModule or component locally,
205+
// you should uncomment this line.
206+
// preBuild.dependsOn("generateCodegenArtifactsFromSchema")
207+
preDebugBuild.dependsOn(packageReactNdkDebugLibs)
208+
preReleaseBuild.dependsOn(packageReactNdkReleaseLibs)
209+
210+
// Due to a bug inside AGP, we have to explicitly set a dependency
211+
// between configureNdkBuild* tasks and the preBuild tasks.
212+
// This can be removed once this is solved: https://issuetracker.google.com/issues/207403732
213+
configureNdkBuildRelease.dependsOn(preReleaseBuild)
214+
configureNdkBuildDebug.dependsOn(preDebugBuild)
215+
reactNativeArchitectures().each { architecture ->
216+
tasks.findByName("configureNdkBuildDebug[${architecture}]")?.configure {
217+
dependsOn("preDebugBuild")
218+
}
219+
tasks.findByName("configureNdkBuildRelease[${architecture}]")?.configure {
220+
dependsOn("preReleaseBuild")
221+
}
222+
}
223+
}
140224
}
225+
141226
splits {
142227
abi {
143228
reset()
144229
enable enableSeparateBuildPerCPUArchitecture
145230
universalApk false // If true, also generate a universal APK
146-
include "armeabi-v7a", "x86", "arm64-v8a", "x86_64"
231+
include (*reactNativeArchitectures())
147232
}
148233
}
149234
signingConfigs {
@@ -183,39 +268,60 @@ android {
183268
}
184269
}
185270

271+
// Apply static values from `gradle.properties` to the `android.packagingOptions`
272+
// Accepts values in comma delimited lists, example:
273+
// android.packagingOptions.pickFirsts=/LICENSE,**/picasa.ini
274+
["pickFirsts", "excludes", "merges", "doNotStrip"].each { prop ->
275+
// Split option: 'foo,bar' -> ['foo', 'bar']
276+
def options = (findProperty("android.packagingOptions.$prop") ?: "").split(",");
277+
// Trim all elements in place.
278+
for (i in 0..<options.size()) options[i] = options[i].trim();
279+
// `[] - ""` is essentially `[""].filter(Boolean)` removing all empty strings.
280+
options -= ""
281+
282+
if (options.length > 0) {
283+
println "android.packagingOptions.$prop += $options ($options.length)"
284+
// Ex: android.packagingOptions.pickFirsts += '**/SCCS/**'
285+
options.each {
286+
android.packagingOptions[prop] += it
287+
}
288+
}
289+
}
290+
186291
dependencies {
187292
implementation fileTree(dir: "libs", include: ["*.jar"])
293+
188294
//noinspection GradleDynamicVersion
189295
implementation "com.facebook.react:react-native:+" // From node_modules
190296

191297
def isGifEnabled = (findProperty('expo.gif.enabled') ?: "") == "true";
192298
def isWebpEnabled = (findProperty('expo.webp.enabled') ?: "") == "true";
193299
def isWebpAnimatedEnabled = (findProperty('expo.webp.animated') ?: "") == "true";
300+
def frescoVersion = rootProject.ext.frescoVersion
194301

195302
// If your app supports Android versions before Ice Cream Sandwich (API level 14)
196-
// All fresco packages should use the same version
197303
if (isGifEnabled || isWebpEnabled) {
198-
implementation 'com.facebook.fresco:fresco:2.0.0'
199-
implementation 'com.facebook.fresco:imagepipeline-okhttp3:2.0.0'
304+
implementation "com.facebook.fresco:fresco:${frescoVersion}"
305+
implementation "com.facebook.fresco:imagepipeline-okhttp3:${frescoVersion}"
200306
}
201307

202308
if (isGifEnabled) {
203309
// For animated gif support
204-
implementation 'com.facebook.fresco:animated-gif:2.0.0'
310+
implementation "com.facebook.fresco:animated-gif:${frescoVersion}"
205311
}
206312

207313
if (isWebpEnabled) {
208314
// For webp support
209-
implementation 'com.facebook.fresco:webpsupport:2.0.0'
315+
implementation "com.facebook.fresco:webpsupport:${frescoVersion}"
210316
if (isWebpAnimatedEnabled) {
211317
// Animated webp support
212-
implementation 'com.facebook.fresco:animated-webp:2.0.0'
318+
implementation "com.facebook.fresco:animated-webp:${frescoVersion}"
213319
}
214320
}
215-
321+
216322
implementation "androidx.swiperefreshlayout:swiperefreshlayout:1.0.0"
217323
debugImplementation("com.facebook.flipper:flipper:${FLIPPER_VERSION}") {
218-
exclude group:'com.facebook.fbjni'
324+
exclude group:'com.facebook.fbjni'
219325
}
220326
debugImplementation("com.facebook.flipper:flipper-network-plugin:${FLIPPER_VERSION}") {
221327
exclude group:'com.facebook.flipper'
@@ -226,19 +332,45 @@ dependencies {
226332
}
227333

228334
if (enableHermes) {
229-
debugImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-debug.aar"))
230-
releaseImplementation files(new File(["node", "--print", "require.resolve('hermes-engine/package.json')"].execute(null, rootDir).text.trim(), "../android/hermes-release.aar"))
335+
//noinspection GradleDynamicVersion
336+
implementation("com.facebook.react:hermes-engine:+") { // From node_modules
337+
exclude group:'com.facebook.fbjni'
338+
}
231339
} else {
232340
implementation jscFlavor
233341
}
234342
}
235343

344+
if (isNewArchitectureEnabled()) {
345+
// If new architecture is enabled, we let you build RN from source
346+
// Otherwise we fallback to a prebuilt .aar bundled in the NPM package.
347+
// This will be applied to all the imported transtitive dependency.
348+
configurations.all {
349+
resolutionStrategy.dependencySubstitution {
350+
substitute(module("com.facebook.react:react-native"))
351+
.using(project(":ReactAndroid"))
352+
.because("On New Architecture we're building React Native from source")
353+
substitute(module("com.facebook.react:hermes-engine"))
354+
.using(project(":ReactAndroid:hermes-engine"))
355+
.because("On New Architecture we're building Hermes from source")
356+
}
357+
}
358+
}
359+
236360
// Run this once to be able to run the application with BUCK
237361
// puts all compile dependencies into folder libs for BUCK to use
238362
task copyDownloadableDepsToLibs(type: Copy) {
239-
from configurations.compile
363+
from configurations.implementation
240364
into 'libs'
241365
}
242366

243367
apply from: new File(["node", "--print", "require.resolve('@react-native-community/cli-platform-android/package.json')"].execute(null, rootDir).text.trim(), "../native_modules.gradle");
244368
applyNativeModulesAppBuildGradle(project)
369+
370+
def isNewArchitectureEnabled() {
371+
// To opt-in for the New Architecture, you can either:
372+
// - Set `newArchEnabled` to true inside the `gradle.properties` file
373+
// - Invoke gradle with `-newArchEnabled=true`
374+
// - Set an environment variable `ORG_GRADLE_PROJECT_newArchEnabled=true`
375+
return project.hasProperty("newArchEnabled") && project.newArchEnabled == "true"
376+
}

0 commit comments

Comments
 (0)