Skip to content

Commit 19c44f8

Browse files
authored
fix(android): remove deprecated activity getters (#867)
* fix(android): remove deprecated activity getters * chore: remove uitextview dep * Fix deprecated activity getters in Android * chore: yarn install * chore: yarn install
1 parent 9c041cd commit 19c44f8

File tree

8 files changed

+83
-107
lines changed

8 files changed

+83
-107
lines changed

.changeset/late-rockets-report.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
"@react-native-documents/picker": patch
3+
---
4+
5+
fix(android): remove deprecated activity getters

.github/workflows/ios.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ jobs:
3131
- name: Install dependencies
3232
run: yarn install --immutable
3333
- name: Install pods
34-
run: RCT_NEW_ARCH_ENABLED=0 npx pod-install
34+
run: RCT_NEW_ARCH_ENABLED=0 RCT_USE_PREBUILT_RNCORE=1 RCT_USE_RN_DEP=1 npx pod-install
3535
working-directory: example/ios
3636
- name: Build ios example app on old architecture
3737
run: xcodebuild -scheme ReactTestApp -workspace document-picker-example.xcworkspace ONLY_ACTIVE_ARCH=NO -sdk iphonesimulator -configuration Debug

example/ios/Podfile.lock

Lines changed: 4 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -1304,7 +1304,7 @@ PODS:
13041304
- ReactCommon/turbomodule/core
13051305
- ReactNativeDependencies
13061306
- Yoga
1307-
- react-native-document-viewer (1.0.1):
1307+
- react-native-document-viewer (1.0.2):
13081308
- hermes-engine
13091309
- RCTRequired
13101310
- RCTTypeSafety
@@ -1328,28 +1328,6 @@ PODS:
13281328
- Yoga
13291329
- react-native-segmented-control (2.5.7):
13301330
- React-Core
1331-
- react-native-uitextview (2.1.0-rc.0):
1332-
- hermes-engine
1333-
- RCTRequired
1334-
- RCTTypeSafety
1335-
- React-Core
1336-
- React-Core-prebuilt
1337-
- React-debug
1338-
- React-Fabric
1339-
- React-featureflags
1340-
- React-graphics
1341-
- React-ImageManager
1342-
- React-jsi
1343-
- React-NativeModulesApple
1344-
- React-RCTFabric
1345-
- React-renderercss
1346-
- React-rendererdebug
1347-
- React-utils
1348-
- ReactCodegen
1349-
- ReactCommon/turbomodule/bridging
1350-
- ReactCommon/turbomodule/core
1351-
- ReactNativeDependencies
1352-
- Yoga
13531331
- React-NativeModulesApple (0.81.1):
13541332
- hermes-engine
13551333
- React-callinvoker
@@ -1724,7 +1702,7 @@ PODS:
17241702
- ReactCommon/turbomodule/core
17251703
- ReactNativeDependencies
17261704
- Yoga
1727-
- ReactTestApp-DevSupport (4.4.9):
1705+
- ReactTestApp-DevSupport (4.4.10):
17281706
- React-Core
17291707
- React-jsi
17301708
- ReactTestApp-Resources (1.0.0-dev)
@@ -1792,7 +1770,6 @@ DEPENDENCIES:
17921770
- react-native-document-picker (from `../../packages/document-picker`)
17931771
- react-native-document-viewer (from `../../packages/document-viewer`)
17941772
- "react-native-segmented-control (from `../../node_modules/@react-native-segmented-control/segmented-control`)"
1795-
- react-native-uitextview (from `../../node_modules/react-native-uitextview`)
17961773
- React-NativeModulesApple (from `../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios`)
17971774
- React-oscompat (from `../../node_modules/react-native/ReactCommon/oscompat`)
17981775
- React-perflogger (from `../../node_modules/react-native/ReactCommon/reactperflogger`)
@@ -1908,8 +1885,6 @@ EXTERNAL SOURCES:
19081885
:path: "../../packages/document-viewer"
19091886
react-native-segmented-control:
19101887
:path: "../../node_modules/@react-native-segmented-control/segmented-control"
1911-
react-native-uitextview:
1912-
:path: "../../node_modules/react-native-uitextview"
19131888
React-NativeModulesApple:
19141889
:path: "../../node_modules/react-native/ReactCommon/react/nativemodule/core/platform/ios"
19151890
React-oscompat:
@@ -2020,9 +1995,8 @@ SPEC CHECKSUMS:
20201995
React-Mapbuffer: bc36232966c55d5b1cbef3b84cb97c4317fa4403
20211996
React-microtasksnativemodule: cbabfedcf6c2984e59d07f9ab553f3d277599b1b
20221997
react-native-document-picker: e06c0a5836adabd1b58e4f956bb3b5b58d7766e2
2023-
react-native-document-viewer: aab4b9b37bebfe95f10679085666ec6fe424fa38
1998+
react-native-document-viewer: 49cf47192ee7e15f4ad25f8fdaef6b4f1ab0cc9c
20241999
react-native-segmented-control: bf6e0032726727498e18dd437ae88afcdbc18e99
2025-
react-native-uitextview: d24acf59b5d64c9f0ddcd86d23629655460c1f3f
20262000
React-NativeModulesApple: 055e2d1417c663e7a26fc0847609f503e626e9e1
20272001
React-oscompat: 8f2893713639e12c7558750a9f7de3f08ac255b0
20282002
React-perflogger: 34b632f94b15e1068f7997e5a68b40a55162ad13
@@ -2055,7 +2029,7 @@ SPEC CHECKSUMS:
20552029
ReactCommon: 3579ef7cd884fbb5218bed929f25b7b212299700
20562030
ReactNativeDependencies: 9444683ddc7eaa98d2289224ce730a7632b705ff
20572031
ReactNativeHost: 7f059fda99bc0ba0187c19bfe91866c7692d90df
2058-
ReactTestApp-DevSupport: f62a6d484c9aff112862cec102aa1b526f7714aa
2032+
ReactTestApp-DevSupport: 9b7bbba5e8fed998e763809171d9906a1375f9d3
20592033
ReactTestApp-Resources: 1bd9ff10e4c24f2ad87101a32023721ae923bccf
20602034
RNCAsyncStorage: 3a4f5e2777dae1688b781a487923a08569e27fe4
20612035
Yoga: 18b87f28df0aee34fa7370518a35aa8107ba47b9

example/package.json

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -64,7 +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",
68-
"react-native-uitextview": "^2.1.0-rc.0"
67+
"react-native": "^0.81.1"
6968
}
7069
}
Lines changed: 2 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,12 @@
11
import React from 'react'
2-
import { UITextView } from 'react-native-uitextview'
32
import { Platform, TextInput, Text } from 'react-native'
4-
// note this is not stable yet
53

64
export type SelectableTextProps = {
75
value: string | Record<string, any>
86
accessibilityLabel: string
97
}
108
const style = { color: 'black' } as const
119

12-
const SelectableTextPaper = ({ value, accessibilityLabel }: SelectableTextProps) => {
13-
const toRender = typeof value === 'string' ? value : JSON.stringify(value, null, 2)
14-
return (
15-
<UITextView style={style} accessibilityLabel={accessibilityLabel} selectable uiTextView>
16-
{toRender}
17-
</UITextView>
18-
)
19-
}
20-
2110
const SelectableTextFabric = ({ value, accessibilityLabel }: SelectableTextProps) => {
2211
const toRender = typeof value === 'string' ? value : JSON.stringify(value, null, 2)
2312
return Platform.OS === 'ios' ? (
@@ -35,6 +24,5 @@ const SelectableTextFabric = ({ value, accessibilityLabel }: SelectableTextProps
3524
</Text>
3625
)
3726
}
38-
// @ts-ignore
39-
const isFabricEnabled = global.nativeFabricUIManager !== null
40-
export const SelectableText = isFabricEnabled ? SelectableTextFabric : SelectableTextPaper
27+
// maybe use different implementation for old architecture
28+
export const SelectableText = SelectableTextFabric

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@
4848
"@changesets/cli": "^2.29.6",
4949
"@commitlint/cli": "^18.6.1",
5050
"@commitlint/config-conventional": "^18.6.3",
51-
"@evilmartians/lefthook": "^1.10.10",
51+
"@evilmartians/lefthook": "^1.13.0",
5252
"@jest/globals": "^29.7.0",
5353
"@manypkg/cli": "^0.21.4",
5454
"@react-native/eslint-config": "^0.81.1",
@@ -57,8 +57,8 @@
5757
"eslint-config-prettier": "^9.1.0",
5858
"eslint-plugin-prettier": "^5.2.3",
5959
"jest": "^29.7.0",
60-
"pod-install": "1.0.1",
61-
"prettier": "^3.4.2",
60+
"pod-install": "1.0.7",
61+
"prettier": "^3.6.2",
6262
"typescript": "^5.7.3"
6363
},
6464
"packageManager": "yarn@4.9.4"

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

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -83,12 +83,8 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
8383

8484
@ReactMethod
8585
override fun pick(opts: ReadableMap, promise: Promise) {
86-
val currentActivity = currentActivity
86+
val currentActivity = reactApplicationContext.currentActivity ?: return rejectWithNullActivity(promise)
8787

88-
if (currentActivity == null) {
89-
rejectWithNullActivity(promise)
90-
return
91-
}
9288
if (!promiseWrapper.trySetPromiseRejectingIncoming(promise, "pick")) {
9389
return
9490
}
@@ -145,11 +141,8 @@ class RNDocumentPickerModule(reactContext: ReactApplicationContext) :
145141

146142
@ReactMethod
147143
override fun pickDirectory(opts: ReadableMap, promise: Promise) {
148-
val currentActivity = currentActivity
149-
if (currentActivity == null) {
150-
rejectWithNullActivity(promise)
151-
return
152-
}
144+
val currentActivity = reactApplicationContext.currentActivity ?: return rejectWithNullActivity(promise)
145+
153146
if (!promiseWrapper.trySetPromiseRejectingIncoming(promise, "pickDirectory")) {
154147
return
155148
}

0 commit comments

Comments
 (0)