Page Menu
Home
Phabricator
Search
Configure Global Search
Log In
Files
F3540454
D12167.diff
No One
Temporary
Actions
View File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Flag For Later
Size
1 KB
Referenced Files
None
Subscribers
None
D12167.diff
View Options
diff --git a/native/keyboard/keyboard-state-container.react.js b/native/keyboard/keyboard-state-container.react.js
--- a/native/keyboard/keyboard-state-container.react.js
+++ b/native/keyboard/keyboard-state-container.react.js
@@ -1,5 +1,6 @@
// @flow
+import * as MediaLibrary from 'expo-media-library';
import * as React from 'react';
import { Platform } from 'react-native';
import { KeyboardUtils } from 'react-native-keyboard-input';
@@ -68,6 +69,15 @@
}
if (this.state.mediaGalleryOpen && !prevState.mediaGalleryOpen) {
void (async () => {
+ if (Platform.OS === 'android') {
+ // The promise returned from MediaLibrary.requestPermissionsAsync
+ // never resolves on Android if it's invoked from
+ // MediaGalleryKeyboard, which runs in a special environment via
+ // react-native-keyboard-input. To get around this, we invoke it
+ // here, and then use MediaLibrary.getPermissionsAsync in
+ // MediaGalleryKeyboard
+ void MediaLibrary.requestPermissionsAsync();
+ }
await sleep(tabBarAnimationDuration);
await waitForInteractions();
this.setState({ renderKeyboardInputHost: true });
diff --git a/native/media/media-gallery-keyboard.react.js b/native/media/media-gallery-keyboard.react.js
--- a/native/media/media-gallery-keyboard.react.js
+++ b/native/media/media-gallery-keyboard.react.js
@@ -419,7 +419,14 @@
};
async getPermissions(): Promise<boolean> {
- const { granted } = await MediaLibrary.requestPermissionsAsync();
+ let granted = false;
+ if (Platform.OS === 'android') {
+ const result = await MediaLibrary.getPermissionsAsync();
+ granted = result.granted;
+ } else {
+ const result = await MediaLibrary.requestPermissionsAsync();
+ granted = result.granted;
+ }
if (!granted) {
this.guardedSetState({ error: "don't have permission :(" });
}
File Metadata
Details
Attached
Mime Type
text/plain
Expires
Fri, Dec 27, 5:06 AM (9 h, 27 m)
Storage Engine
blob
Storage Format
Raw Data
Storage Handle
2710641
Default Alt Text
D12167.diff (1 KB)
Attached To
Mode
D12167: [native] Fix MediaGalleryKeyboard on Android
Attached
Detach File
Event Timeline
Log In to Comment