Skip to content

Commit 26c45dc

Browse files
authored
[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 36b6a2aec20be6c76748f27a07d9f670d33a1313. * 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+.
1 parent b2104b4 commit 26c45dc

File tree

12 files changed

+564
-57
lines changed

12 files changed

+564
-57
lines changed

packages/image_picker/image_picker/CHANGELOG.md

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,10 @@
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+
18
## 0.7.4
29

310
* Update flutter_plugin_android_lifecycle dependency to 2.0.1 to fix an R8 issue

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

Lines changed: 129 additions & 2 deletions
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 */
@@ -35,6 +35,13 @@
3535
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
3636
remoteInfo = Runner;
3737
};
38+
BE7AEE7126403C46006181AA /* PBXContainerItemProxy */ = {
39+
isa = PBXContainerItemProxy;
40+
containerPortal = 97C146E61CF9000F007C117D /* Project object */;
41+
proxyType = 1;
42+
remoteGlobalIDString = 97C146ED1CF9000F007C117D;
43+
remoteInfo = Runner;
44+
};
3845
/* End PBXContainerItemProxy section */
3946

4047
/* Begin PBXCopyFilesBuildPhase section */
@@ -80,6 +87,9 @@
8087
9FC8F0E8229FA49E00C8D58F /* gifImage.gif */ = {isa = PBXFileReference; lastKnownFileType = image.gif; path = gifImage.gif; sourceTree = "<group>"; };
8188
9FC8F0ED229FB90B00C8D58F /* ImageUtilTests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ImageUtilTests.m; path = ../../../ios/Tests/ImageUtilTests.m; sourceTree = "<group>"; };
8289
A908FAEEA2A9B26D903C09C5 /* libPods-RunnerUITests.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-RunnerUITests.a"; sourceTree = BUILT_PRODUCTS_DIR; };
90+
BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = RunnerUITestiOS14.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
91+
BE7AEE7026403C46006181AA /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
92+
BE7AEE7826403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; path = ImagePickerFromLimitedGalleryUITests.m; sourceTree = "<group>"; };
8393
EC32F6993F4529982D9519F1 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
8494
F78AF3172342D9D7008449C7 /* ImagePickerTestImages.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; name = ImagePickerTestImages.h; path = ../../../ios/Tests/ImagePickerTestImages.h; sourceTree = "<group>"; };
8595
F78AF3182342D9D7008449C7 /* ImagePickerTestImages.m */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.objc; name = ImagePickerTestImages.m; path = ../../../ios/Tests/ImagePickerTestImages.m; sourceTree = "<group>"; };
@@ -90,7 +100,6 @@
90100
isa = PBXFrameworksBuildPhase;
91101
buildActionMask = 2147483647;
92102
files = (
93-
F10E2DB84567A50A8721C9C7 /* libPods-RunnerUITests.a in Frameworks */,
94103
);
95104
runOnlyForDeploymentPostprocessing = 0;
96105
};
@@ -102,6 +111,13 @@
102111
);
103112
runOnlyForDeploymentPostprocessing = 0;
104113
};
114+
BE7AEE6926403C46006181AA /* Frameworks */ = {
115+
isa = PBXFrameworksBuildPhase;
116+
buildActionMask = 2147483647;
117+
files = (
118+
);
119+
runOnlyForDeploymentPostprocessing = 0;
120+
};
105121
/* End PBXFrameworksBuildPhase section */
106122

107123
/* Begin PBXGroup section */
@@ -159,6 +175,7 @@
159175
9740EEB11CF90186004384FC /* Flutter */,
160176
97C146F01CF9000F007C117D /* Runner */,
161177
6801C8372555D726009DAF8D /* RunnerUITests */,
178+
BE7AEE6D26403C46006181AA /* RunnerUITestiOS14 */,
162179
97C146EF1CF9000F007C117D /* Products */,
163180
840012C8B5EDBCF56B0E4AC1 /* Pods */,
164181
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */,
@@ -170,6 +187,7 @@
170187
children = (
171188
97C146EE1CF9000F007C117D /* Runner.app */,
172189
6801C8362555D726009DAF8D /* RunnerUITests.xctest */,
190+
BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */,
173191
);
174192
name = Products;
175193
sourceTree = "<group>";
@@ -198,6 +216,15 @@
198216
name = "Supporting Files";
199217
sourceTree = "<group>";
200218
};
219+
BE7AEE6D26403C46006181AA /* RunnerUITestiOS14 */ = {
220+
isa = PBXGroup;
221+
children = (
222+
BE7AEE7826403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m */,
223+
BE7AEE7026403C46006181AA /* Info.plist */,
224+
);
225+
path = RunnerUITestiOS14;
226+
sourceTree = "<group>";
227+
};
201228
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */ = {
202229
isa = PBXGroup;
203230
children = (
@@ -250,6 +277,24 @@
250277
productReference = 97C146EE1CF9000F007C117D /* Runner.app */;
251278
productType = "com.apple.product-type.application";
252279
};
280+
BE7AEE6B26403C46006181AA /* RunnerUITestiOS14 */ = {
281+
isa = PBXNativeTarget;
282+
buildConfigurationList = BE7AEE7526403C46006181AA /* Build configuration list for PBXNativeTarget "RunnerUITestiOS14" */;
283+
buildPhases = (
284+
BE7AEE6826403C46006181AA /* Sources */,
285+
BE7AEE6926403C46006181AA /* Frameworks */,
286+
BE7AEE6A26403C46006181AA /* Resources */,
287+
);
288+
buildRules = (
289+
);
290+
dependencies = (
291+
BE7AEE7226403C46006181AA /* PBXTargetDependency */,
292+
);
293+
name = RunnerUITestiOS14;
294+
productName = RunnerUITestiOS14;
295+
productReference = BE7AEE6C26403C46006181AA /* RunnerUITestiOS14.xctest */;
296+
productType = "com.apple.product-type.bundle.ui-testing";
297+
};
253298
/* End PBXNativeTarget section */
254299

255300
/* Begin PBXProject section */
@@ -273,6 +318,11 @@
273318
};
274319
};
275320
};
321+
BE7AEE6B26403C46006181AA = {
322+
CreatedOnToolsVersion = 12.4;
323+
ProvisioningStyle = Automatic;
324+
TestTargetID = 97C146ED1CF9000F007C117D;
325+
};
276326
};
277327
};
278328
buildConfigurationList = 97C146E91CF9000F007C117D /* Build configuration list for PBXProject "Runner" */;
@@ -290,6 +340,7 @@
290340
targets = (
291341
97C146ED1CF9000F007C117D /* Runner */,
292342
6801C8352555D726009DAF8D /* RunnerUITests */,
343+
BE7AEE6B26403C46006181AA /* RunnerUITestiOS14 */,
293344
);
294345
};
295346
/* End PBXProject section */
@@ -316,6 +367,13 @@
316367
);
317368
runOnlyForDeploymentPostprocessing = 0;
318369
};
370+
BE7AEE6A26403C46006181AA /* Resources */ = {
371+
isa = PBXResourcesBuildPhase;
372+
buildActionMask = 2147483647;
373+
files = (
374+
);
375+
runOnlyForDeploymentPostprocessing = 0;
376+
};
319377
/* End PBXResourcesBuildPhase section */
320378

321379
/* Begin PBXShellScriptBuildPhase section */
@@ -413,6 +471,14 @@
413471
);
414472
runOnlyForDeploymentPostprocessing = 0;
415473
};
474+
BE7AEE6826403C46006181AA /* Sources */ = {
475+
isa = PBXSourcesBuildPhase;
476+
buildActionMask = 2147483647;
477+
files = (
478+
BE7AEE7926403CC8006181AA /* ImagePickerFromLimitedGalleryUITests.m in Sources */,
479+
);
480+
runOnlyForDeploymentPostprocessing = 0;
481+
};
416482
/* End PBXSourcesBuildPhase section */
417483

418484
/* Begin PBXTargetDependency section */
@@ -421,6 +487,11 @@
421487
target = 97C146ED1CF9000F007C117D /* Runner */;
422488
targetProxy = 6801C83B2555D726009DAF8D /* PBXContainerItemProxy */;
423489
};
490+
BE7AEE7226403C46006181AA /* PBXTargetDependency */ = {
491+
isa = PBXTargetDependency;
492+
target = 97C146ED1CF9000F007C117D /* Runner */;
493+
targetProxy = BE7AEE7126403C46006181AA /* PBXContainerItemProxy */;
494+
};
424495
/* End PBXTargetDependency section */
425496

426497
/* Begin PBXVariantGroup section */
@@ -642,6 +713,53 @@
642713
};
643714
name = Release;
644715
};
716+
BE7AEE7326403C46006181AA /* Debug */ = {
717+
isa = XCBuildConfiguration;
718+
buildSettings = {
719+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
720+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
721+
CLANG_ENABLE_OBJC_WEAK = YES;
722+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
723+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
724+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
725+
CODE_SIGN_STYLE = Automatic;
726+
DEVELOPMENT_TEAM = "";
727+
GCC_C_LANGUAGE_STANDARD = gnu11;
728+
INFOPLIST_FILE = RunnerUITestiOS14/Info.plist;
729+
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
730+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
731+
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
732+
MTL_FAST_MATH = YES;
733+
PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.RunnerUITestiOS14;
734+
PRODUCT_NAME = "$(TARGET_NAME)";
735+
TARGETED_DEVICE_FAMILY = "1,2";
736+
TEST_TARGET_NAME = Runner;
737+
};
738+
name = Debug;
739+
};
740+
BE7AEE7426403C46006181AA /* Release */ = {
741+
isa = XCBuildConfiguration;
742+
buildSettings = {
743+
CLANG_ANALYZER_NUMBER_OBJECT_CONVERSION = YES_AGGRESSIVE;
744+
CLANG_CXX_LANGUAGE_STANDARD = "gnu++14";
745+
CLANG_ENABLE_OBJC_WEAK = YES;
746+
CLANG_WARN_DOCUMENTATION_COMMENTS = YES;
747+
CLANG_WARN_QUOTED_INCLUDE_IN_FRAMEWORK_HEADER = YES;
748+
CLANG_WARN_UNGUARDED_AVAILABILITY = YES_AGGRESSIVE;
749+
CODE_SIGN_STYLE = Automatic;
750+
DEVELOPMENT_TEAM = NHAKRD9N7D;
751+
GCC_C_LANGUAGE_STANDARD = gnu11;
752+
INFOPLIST_FILE = RunnerUITestiOS14/Info.plist;
753+
IPHONEOS_DEPLOYMENT_TARGET = 14.1;
754+
LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/Frameworks @loader_path/Frameworks";
755+
MTL_FAST_MATH = YES;
756+
PRODUCT_BUNDLE_IDENTIFIER = com.baseflow.RunnerUITestiOS14;
757+
PRODUCT_NAME = "$(TARGET_NAME)";
758+
TARGETED_DEVICE_FAMILY = "1,2";
759+
TEST_TARGET_NAME = Runner;
760+
};
761+
name = Release;
762+
};
645763
/* End XCBuildConfiguration section */
646764

647765
/* Begin XCConfigurationList section */
@@ -672,6 +790,15 @@
672790
defaultConfigurationIsVisible = 0;
673791
defaultConfigurationName = Release;
674792
};
793+
BE7AEE7526403C46006181AA /* Build configuration list for PBXNativeTarget "RunnerUITestiOS14" */ = {
794+
isa = XCConfigurationList;
795+
buildConfigurations = (
796+
BE7AEE7326403C46006181AA /* Debug */,
797+
BE7AEE7426403C46006181AA /* Release */,
798+
);
799+
defaultConfigurationIsVisible = 0;
800+
defaultConfigurationName = Release;
801+
};
675802
/* End XCConfigurationList section */
676803
};
677804
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)