Skip to content

Commit aa809f5

Browse files
ydagjolmiracle
authored andcommitted
[image_picker] Image picker phpicker impl (flutter#3835)
* Add PHPicker libraries and its delegate I have to implement PHPicker to select photos, live photos and videos from the photo library for iOS 14 and higher versions. But I also have to keep old UIImagePickerController for lower iOS versions and to use camera. * Add PHPicker implementation * Refactor UIImagePickerController implementation I moved the UIImagePickerController implementation into pickImageWithUIImagePicker method for code reusability. * Refactor handleMethodCall function * Refactor showPhotoLibrary function * Add the limited access into the photo library I refactored the checkPhotoAuthorization function to add limited access functionality. Also I implemented showLimitedPhotoLibrary function to call presentLimitedLibraryPickerFromViewController. * Add the implementation of picker function I implemented picker function that is came from PHPickerViewControllerDelegate. * Refactor Info.plist file I added PHPhotoLibraryPreventAutomaticLimitedAccessAlert = YES into Info.plist to use limited access functionality. * Add the function to get PHAssetResult * Change the image to bypass HEIC problem * Add UITest to test select photo functionality * Add unit test for PHAssetResult * Format the codes in all files * Fix the unit test * Update the version * Add the description into CHANGELOG file * Fix the license header * Remove the unnecessary if statement * Refactor PHPickerViewController to use property * Refactor phPickerFlag state to use property * Refactor the code to combine lines * Refactor arguments to use property * Revert formatting changes This reverts part of commit 36b6a2a. * Fix the unit test * Format the code * Refactor the UITest to skip lower versions * Fix the property's name * Refactor the properties to pass them via methods * Add the getDesiredImageQuality method * Add API_AVAILABLE for limited access method * Refactor PHPickerController to use as a property * Refactor PHPicker picker method and UITest * Refactor the UITest Move to UITest to new target file to test on iOS 14 and higher versions. * Change the team to None in the RunnerUITestiOS14 * Fix the UITest * Refactor the method to fix dispatch * Change to use self instead of weakSelf * Fix the UITest to use XCTSkip * Add ImagePickerClassType to use enum * Remove unused method If the user enabled limited library access, use presentLimitedLibraryPickerFromViewController to present the limited library picker so they may update their selection. But in this case, limited access status will not return with old requestAuthorization implementation in checkPhotoAuthorization method. So this method will not be used. * Fix property to change copy to strong * Refactor enum * Change argument call * Add checkPhotoAuthorizationForAccessLevel method I implemented requestAuthorizationForAccessLevel which is the new way to handle the photo library authorization with iOS 14+. # Conflicts: # packages/image_picker/image_picker/CHANGELOG.md # packages/image_picker/image_picker/example/ios/Runner.xcodeproj/project.pbxproj # packages/image_picker/image_picker/ios/Classes/FLTImagePickerPlugin.m # packages/image_picker/image_picker/pubspec.yaml
1 parent 8f3d217 commit aa809f5

12 files changed

Lines changed: 593 additions & 56 deletions

File tree

packages/image_picker/image_picker/CHANGELOG.md

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,38 @@
1+
## 0.7.5
2+
3+
* Fixes an issue where image rotation is wrong when Select Photos chose and image is scaled.
4+
* Breaking Changes:
5+
* Migrate to PHPicker for iOS 14 and higher versions to pick image from the photo library.
6+
* Implement the limited permission to pick photo from the photo library when Select Photo is chose.
7+
8+
## 0.7.4
9+
10+
* Update flutter_plugin_android_lifecycle dependency to 2.0.1 to fix an R8 issue
11+
on some versions.
12+
13+
## 0.7.3
14+
15+
* Endorse image_picker_for_web
16+
17+
## 0.7.2+1
18+
19+
* Android: fixes an issue where videos could be wrongly picked with `.jpg` extension.
20+
21+
## 0.7.2
22+
23+
* Run CocoaPods iOS tests in RunnerUITests target
24+
25+
## 0.7.1
26+
27+
* Update platform_plugin_interface version requirement.
28+
29+
## 0.7.0
30+
31+
* Migrate to nullsafety
32+
* Breaking Changes:
33+
* Removed the deprecated methods: `ImagePicker.pickImage`, `ImagePicker.pickVideo`,
34+
`ImagePicker.retrieveLostData`
35+
136
## 0.6.7+22
237

338
* iOS: update XCUITests to separate each test session.

packages/image_picker/image_picker/example/ios/Runner.xcodeproj/project.pbxproj

Lines changed: 130 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
1111
5C9513011EC38BD300040975 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */; };
1212
680049262280D736006DD6AB /* MetaDataUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 680049252280D736006DD6AB /* MetaDataUtilTests.m */; };
13-
680049272280D79A006DD6AB /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
1413
680049382280F2B9006DD6AB /* pngImage.png in Resources */ = {isa = PBXBuildFile; fileRef = 680049352280F2B8006DD6AB /* pngImage.png */; };
1514
680049392280F2B9006DD6AB /* jpgImage.jpg in Resources */ = {isa = PBXBuildFile; fileRef = 680049362280F2B8006DD6AB /* jpgImage.jpg */; };
1615
6801C8392555D726009DAF8D /* ImagePickerFromGalleryUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = 6801C8382555D726009DAF8D /* ImagePickerFromGalleryUITests.m */; };
@@ -23,6 +22,7 @@
2322
9FC8F0E9229FA49E00C8D58F /* gifImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */; };
2423
9FC8F0EC229FA68500C8D58F /* gifImage.gif in Resources */ = {isa = PBXBuildFile; fileRef = 9FC8F0E8229FA49E00C8D58F /* gifImage.gif */; };
2524
9FC8F0EE229FB90B00C8D58F /* ImageUtilTests.m in Sources */ = {isa = PBXBuildFile; fileRef = 9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */; };
25+
BE7AEE7926403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m in Sources */ = {isa = PBXBuildFile; fileRef = BE7AEE7826403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m */; };
2626
F4F7A436CCA4BF276270A3AE /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EC32F6993F4529982D9519F1 /* libPods-Runner.a */; };
2727
F78AF3192342D9D7008449C7 /* ImagePickerTestImages.m in Sources */ = {isa = PBXBuildFile; fileRef = F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */; };
2828
/* End PBXBuildFile section */
@@ -42,6 +42,13 @@
4242
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
4343
remoteInfo = Runner;
4444
};
45+
BE7AEE7126403C46006181AA /* PBXContainerItemProxy */ = {
46+
isa = PBXContainerItemProxy;
47+
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
48+
proxyType = 1;
49+
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
50+
remoteInfo = Runner;
51+
};
4552
/* End PBXContainerItemProxy section */
4653

4754
/* Begin PBXCopyFilesBuildPhase section */
@@ -86,6 +93,10 @@
8693
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
8794
9FC8F0E8229FA49E00C8D58F /* gifImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = gifImage.gif; sourceTree = "<group>"; };
8895
9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ImageUtilTests.m; path = ../../../ios/Tests/ImageUtilTests.m; sourceTree = "<group>"; };
96+
A908FAEEA2A9B26D903C09C5 /* libPods-RunnerUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
97+
BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITestiOS14.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
98+
BE7AEE7026403C46006181AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
99+
BE7AEE7826403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromLimitedGalleryUITests.m; sourceTree = "<group>"; };
89100
EC32F6993F4529982D9519F1 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
90101
F78AF3172342D9D7008449C7 /* ImagePickerTestImages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ImagePickerTestImages.h; path = ../../../ios/Tests/ImagePickerTestImages.h; sourceTree = "<group>"; };
91102
F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ImagePickerTestImages.m; path = ../../../ios/Tests/ImagePickerTestImages.m; sourceTree = "<group>"; };
@@ -114,6 +125,13 @@
114125
);
115126
runOnlyForDeploymentPostprocessing = 0;
116127
};
128+
BE7AEE6926403C46006181AA /* Frameworks */ = {
129+
isa = PBXFrameworksBuildPhase;
130+
buildActionMask = 2147483647;
131+
files = (
132+
);
133+
runOnlyForDeploymentPostprocessing = 0;
134+
};
117135
/* End PBXFrameworksBuildPhase section */
118136

119137
/* Begin PBXGroup section */
@@ -178,6 +196,7 @@
178196
97C146F01CF9000F007C117D /* Runner */,
179197
680049182280D368006DD6AB /* image_picker_exampleTests */,
180198
6801C8372555D726009DAF8D /* RunnerUITests */,
199+
BE7AEE6D26403C46006181AA /* RunnerUITestiOS14 */,
181200
97C146EF1CF9000F007C117D /* Products */,
182201
840012C8B5EDBCF56B0E4AC1 /* Pods */,
183202
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
@@ -190,6 +209,7 @@
190209
97C146EE1CF9000F007C117D /* Runner.app */,
191210
680049172280D368006DD6AB /* image_picker_exampleTests.xctest */,
192211
6801C8362555D726009DAF8D /* RunnerUITests.xctest */,
212+
BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */,
193213
);
194214
name = Products;
195215
sourceTree = "<group>";
@@ -218,6 +238,15 @@
218238
name = "Supporting Files";
219239
sourceTree = "<group>";
220240
};
241+
BE7AEE6D26403C46006181AA /* RunnerUITestiOS14 */ = {
242+
isa = PBXGroup;
243+
children = (
244+
BE7AEE7826403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m */,
245+
BE7AEE7026403C46006181AA /* Info.plist */,
246+
);
247+
path = RunnerUITestiOS14;
248+
sourceTree = "<group>";
249+
};
221250
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */ = {
222251
isa = PBXGroup;
223252
children = (
@@ -287,6 +316,24 @@
287316
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
288317
productType = "com.apple.product-type.application";
289318
};
319+
BE7AEE6B26403C46006181AA /* RunnerUITestiOS14 */ = {
320+
isa = PBXNativeTarget;
321+
buildConfigurationList = BE7AEE7526403C46006181AA /* Build configuration list for PBXNativeTarget "RunnerUITestiOS14" */;
322+
buildPhases = (
323+
BE7AEE6826403C46006181AA /* Sources */,
324+
BE7AEE6926403C46006181AA /* Frameworks */,
325+
BE7AEE6A26403C46006181AA /* Resources */,
326+
);
327+
buildRules = (
328+
);
329+
dependencies = (
330+
BE7AEE7226403C46006181AA /* PBXTargetDependency */,
331+
);
332+
name = RunnerUITestiOS14;
333+
productName = RunnerUITestiOS14;
334+
productReference = BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */;
335+
productType = "com.apple.product-type.bundle.ui-testing";
336+
};
290337
/* End PBXNativeTarget section */
291338

292339
/* Begin PBXProject section */
@@ -315,6 +362,11 @@
315362
};
316363
};
317364
};
365+
BE7AEE6B26403C46006181AA = {
366+
CreatedOnToolsVersion = 12.4;
367+
ProvisioningStyle = Automatic;
368+
TestTargetID = 97C146ED1CF9000F007C117D;
369+
};
318370
};
319371
};
320372
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
@@ -333,6 +385,7 @@
333385
97C146ED1CF9000F007C117D /* Runner */,
334386
680049162280D368006DD6AB /* image_picker_exampleTests */,
335387
6801C8352555D726009DAF8D /* RunnerUITests */,
388+
BE7AEE6B26403C46006181AA /* RunnerUITestiOS14 */,
336389
);
337390
};
338391
/* End PBXProject section */
@@ -367,6 +420,13 @@
367420
);
368421
runOnlyForDeploymentPostprocessing = 0;
369422
};
423+
BE7AEE6A26403C46006181AA /* Resources */ = {
424+
isa = PBXResourcesBuildPhase;
425+
buildActionMask = 2147483647;
426+
files = (
427+
);
428+
runOnlyForDeploymentPostprocessing = 0;
429+
};
370430
/* End PBXResourcesBuildPhase section */
371431

372432
/* Begin PBXShellScriptBuildPhase section */
@@ -467,6 +527,14 @@
467527
);
468528
runOnlyForDeploymentPostprocessing = 0;
469529
};
530+
BE7AEE6826403C46006181AA /* Sources */ = {
531+
isa = PBXSourcesBuildPhase;
532+
buildActionMask = 2147483647;
533+
files = (
534+
BE7AEE7926403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m in Sources */,
535+
);
536+
runOnlyForDeploymentPostprocessing = 0;
537+
};
470538
/* End PBXSourcesBuildPhase section */
471539

472540
/* Begin PBXTargetDependency section */
@@ -480,6 +548,11 @@
480548
target = 97C146ED1CF9000F007C117D /* Runner */;
481549
targetProxy = 6801C83B2555D726009DAF8D /* PBXContainerItemProxy */;
482550
};
551+
BE7AEE7226403C46006181AA /* PBXTargetDependency */ = {
552+
isa = PBXTargetDependency;
553+
target = 97C146ED1CF9000F007C117D /* Runner */;
554+
targetProxy = BE7AEE7126403C46006181AA /* PBXContainerItemProxy */;
555+
};
483556
/* End PBXTargetDependency section */
484557

485558
/* Begin PBXVariantGroup section */
@@ -750,6 +823,53 @@
750823
};
751824
name = Release;
752825
};
826+
BE7AEE7326403C46006181AA /* Debug */ = {
827+
isa = XCBuildConfiguration;
828+
buildSettings = {
829+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
830+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
831+
CLANG_ENABLE_OBJC_WEAK = YES;
832+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
833+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
834+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
835+
CODE_SIGN_STYLE = Automatic;
836+
DEVELOPMENT_TEAM = "";
837+
GCC_C_LANGUAGE_STANDARD = gnu11;
838+
INFOPLIST_FILE = RunnerUITestiOS14/Info.plist;
839+
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
840+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
841+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
842+
MTL_FAST_MATH = YES;
843+
PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.RunnerUITestiOS14;
844+
PRODUCT_NAME = "$(TARGET_NAME)";
845+
TARGETED_DEVICE_FAMILY = "1,2";
846+
TEST_TARGET_NAME = Runner;
847+
};
848+
name = Debug;
849+
};
850+
BE7AEE7426403C46006181AA /* Release */ = {
851+
isa = XCBuildConfiguration;
852+
buildSettings = {
853+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
854+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
855+
CLANG_ENABLE_OBJC_WEAK = YES;
856+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
857+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
858+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
859+
CODE_SIGN_STYLE = Automatic;
860+
DEVELOPMENT_TEAM = NHAKRD9N7D;
861+
GCC_C_LANGUAGE_STANDARD = gnu11;
862+
INFOPLIST_FILE = RunnerUITestiOS14/Info.plist;
863+
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
864+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
865+
MTL_FAST_MATH = YES;
866+
PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.RunnerUITestiOS14;
867+
PRODUCT_NAME = "$(TARGET_NAME)";
868+
TARGETED_DEVICE_FAMILY = "1,2";
869+
TEST_TARGET_NAME = Runner;
870+
};
871+
name = Release;
872+
};
753873
/* End XCBuildConfiguration section */
754874

755875
/* Begin XCConfigurationList section */
@@ -789,6 +909,15 @@
789909
defaultConfigurationIsVisible = 0;
790910
defaultConfigurationName = Release;
791911
};
912+
BE7AEE7526403C46006181AA /* Build configuration list for PBXNativeTarget "RunnerUITestiOS14" */ = {
913+
isa = XCConfigurationList;
914+
buildConfigurations = (
915+
BE7AEE7326403C46006181AA /* Debug */,
916+
BE7AEE7426403C46006181AA /* Release */,
917+
);
918+
defaultConfigurationIsVisible = 0;
919+
defaultConfigurationName = Release;
920+
};
792921
/* End XCConfigurationList section */
793922
};
794923
rootObject = 97C146E61CF9000F007C117D /* Project object */;

packages/image_picker/image_picker/example/ios/Runner.xcodeproj/xcshareddata/xcschemes/Runner.xcscheme

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<?xml version="1.0" encoding="UTF-8"?>
22
<Scheme
3-
LastUpgradeVersion = "1100"
3+
LastUpgradeVersion = "1240"
44
version = "1.3">
55
<BuildAction
66
parallelizeBuildables = "YES"
@@ -47,6 +47,16 @@
4747
ReferencedContainer = "container:Runner.xcodeproj">
4848
</BuildableReference>
4949
</TestableReference>
50+
<TestableReference
51+
skipped = "NO">
52+
<BuildableReference
53+
BuildableIdentifier = "primary"
54+
BlueprintIdentifier = "BE7AEE6B26403C46006181AA"
55+
BuildableName = "RunnerUITestiOS14.xctest"
56+
BlueprintName = "RunnerUITestiOS14"
57+
ReferencedContainer = "container:Runner.xcodeproj">
58+
</BuildableReference>
59+
</TestableReference>
5060
</Testables>
5161
</TestAction>
5262
<LaunchAction

0 commit comments

Comments
 (0)