Skip to content

Commit

Permalink
upgrade camera-roll lib to 7.5.2
Browse files Browse the repository at this point in the history
  • Loading branch information
siddarthkay committed Apr 17, 2024
1 parent 280480c commit cbd61fa
Show file tree
Hide file tree
Showing 6 changed files with 23 additions and 334 deletions.
6 changes: 4 additions & 2 deletions ios/Podfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -881,7 +881,9 @@ PODS:
- React-Core
- react-native-blur (4.3.3):
- React-Core
- react-native-cameraroll (5.10.0):
- react-native-cameraroll (7.5.2):
- glog
- RCT-Folly (= 2022.05.16.00)
- React-Core
- react-native-config (1.5.0):
- react-native-config/App (= 1.5.0)
Expand Down Expand Up @@ -1475,7 +1477,7 @@ SPEC CHECKSUMS:
react-native-biometrics: 352e5a794bfffc46a0c86725ea7dc62deb085bdc
react-native-blob-util: 600972b1782380a5a7d5db61a3817ea32349dae9
react-native-blur: c6d0a1dc2b4b519f7afe3b14d8151998632b6d18
react-native-cameraroll: 4701ae7c3dbcd3f5e9e150ca17f250a276154b35
react-native-cameraroll: af8eec1e585d053ff485d98ec837f9a8a11b5745
react-native-config: 5330c8258265c1e5fdb8c009d2cabd6badd96727
react-native-hole-view: 6935448993bac79f2b5a4ad7e9741094cf810679
react-native-image-resizer: 2f1577efa3bc762597681f530c8e8d05ce0ceeb3
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
},
"dependencies": {
"@react-native-async-storage/async-storage": "1.19.3",
"@react-native-camera-roll/camera-roll": "5.10.0",
"@react-native-camera-roll/camera-roll": "7.5.2",
"@react-native-clipboard/clipboard": "1.13.2",
"@react-native-community/audio-toolkit": "git+https://github.com/tbenr/react-native-audio-toolkit.git#refs/tags/v2.0.3-status-v6",
"@react-native-community/blur": "git+https://github.com/status-im/react-native-blur.git#refs/tags/v4.3.3-status",
Expand Down
176 changes: 5 additions & 171 deletions patches/CameraRoll.ts.patch
Original file line number Diff line number Diff line change
@@ -1,109 +1,6 @@
--- /tmp/tmp-status-mobile-8a12ad351/tmp.SnIPZikasU/CameraRoll.ts 2024-04-16 12:22:28.722553000 +0200
+++ ./node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts 2024-04-16 12:22:40.347610946 +0200
@@ -24,32 +24,32 @@
};

export type GroupTypes =
- | 'Album'
- | 'All'
- | 'Event'
- | 'Faces'
- | 'Library'
- | 'PhotoStream'
- | 'SavedPhotos';
+ | 'Album'
+ | 'All'
+ | 'Event'
+ | 'Faces'
+ | 'Library'
+ | 'PhotoStream'
+ | 'SavedPhotos';

export type SubTypes =
- | 'PhotoPanorama'
- | 'PhotoHDR'
- | 'PhotoScreenshot'
- | 'PhotoLive'
- | 'PhotoDepthEffect'
- | 'VideoStreamed'
- | 'VideoHighFrameRate'
- | 'VideoTimelapse';
+ | 'PhotoPanorama'
+ | 'PhotoHDR'
+ | 'PhotoScreenshot'
+ | 'PhotoLive'
+ | 'PhotoDepthEffect'
+ | 'VideoStreamed'
+ | 'VideoHighFrameRate'
+ | 'VideoTimelapse';

export type Include =
- | 'filename'
- | 'fileSize'
- | 'fileExtension'
- | 'location'
- | 'imageSize'
- | 'playableDuration'
- | 'orientation';
+ | 'filename'
+ | 'fileSize'
+ | 'fileExtension'
+ | 'location'
+ | 'imageSize'
+ | 'playableDuration'
+ | 'orientation';

export type AssetType = 'All' | 'Videos' | 'Photos';

@@ -164,14 +164,14 @@
};

export type AlbumSubType =
- | 'AlbumRegular'
- | 'AlbumSyncedEvent'
- | 'AlbumSyncedFaces'
- | 'AlbumSyncedAlbum'
- | 'AlbumImported'
- | 'AlbumMyPhotoStream'
- | 'AlbumCloudShared'
- | 'Unknown';
+ | 'AlbumRegular'
+ | 'AlbumSyncedEvent'
+ | 'AlbumSyncedFaces'
+ | 'AlbumSyncedAlbum'
+ | 'AlbumImported'
+ | 'AlbumMyPhotoStream'
+ | 'AlbumCloudShared'
+ | 'Unknown';

export type Album = {
title: string;
@@ -180,18 +180,18 @@
};

export type ThumbnailSize = {
- height: number,
- width: number
+ height: number;
+ width: number;
};

export type PhotoThumbnailOptions = {
- allowNetworkAccess: boolean, //iOS only
- targetSize: ThumbnailSize,
- quality: number
+ allowNetworkAccess: boolean; //iOS only
+ targetSize: ThumbnailSize;
+ quality: number;
};

export type PhotoThumbnail = {
- thumbnailBase64: string,
+ thumbnailBase64: string;
};

/**
@@ -213,12 +213,25 @@
--- /tmp/tmp-status-mobile-3907e6b2e/tmp.re8kHerusA/CameraRoll.ts 2024-04-16 15:17:12.942432000 +0200
+++ ./node_modules/@react-native-camera-roll/camera-roll/src/CameraRoll.ts 2024-04-16 15:17:42.455250986 +0200
@@ -239,6 +239,19 @@
}

/**
Expand All @@ -120,69 +17,6 @@
+ }
+
+ /**
* Saves the photo or video to the camera roll or photo library.
* Saves the photo or video to the camera roll or photo library, and returns the URI of the newly created asset.
*
*/
static save(
- tag: string,
- options: SaveToCameraRollOptions = {},
+ tag: string,
+ options: SaveToCameraRollOptions = {},
): Promise<string> {
let {type = 'auto'} = options;
const {album = ''} = options;
@@ -234,17 +247,17 @@
}

static saveToCameraRoll(
- tag: string,
- type?: 'photo' | 'video' | 'auto',
+ tag: string,
+ type?: 'photo' | 'video' | 'auto',
): Promise<string> {
console.warn(
- 'CameraRoll.saveToCameraRoll(tag, type) is deprecated. Use the save function instead',
+ 'CameraRoll.saveToCameraRoll(tag, type) is deprecated. Use the save function instead',
);
return CameraRoll.save(tag, {type});
}

static getAlbums(
- params: GetAlbumsParams = {assetType: 'All'},
+ params: GetAlbumsParams = {assetType: 'All'},
): Promise<Album[]> {
return RNCCameraRoll.getAlbums(params);
}
@@ -279,8 +292,8 @@
* @returns Promise<PhotoIdentifier>
*/
static iosGetImageDataById(
- internalID: string,
- convertHeicImages = false,
+ internalID: string,
+ convertHeicImages = false,
): Promise<PhotoIdentifier> {
const conversionOption: PhotoConvertionOptions = {
convertHeicImages: convertHeicImages,
@@ -288,14 +301,17 @@
return RNCCameraRoll.getPhotoByInternalID(internalID, conversionOption);
}

- /**
+ /**
* Returns a Promise with thumbnail photo.
*
* @param internalID - PH photo internal ID.
* @param options - thumbnail photo options.
* @returns Promise<PhotoThumbnail>
*/
- static getPhotoThumbnail(internalID: string, options: PhotoThumbnailOptions): Promise<PhotoThumbnail> {
- return RNCCameraRoll.getPhotoThumbnail(internalID, options);
- }
+ static getPhotoThumbnail(
+ internalID: string,
+ options: PhotoThumbnailOptions,
+ ): Promise<PhotoThumbnail> {
+ return RNCCameraRoll.getPhotoThumbnail(internalID, options);
+ }
}
* @deprecated `save(...)` is deprecated - use `saveAsset(...)` instead.
73 changes: 5 additions & 68 deletions patches/NativeCameraRollModule.ts.patch
Original file line number Diff line number Diff line change
@@ -1,74 +1,11 @@
--- /tmp/tmp-status-mobile-8a12ad351/tmp.v1Aju1hKVG/NativeCameraRollModule.ts 2024-04-16 12:14:39.262541000 +0200
+++ ./node_modules/@react-native-camera-roll/camera-roll/src/NativeCameraRollModule.ts 2024-04-16 12:21:34.905876910 +0200
@@ -2,17 +2,17 @@
// we use Object type because methods on the native side use NSDictionary and ReadableMap
// and we want to stay compatible with those
import {TurboModuleRegistry, TurboModule} from 'react-native';
-import type { PhotoThumbnail } from './CameraRoll';
+import type {PhotoThumbnail} from './CameraRoll';

export type AlbumSubType =
- | 'AlbumRegular'
- | 'AlbumSyncedEvent'
- | 'AlbumSyncedFaces'
- | 'AlbumSyncedAlbum'
- | 'AlbumImported'
- | 'AlbumMyPhotoStream'
- | 'AlbumCloudShared'
- | 'Unknown';
+ | 'AlbumRegular'
+ | 'AlbumSyncedEvent'
+ | 'AlbumSyncedFaces'
+ | 'AlbumSyncedAlbum'
+ | 'AlbumImported'
+ | 'AlbumMyPhotoStream'
+ | 'AlbumCloudShared'
+ | 'Unknown';

type Album = {
title: string;
@@ -21,14 +21,14 @@
};

type SubTypes =
- | 'PhotoPanorama'
- | 'PhotoHDR'
- | 'PhotoScreenshot'
- | 'PhotoLive'
- | 'PhotoDepthEffect'
- | 'VideoStreamed'
- | 'VideoHighFrameRate'
- | 'VideoTimelapse';
+ | 'PhotoPanorama'
+ | 'PhotoHDR'
+ | 'PhotoScreenshot'
+ | 'PhotoLive'
+ | 'PhotoDepthEffect'
+ | 'VideoStreamed'
+ | 'VideoHighFrameRate'
+ | 'VideoTimelapse';

type PhotoIdentifier = {
node: {
@@ -73,14 +73,16 @@
--- /tmp/tmp-status-mobile-3907e6b2e/tmp.juxTO1BeCM/NativeCameraRollModule.ts 2024-04-16 15:21:28.379979000 +0200
+++ ./node_modules/@react-native-camera-roll/camera-roll/src/NativeCameraRollModule.ts 2024-04-16 15:21:40.490391291 +0200
@@ -81,6 +81,8 @@
getPhotos(params: Object): Promise<PhotoIdentifiersPage>;
getAlbums(params: Object): Promise<Album[]>;
deletePhotos(photoUris: Array<string>): Promise<void>;
+ getPhotosCountiOS(arg: string): Promise<number>;
+ getFavoritesiOS(arg: string): Promise<Album>;
getPhotoByInternalID(
- internalID: string,
- options: Object,
+ internalID: string,
+ options: Object,
): Promise<PhotoIdentifier>;
getPhotoThumbnail(
- internalID: string,
- options: Object
- ): Promise<PhotoThumbnail>
+ internalID: string,
+ options: Object,
+ ): Promise<PhotoThumbnail>;
}

export default TurboModuleRegistry.getEnforcing<Spec>('RNCCameraRoll');
internalID: string,
options: Object,
92 changes: 4 additions & 88 deletions patches/RNCCameraRoll.mm.patch
Original file line number Diff line number Diff line change
@@ -1,91 +1,7 @@
--- /tmp/tmp-status-mobile-8a12ad351/tmp.1GxFrJZyJK/RNCCameraRoll.mm 2024-04-16 12:08:50.684272000 +0200
+++ ./node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm 2024-04-16 12:09:28.792265816 +0200
@@ -178,14 +178,14 @@
if ([[inputURI.pathExtension lowercaseString] isEqualToString:@"webp"]) {
UIImage *webpImage;

- #ifdef SD_WEB_IMAGE_WEBP_CODER_AVAILABLE
+ #ifdef SD_WEB_IMAGE_WEBP_CODER_AVAILABLE
webpImage = [[SDImageWebPCoder sharedCoder] decodedImageWithData:data options:nil];
#else
if (@available(iOS 14, *)) {
webpImage = [UIImage imageWithData:data];
}
#endif
-
+
if (webpImage) {
data = UIImageJPEGRepresentation(webpImage, 1.0);
}
@@ -701,15 +701,15 @@
checkPhotoLibraryConfig();

BOOL const allowNetworkAccess = options[@"allowNetworkAccess"] == nil ? NO : [RCTConvert BOOL:options[@"allowNetworkAccess"]];
-
+
NSDictionary *const targetSize = [RCTConvert NSDictionary:options[@"targetSize"]];
CGFloat const targetHeight = targetSize[@"height"] == nil ? 400 : [RCTConvert CGFloat:targetSize[@"height"]];
CGFloat const targetWidth = targetSize[@"width"] == nil ? 400 : [RCTConvert CGFloat:targetSize[@"width"]];
-
+
CGFloat quality = options[@"quality"] == nil ? 1.0 : [RCTConvert CGFloat:options[@"quality"]];

requestPhotoLibraryAccess(reject, ^(bool isLimited){
-
+
PHFetchResult<PHAsset *> *fetchResult;
PHAsset *asset;
NSString *mediaIdentifier = internalId;
@@ -729,7 +729,7 @@
requestOptions.networkAccessAllowed = allowNetworkAccess;
requestOptions.version = PHImageRequestOptionsVersionUnadjusted;
requestOptions.deliveryMode = PHImageRequestOptionsDeliveryModeHighQualityFormat;
-
+
CGSize const thumbnailSize = CGSizeMake(targetWidth, targetHeight);
[[PHImageManager defaultManager] requestImageForAsset:asset
targetSize:thumbnailSize
@@ -741,9 +741,9 @@
if (error) {
reject(@"Error while getting thumbnail image",@"Error while getting thumbnail image",error);
}
-
+
NSString *thumbnailBase64 = [UIImageJPEGRepresentation(image, quality) base64EncodedStringWithOptions:NSDataBase64EncodingEndLineWithLineFeed];
-
+
resolve(@{
@"thumbnailBase64": thumbnailBase64
});
@@ -759,7 +759,7 @@

NSString *subTypeLabelForCollection(PHAssetCollection *assetCollection) {
PHAssetCollectionSubtype subtype = assetCollection.assetCollectionSubtype;
-
+
switch (subtype) {
case PHAssetCollectionSubtypeAlbumRegular:
return @"AlbumRegular";
@@ -774,7 +774,7 @@
case PHAssetCollectionSubtypeAlbumMyPhotoStream:
return @"AlbumMyPhotoStream";
case PHAssetCollectionSubtypeAlbumCloudShared:
- return @"AlbumCloudShared";
+ return @"AlbumCloudShared";
default:
return @"Unknown";
}
@@ -783,7 +783,7 @@
- (NSArray<NSString *> *) mediaSubTypeLabelsForAsset:(PHAsset *)asset {
PHAssetMediaSubtype subtype = asset.mediaSubtypes;
NSMutableArray<NSString*> *mediaSubTypeLabels = [NSMutableArray array];
-
+
if (subtype & PHAssetMediaSubtypePhotoPanorama) {
[mediaSubTypeLabels addObject:@"PhotoPanorama"];
}
@@ -812,6 +812,53 @@
return mediaSubTypeLabels;
--- /tmp/tmp-status-mobile-3907e6b2e/tmp.O0mkyjqnsy/RNCCameraRoll.mm 2024-04-16 15:26:23.070258000 +0200
+++ ./node_modules/@react-native-camera-roll/camera-roll/ios/RNCCameraRoll.mm 2024-04-16 15:26:32.664996066 +0200
@@ -955,6 +955,53 @@
return [albumTitles copy];
}

+RCT_EXPORT_METHOD(getPhotosCountiOS:(NSString *)blank
Expand Down
Loading

0 comments on commit cbd61fa

Please sign in to comment.