Skip to content
This repository has been archived by the owner on Feb 22, 2023. It is now read-only.

Adding Video Capability to image_picker #565

Merged
merged 45 commits into from
May 27, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
45 commits
Select commit Hold shift + click to select a range
e81b561
Merge pull request #1 from flutter/master
rodydavis May 10, 2018
6f35340
Adding Video Record and Selection for Android and iOS
rodydavis May 11, 2018
3b660f5
Fixing Null Error on Video Selection
rodydavis May 11, 2018
a1143e4
Updating Number
rodydavis May 11, 2018
54c3f68
Updating Formating
rodydavis May 11, 2018
4f3b1c3
Rolling Back Number
rodydavis May 11, 2018
74f775d
Updating Formating
rodydavis May 11, 2018
1fb8bf7
Revert "Updating Formating"
rodydavis May 11, 2018
86d5e88
Revert "Revert "Updating Formating""
rodydavis May 11, 2018
eaa2f8d
Revert "Revert "Revert "Updating Formating"""
rodydavis May 11, 2018
c6e35da
Revert "Rolling Back Number"
rodydavis May 11, 2018
7e83b8f
Revert "Updating Formating"
rodydavis May 11, 2018
ae48534
Revert "Updating Number"
rodydavis May 11, 2018
97bc60d
Updating Formatting
rodydavis May 11, 2018
95b6bb3
Updating Formatting
rodydavis May 11, 2018
d7d342e
Updating Formatting Based on Google Style Guide
rodydavis May 11, 2018
ffe05d0
Fixing Spacing
rodydavis May 11, 2018
06d837e
Updating Formatting based on Test Fail
rodydavis May 11, 2018
9754383
Working on Fixing Failed Tests
rodydavis May 11, 2018
ddd770c
Update main.dart
rodydavis May 16, 2018
a2ee99d
Updated Authors
rodydavis May 16, 2018
fd38d12
Update CHANGELOG.md
rodydavis May 16, 2018
bfc5dc9
Adding Video Player
rodydavis May 16, 2018
3a2f735
Updating Dependencies
rodydavis May 16, 2018
883f99d
Updating Stying
rodydavis May 16, 2018
dd9ef1f
Update main.dart
rodydavis May 16, 2018
111d568
Updating Project with PR Changes
rodydavis May 24, 2018
16ea638
Ignoring .vscode files
rodydavis May 24, 2018
2a30285
Removing Comments and Updating Changelog
rodydavis May 24, 2018
af2d018
Updating Changes for PR
rodydavis May 24, 2018
ce609b4
Fixing Formatting
rodydavis May 24, 2018
cd7e45f
Refactoring for PR
rodydavis May 24, 2018
d56aa5a
Updating Format
rodydavis May 24, 2018
e4c025b
Update .gitignore
rodydavis May 25, 2018
5a580bf
Updating Set State
rodydavis May 25, 2018
8161e02
Removing .settings .project .classpath
rodydavis May 25, 2018
e0f0d62
Merge branch 'image_picker_video' of https://github.com/AppleEducate/…
rodydavis May 25, 2018
f8ffc37
Removing Files
rodydavis May 25, 2018
b39d2fa
Updating Example
rodydavis May 25, 2018
a67bf89
Merge branch 'master' into image_picker_video
rodydavis May 25, 2018
9f73d2d
Adding Line
rodydavis May 25, 2018
e1b1075
Merge branch 'image_picker_video' of https://github.com/AppleEducate/…
rodydavis May 25, 2018
1ce00fb
Update .gitignore
rodydavis May 25, 2018
f962130
Update main.dart
rodydavis May 25, 2018
494de63
Update main.dart
rodydavis May 25, 2018
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions packages/image_picker/CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
## 0.4.2

* Added support for picking videos.
* Updated example app to show video preview.

## 0.4.1

* Bugfix: the `pickImage` method will now return null when the user cancels picking the image, instead of hanging indefinitely.
Expand Down
5 changes: 3 additions & 2 deletions packages/image_picker/android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="io.flutter.plugins.imagepicker">
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>
<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
<uses-permission android:name="android.permission.CAMERA"/>

<application>
<provider
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -180,6 +180,61 @@ public void onScanCompleted(String path, Uri uri) {
this.fileUtils = fileUtils;
}

public void chooseVideoFromGallery(MethodCall methodCall, MethodChannel.Result result) {
if (!setPendingMethodCallAndResult(methodCall, result)) {
finishWithAlreadyActiveError();
return;
}

if (!permissionManager.isPermissionGranted(Manifest.permission.READ_EXTERNAL_STORAGE)) {
permissionManager.askForPermission(
Manifest.permission.READ_EXTERNAL_STORAGE, REQUEST_EXTERNAL_STORAGE_PERMISSION);
return;
}

launchPickVideoFromGalleryIntent();
}

private void launchPickVideoFromGalleryIntent() {
Intent pickImageIntent = new Intent(Intent.ACTION_GET_CONTENT);
pickImageIntent.setType("video/*");

activity.startActivityForResult(pickImageIntent, REQUEST_CODE_CHOOSE_FROM_GALLERY);
}

public void takeVideoWithCamera(MethodCall methodCall, MethodChannel.Result result) {
if (!setPendingMethodCallAndResult(methodCall, result)) {
finishWithAlreadyActiveError();
return;
}

if (!permissionManager.isPermissionGranted(Manifest.permission.CAMERA)) {
permissionManager.askForPermission(Manifest.permission.CAMERA, REQUEST_CAMERA_PERMISSION);
return;
}

launchTakeVideoWithCameraIntent();
}

private void launchTakeVideoWithCameraIntent() {
Intent intent = new Intent(MediaStore.ACTION_VIDEO_CAPTURE);
boolean canTakePhotos = intentResolver.resolveActivity(intent);

if (!canTakePhotos) {
finishWithError("no_available_camera", "No cameras available for taking pictures.");
return;
}

File imageFile = createTemporaryWritableImageFile();
pendingCameraImageUri = Uri.parse("file:" + imageFile.getAbsolutePath());

Uri imageUri = fileUriResolver.resolveFileProviderUriForFile(fileProviderName, imageFile);
intent.putExtra(MediaStore.EXTRA_OUTPUT, imageUri);
grantUriPermissions(intent, imageUri);

activity.startActivityForResult(intent, REQUEST_CODE_TAKE_WITH_CAMERA);
}

public void chooseImageFromGallery(MethodCall methodCall, MethodChannel.Result result) {
if (!setPendingMethodCallAndResult(methodCall, result)) {
finishWithAlreadyActiveError();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,10 +49,8 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
result.error("no_activity", "image_picker plugin requires a foreground activity.", null);
return;
}

if (call.method.equals("pickImage")) {
int imageSource = call.argument("source");

switch (imageSource) {
case SOURCE_GALLERY:
delegate.chooseImageFromGallery(call, result);
Expand All @@ -63,6 +61,18 @@ public void onMethodCall(MethodCall call, MethodChannel.Result result) {
default:
throw new IllegalArgumentException("Invalid image source: " + imageSource);
}
} else if (call.method.equals("pickVideo")) {
int imageSource = call.argument("source");
switch (imageSource) {
case SOURCE_GALLERY:
delegate.chooseVideoFromGallery(call, result);
break;
case SOURCE_CAMERA:
delegate.takeVideoWithCamera(call, result);
break;
default:
throw new IllegalArgumentException("Invalid video source: " + imageSource);
}
} else {
throw new IllegalArgumentException("Unknown method " + call.method);
}
Expand Down
29 changes: 19 additions & 10 deletions packages/image_picker/example/ios/Runner.xcodeproj/project.pbxproj
100755 → 100644
Original file line number Diff line number Diff line change
Expand Up @@ -7,11 +7,10 @@
objects = {

/* Begin PBXBuildFile section */
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
2D5378261FAA1A9400D5DBA9 /* flutter_assets in Resources */ = {isa = PBXBuildFile; fileRef = 2D5378251FAA1A9400D5DBA9 /* flutter_assets */; };
3B3967161E833CAA004F5970 /* AppFrameworkInfo.plist in Resources */ = {isa = PBXBuildFile; fileRef = 3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */; };
3B80C3941E831B6300D905FE /* App.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; };
3B80C3951E831B6300D905FE /* App.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 3B80C3931E831B6300D905FE /* App.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
3E15FEC43344A77097B00440 /* Pods_Runner.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 01A6711EF19E90303F1F55DC /* Pods_Runner.framework */; };
5C9513011EC38BD300040975 /* GeneratedPluginRegistrant.m in Sources */ = {isa = PBXBuildFile; fileRef = 5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */; };
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; };
9705A1C71CF904A300538489 /* Flutter.framework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = 9740EEBA1CF902C7004384FC /* Flutter.framework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
Expand All @@ -22,6 +21,7 @@
97C146FC1CF9000F007C117D /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FA1CF9000F007C117D /* Main.storyboard */; };
97C146FE1CF9000F007C117D /* Assets.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FD1CF9000F007C117D /* Assets.xcassets */; };
97C147011CF9000F007C117D /* LaunchScreen.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 97C146FF1CF9000F007C117D /* LaunchScreen.storyboard */; };
F4F7A436CCA4BF276270A3AE /* libPods-Runner.a in Frameworks */ = {isa = PBXBuildFile; fileRef = EC32F6993F4529982D9519F1 /* libPods-Runner.a */; };
/* End PBXBuildFile section */

/* Begin PBXCopyFilesBuildPhase section */
Expand All @@ -40,9 +40,8 @@
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
01A6711EF19E90303F1F55DC /* Pods_Runner.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Runner.framework; sourceTree = BUILT_PRODUCTS_DIR; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
2D5378251FAA1A9400D5DBA9 /* flutter_assets */ = {isa = PBXFileReference; lastKnownFileType = folder; name = flutter_assets; path = Flutter/flutter_assets; sourceTree = SOURCE_ROOT; };
3B3967151E833CAA004F5970 /* AppFrameworkInfo.plist */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.plist.xml; name = AppFrameworkInfo.plist; path = Flutter/AppFrameworkInfo.plist; sourceTree = "<group>"; };
3B80C3931E831B6300D905FE /* App.framework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.framework; name = App.framework; path = Flutter/App.framework; sourceTree = "<group>"; };
5C9512FF1EC38BD300040975 /* GeneratedPluginRegistrant.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GeneratedPluginRegistrant.h; sourceTree = "<group>"; };
5C9513001EC38BD300040975 /* GeneratedPluginRegistrant.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GeneratedPluginRegistrant.m; sourceTree = "<group>"; };
Expand All @@ -58,6 +57,7 @@
97C146FD1CF9000F007C117D /* Assets.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; path = Assets.xcassets; sourceTree = "<group>"; };
97C147001CF9000F007C117D /* Base */ = {isa = PBXFileReference; lastKnownFileType = file.storyboard; name = Base; path = Base.lproj/LaunchScreen.storyboard; sourceTree = "<group>"; };
97C147021CF9000F007C117D /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
EC32F6993F4529982D9519F1 /* libPods-Runner.a */ = {isa = PBXFileReference; explicitFileType = archive.ar; includeInIndex = 0; path = "libPods-Runner.a"; sourceTree = BUILT_PRODUCTS_DIR; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
Expand All @@ -67,7 +67,7 @@
files = (
9705A1C61CF904A100538489 /* Flutter.framework in Frameworks */,
3B80C3941E831B6300D905FE /* App.framework in Frameworks */,
3E15FEC43344A77097B00440 /* Pods_Runner.framework in Frameworks */,
F4F7A436CCA4BF276270A3AE /* libPods-Runner.a in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -141,7 +141,7 @@
CF3B75C9A7D2FA2A4C99F110 /* Frameworks */ = {
isa = PBXGroup;
children = (
01A6711EF19E90303F1F55DC /* Pods_Runner.framework */,
EC32F6993F4529982D9519F1 /* libPods-Runner.a */,
);
name = Frameworks;
sourceTree = "<group>";
Expand Down Expand Up @@ -183,7 +183,12 @@
TargetAttributes = {
97C146ED1CF9000F007C117D = {
CreatedOnToolsVersion = 7.3.1;
DevelopmentTeam = 3GRKCVVJ22;
DevelopmentTeam = 9FK3425VTA;
SystemCapabilities = {
com.apple.BackgroundModes = {
enabled = 1;
};
};
};
};
};
Expand Down Expand Up @@ -258,9 +263,12 @@
files = (
);
inputPaths = (
"${SRCROOT}/Pods/Target Support Files/Pods-Runner/Pods-Runner-frameworks.sh",
"${PODS_ROOT}/.symlinks/flutter/ios/Flutter.framework",
);
name = "[CP] Embed Pods Frameworks";
outputPaths = (
"${TARGET_BUILD_DIR}/${FRAMEWORKS_FOLDER_PATH}/Flutter.framework",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
Expand All @@ -287,13 +295,16 @@
files = (
);
inputPaths = (
"${PODS_PODFILE_DIR_PATH}/Podfile.lock",
"${PODS_ROOT}/Manifest.lock",
);
name = "[CP] Check Pods Manifest.lock";
outputPaths = (
"$(DERIVED_FILE_DIR)/Pods-Runner-checkManifestLockResult.txt",
);
runOnlyForDeploymentPostprocessing = 0;
shellPath = /bin/sh;
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n";
shellScript = "diff \"${PODS_PODFILE_DIR_PATH}/Podfile.lock\" \"${PODS_ROOT}/Manifest.lock\" > /dev/null\nif [ $? != 0 ] ; then\n # print error to STDERR\n echo \"error: The sandbox is not in sync with the Podfile.lock. Run 'pod install' or update your CocoaPods installation.\" >&2\n exit 1\nfi\n# This output is used by Xcode 'outputs' to avoid re-running this script phase.\necho \"SUCCESS\" > \"${SCRIPT_OUTPUT_FILE_0}\"\n";
showEnvVarsInLog = 0;
};
/* End PBXShellScriptBuildPhase section */
Expand Down Expand Up @@ -427,7 +438,6 @@
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 3GRKCVVJ22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand All @@ -450,7 +460,6 @@
buildSettings = {
ARCHS = arm64;
ASSETCATALOG_COMPILER_APPICON_NAME = AppIcon;
DEVELOPMENT_TEAM = 3GRKCVVJ22;
ENABLE_BITCODE = NO;
FRAMEWORK_SEARCH_PATHS = (
"$(inherited)",
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,8 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>IDEDidComputeMac32BitWarning</key>
<true/>
</dict>
</plist>
14 changes: 10 additions & 4 deletions packages/image_picker/example/ios/Runner/Info.plist
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,16 @@
<string>1</string>
<key>LSRequiresIPhoneOS</key>
<true/>
<key>NSCameraUsageDescription</key>
<string>Used to demonstrate image picker plugin</string>
<key>NSMicrophoneUsageDescription</key>
<string>Used to capture audio for image picker plugin</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Used to demonstrate image picker plugin</string>
<key>UIBackgroundModes</key>
<array>
<string>remote-notification</string>
</array>
<key>UILaunchStoryboardName</key>
<string>LaunchScreen</string>
<key>UIMainStoryboardFile</key>
Expand All @@ -43,10 +53,6 @@
<string>UIInterfaceOrientationLandscapeLeft</string>
<string>UIInterfaceOrientationLandscapeRight</string>
</array>
<key>NSCameraUsageDescription</key>
<string>Used to demonstrate image picker plugin</string>
<key>NSPhotoLibraryUsageDescription</key>
<string>Used to demonstrate image picker plugin</string>
<key>UIViewControllerBasedStatusBarAppearance</key>
<false/>
</dict>
Expand Down
Loading