about summary refs log tree commit diff
path: root/patches
diff options
context:
space:
mode:
authorSamuel Newman <mozzius@protonmail.com>2025-07-21 17:33:59 +0300
committerGitHub <noreply@github.com>2025-07-21 09:33:59 -0500
commit74f7a44d7192dbd09138c1d82b798a3c6ea68cfd (patch)
tree0afb7dbdde230e9cd69a73c7e3ace73c4a60bc59 /patches
parent760b184d28d2addc556c7ed738d57b6adfba1b56 (diff)
downloadvoidsky-74f7a44d7192dbd09138c1d82b798a3c6ea68cfd.tar.zst
Patch in upstream fix for video rotation on Android (#8635)
* patch in upstream fix

* build expo-image-picker from source so that patch takes
Diffstat (limited to 'patches')
-rw-r--r--patches/expo-image-picker+16.1.4.patch38
-rw-r--r--patches/expo-image-picker+16.1.4.patch.md5
2 files changed, 43 insertions, 0 deletions
diff --git a/patches/expo-image-picker+16.1.4.patch b/patches/expo-image-picker+16.1.4.patch
new file mode 100644
index 000000000..0396fecbc
--- /dev/null
+++ b/patches/expo-image-picker+16.1.4.patch
@@ -0,0 +1,38 @@
+diff --git a/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/MediaHandler.kt b/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/MediaHandler.kt
+index c863fb8..cde8859 100644
+--- a/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/MediaHandler.kt
++++ b/node_modules/expo-image-picker/android/src/main/java/expo/modules/imagepicker/MediaHandler.kt
+@@ -101,16 +101,30 @@ internal class MediaHandler(
+       val fileData = getAdditionalFileData(sourceUri)
+       val mimeType = getType(context.contentResolver, sourceUri)
+ 
++      // Extract basic metadata
++      var width = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH)
++      var height = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT)
++      val rotation = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION)
++
++      // Android returns the encoded width/height which do not take the display rotation into
++      // account. For videos recorded in portrait mode the encoded dimensions are often landscape
++      // (e.g. 1920x1080) paired with a 90°/270° rotation flag.  iOS adjusts these values before
++      // reporting them, so to keep the behaviour consistent across platforms we swap the width
++      // and height when the rotation indicates the video should be displayed in portrait.
++      if (rotation % 180 != 0) {
++        width = height.also { height = width }
++      }
++
+       return ImagePickerAsset(
+         type = MediaType.VIDEO,
+         uri = outputUri.toString(),
+-        width = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_WIDTH),
+-        height = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_HEIGHT),
++        width = width,
++        height = height,
+         fileName = fileData?.fileName,
+         fileSize = fileData?.fileSize,
+         mimeType = mimeType,
+         duration = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_DURATION),
+-        rotation = metadataRetriever.extractInt(MediaMetadataRetriever.METADATA_KEY_VIDEO_ROTATION),
++        rotation = rotation,
+         assetId = sourceUri.getMediaStoreAssetId()
+       )
+     } catch (cause: FailedToExtractVideoMetadataException) {
diff --git a/patches/expo-image-picker+16.1.4.patch.md b/patches/expo-image-picker+16.1.4.patch.md
new file mode 100644
index 000000000..7855e8621
--- /dev/null
+++ b/patches/expo-image-picker+16.1.4.patch.md
@@ -0,0 +1,5 @@
+# Expo Image Picker patch
+
+Cherry-picked https://github.com/expo/expo/pull/37849
+
+Remove when we update to a version that includes this commit.