Skip to content

Commit 465e780

Browse files
committed
fix: remove use of deprecated apis
1 parent be7770c commit 465e780

12 files changed

Lines changed: 346 additions & 470 deletions

File tree

.github/workflows/android.yml

Lines changed: 12 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,16 @@ on:
1515
jobs:
1616
android-build:
1717
runs-on: ubuntu-latest
18+
strategy:
19+
matrix:
20+
arch: [old, new]
21+
include:
22+
- arch: old
23+
new-arch-enabled: false
24+
description: "old architecture"
25+
- arch: new
26+
new-arch-enabled: true
27+
description: "new architecture"
1828
steps:
1929
- uses: actions/checkout@v4
2030
- name: Use Node.js lts
@@ -27,23 +37,6 @@ jobs:
2737
java-version: '17'
2838
- name: Install dependencies
2939
run: yarn install --immutable
30-
- name: Build android example app on old architecture
31-
run: ./gradlew app:assembleDebug -PnewArchEnabled=false
32-
working-directory: example/android
33-
android-build-new-arch:
34-
runs-on: ubuntu-latest
35-
steps:
36-
- uses: actions/checkout@v3
37-
- name: Use Node.js lts
38-
uses: actions/setup-node@v4
39-
with:
40-
node-version: lts/*
41-
- uses: actions/setup-java@v4
42-
with:
43-
distribution: 'temurin'
44-
java-version: '17'
45-
- name: Install dependencies
46-
run: yarn install --immutable
47-
- name: Build android example app on new architecture
48-
run: ./gradlew app:assembleDebug -PnewArchEnabled=true
40+
- name: Build android example app on ${{ matrix.description }}
41+
run: ./gradlew app:assembleDebug -PnewArchEnabled=${{ matrix.new-arch-enabled }}
4942
working-directory: example/android

.github/workflows/ios.yml

Lines changed: 13 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,17 @@ on:
1616

1717
jobs:
1818
ios-build:
19-
runs-on: macos-latest
19+
runs-on: macos-26
20+
strategy:
21+
matrix:
22+
arch: [old, new]
23+
include:
24+
- arch: old
25+
new-arch-enabled: 0
26+
description: "old architecture"
27+
- arch: new
28+
new-arch-enabled: 1
29+
description: "new architecture"
2030
steps:
2131
- uses: actions/checkout@v4
2232
- name: Use Node.js lts
@@ -31,29 +41,8 @@ jobs:
3141
- name: Install dependencies
3242
run: yarn install --immutable
3343
- name: Install pods
34-
run: RCT_NEW_ARCH_ENABLED=0 RCT_USE_PREBUILT_RNCORE=1 RCT_USE_RN_DEP=1 npx pod-install
44+
run: RCT_NEW_ARCH_ENABLED=${{ matrix.new-arch-enabled }} RCT_USE_PREBUILT_RNCORE=1 RCT_USE_RN_DEP=1 npx pod-install
3545
working-directory: example/ios
36-
- name: Build ios example app on old architecture
37-
run: xcodebuild -scheme ReactTestApp -workspace document-picker-example.xcworkspace ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator -configuration Debug
38-
working-directory: example/ios
39-
ios-build-new-arch:
40-
runs-on: macos-latest
41-
steps:
42-
- uses: actions/checkout@v4
43-
- name: Use Node.js lts
44-
uses: actions/setup-node@v4
45-
with:
46-
node-version: lts/*
47-
- uses: ruby/setup-ruby@v1
48-
with:
49-
ruby-version: 2.7
50-
working-directory: example/ios
51-
bundler-cache: true
52-
- name: Install dependencies
53-
run: yarn install --immutable
54-
- name: Install pods for new arch
55-
run: RCT_NEW_ARCH_ENABLED=1 RCT_USE_PREBUILT_RNCORE=1 RCT_USE_RN_DEP=1 npx pod-install
56-
working-directory: example/ios
57-
- name: Build ios example app on new architecture
46+
- name: Build ios example app on ${{ matrix.description }}
5847
run: xcodebuild -scheme ReactTestApp -workspace document-picker-example.xcworkspace ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator -configuration Debug
5948
working-directory: example/ios

example/android/gradle.properties

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ reactNativeArchitectures=armeabi-v7a,arm64-v8a,x86,x86_64
4040
# to write custom TurboModules/Fabric components OR use libraries that
4141
# are providing them.
4242
# Note that this is incompatible with web debugging.
43-
newArchEnabled=false
44-
bridgelessEnabled=false
43+
newArchEnabled=true
44+
bridgelessEnabled=true
4545

4646
# Uncomment the line below to build React Native from source.
4747
#react.buildFromSource=true

example/package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -29,19 +29,19 @@
2929
"homepage": "https://github.com/react-native-documents/sponsors-only#readme",
3030
"devDependencies": {
3131
"@react-native-community/cli": "^20.0.2",
32-
"@react-native/metro-config": "^0.81.1",
32+
"@react-native/metro-config": "^0.81.4",
3333
"@types/invariant": "^2.2.37",
3434
"@types/jasmine": "^5.1.5",
35-
"@types/react": "^18.3.18",
35+
"@types/react": "^19.1.13",
3636
"@wdio/browserstack-service": "^8.36.1",
3737
"@wdio/cli": "^8.36.1",
3838
"@wdio/jasmine-framework": "^8.36.1",
3939
"@wdio/local-runner": "^8.36.1",
4040
"@wdio/spec-reporter": "^8.36.1",
4141
"appium": "^2.5.4",
4242
"appium-uiautomator2-driver": "^3.1.0",
43-
"pod-install": "1.0.1",
44-
"react-native-test-app": "^4.4.9",
43+
"pod-install": "1.0.7",
44+
"react-native-test-app": "^4.4.10",
4545
"ts-node": "^10.9.2",
4646
"wdio-wait-for": "^3.0.11"
4747
},
@@ -64,6 +64,6 @@
6464
"@react-native-segmented-control/segmented-control": "^2.5.7",
6565
"invariant": "^2.2.4",
6666
"react": "19.1.0",
67-
"react-native": "^0.81.1"
67+
"react-native": "^0.81.4"
6868
}
6969
}

package.json

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -45,17 +45,17 @@
4545
]
4646
},
4747
"dependencies": {
48-
"@changesets/cli": "^2.29.6",
48+
"@changesets/cli": "^2.29.7",
4949
"@commitlint/cli": "^18.6.1",
5050
"@commitlint/config-conventional": "^18.6.3",
5151
"@evilmartians/lefthook": "^1.13.0",
5252
"@jest/globals": "^29.7.0",
53-
"@manypkg/cli": "^0.21.4",
54-
"@react-native/eslint-config": "^0.81.1",
53+
"@manypkg/cli": "^0.25.1",
54+
"@react-native/eslint-config": "^0.81.4",
5555
"@types/jest": "^29.5.14",
5656
"eslint": "^8.57.1",
57-
"eslint-config-prettier": "^9.1.0",
58-
"eslint-plugin-prettier": "^5.2.3",
57+
"eslint-config-prettier": "^9.1.2",
58+
"eslint-plugin-prettier": "^5.5.4",
5959
"jest": "^29.7.0",
6060
"pod-install": "1.0.7",
6161
"prettier": "^3.6.2",

packages/document-picker/android/src/main/java/com/reactnativedocumentpicker/MetadataGetter.kt

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,7 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
138138
private fun <T> getCursorValue(cursor: Cursor, columnName: String, valueType: Class<T>): T? {
139139
val columnIndex = cursor.getColumnIndex(columnName)
140140
if (columnIndex != -1 && !cursor.isNull(columnIndex)) {
141-
return try {
141+
return runCatching {
142142
when (valueType) {
143143
String::class.java -> cursor.getString(columnIndex) as T
144144
Int::class.java -> cursor.getInt(columnIndex) as T
@@ -147,10 +147,8 @@ class MetadataGetter(private val uriMap: MutableMap<String, Uri>) {
147147
Float::class.java -> cursor.getFloat(columnIndex) as T
148148
else -> null
149149
}
150-
} catch (e: Exception) {
151-
// this should not happen but if it does, we return null
152-
null
153-
}
150+
// throw should not happen but if it does, we return null
151+
}.getOrNull()
154152
}
155153
return null
156154
}

packages/document-picker/android/src/main/java/com/reactnativedocumentpicker/RNDocumentPickerPackage.java

Lines changed: 0 additions & 49 deletions
This file was deleted.
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
1+
// LICENSE: see License.md in the package root
2+
package com.reactnativedocumentpicker
3+
4+
import com.facebook.react.BaseReactPackage
5+
import com.facebook.react.bridge.NativeModule
6+
import com.facebook.react.bridge.ReactApplicationContext
7+
import com.facebook.react.module.model.ReactModuleInfo
8+
import com.facebook.react.module.model.ReactModuleInfoProvider
9+
10+
class RNDocumentPickerPackage : BaseReactPackage() {
11+
override fun getModule(name: String, reactContext: ReactApplicationContext): NativeModule? {
12+
return if (name == NativeDocumentPickerSpec.NAME) {
13+
RNDocumentPickerModule(reactContext)
14+
} else {
15+
null
16+
}
17+
}
18+
19+
override fun getReactModuleInfoProvider(): ReactModuleInfoProvider {
20+
return ReactModuleInfoProvider {
21+
val isTurboModule = BuildConfig.IS_NEW_ARCHITECTURE_ENABLED
22+
val moduleInfos = mapOf(
23+
NativeDocumentPickerSpec.NAME to ReactModuleInfo(
24+
NativeDocumentPickerSpec.NAME,
25+
NativeDocumentPickerSpec.NAME, // "DocumentPickerModule",
26+
false, // canOverrideExistingModule
27+
false, // needsEagerInit
28+
false, // isCxxModule
29+
isTurboModule // isTurboModule
30+
)
31+
)
32+
moduleInfos
33+
}
34+
}
35+
}

packages/document-picker/ios/RNDocumentPicker.mm

Lines changed: 0 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -14,10 +14,6 @@
1414
#import "react_native_document_picker-Swift.h"
1515
#endif
1616

17-
// for UIModalPresentationStyle conversion
18-
// remove after https://github.com/facebook/react-native/commit/2d547a3252b328251e49dabfeec85f8d46c85411 is released
19-
#import <React/RCTModalHostViewManager.h>
20-
2117
@interface RNDocumentPicker ()
2218
@end
2319

packages/document-viewer/android/src/main/java/com/reactnativedocumentviewer/RNDocumentViewerPackage.java

Lines changed: 0 additions & 49 deletions
This file was deleted.

0 commit comments

Comments
 (0)