This repository has been archived by the owner on Feb 22, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 9.8k
Image picker plugin: use the native Android gallery / file chooser #423
Merged
goderbauer
merged 21 commits into
flutter:master
from
roughike:feature/use-native-android-image-picker
Mar 29, 2018
Merged
Changes from 19 commits
Commits
Show all changes
21 commits
Select commit
Hold shift + click to select a range
47703d9
Added the plugins.flutter.io prefix for the method channel.
58ae393
Extracted the image resizing and EXIF data copying logic to separate …
95f3645
Refactored the gallery image source on Android to use the native imag…
3e17792
Modified the Dart side API, documentation, tests and example to omit …
8d1dd47
Removed the image source selector popup from iOS side.
bb61b10
Removed debug/unused code and fixed the logic for getting the name fo…
7ed845f
Fixed formatting.
acb52d0
Merge latest changes from master.
8657b5c
Another try of fixing merge conflicts.
a152e85
formatting.
a04580a
Modified the LICENSE and Java file headers to include appropriate att…
9e13ff9
Modified documentation of pickImage method to reflect the required so…
427155c
Added a TODO comment about refactoring the plugin to use the native c…
fac00ce
formatting.
2e50c59
Bumped version number and updated changelog.
d06d043
Merge branch 'master' into feature/use-native-android-image-picker
roughike 648523c
Updated README to reflect the breaking change in the API.
f196278
Made the example in the README to use a named argument since that's t…
6ef4f2f
Copied the unchanged licenses to the FileUtils header and LICENSE file.
f433569
Added a message stating where the FileUtils.java comes from.
b4c8b1d
Merge branch 'master' of github.com:flutter/plugins into feature/use-…
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
55 changes: 55 additions & 0 deletions
55
...ges/image_picker/android/src/main/java/io/flutter/plugins/imagepicker/ExifDataCopier.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
// Copyright 2017 The Chromium Authors. All rights reserved. | ||
// Use of this source code is governed by a BSD-style license that can be | ||
// found in the LICENSE file. | ||
|
||
package io.flutter.plugins.imagepicker; | ||
|
||
import android.media.ExifInterface; | ||
import android.util.Log; | ||
import java.util.Arrays; | ||
import java.util.List; | ||
|
||
class ExifDataCopier { | ||
void copyExif(String filePathOri, String filePathDest) { | ||
try { | ||
ExifInterface oldExif = new ExifInterface(filePathOri); | ||
ExifInterface newExif = new ExifInterface(filePathDest); | ||
|
||
List<String> attributes = | ||
Arrays.asList( | ||
"FNumber", | ||
"ExposureTime", | ||
"ISOSpeedRatings", | ||
"GPSAltitude", | ||
"GPSAltitudeRef", | ||
"FocalLength", | ||
"GPSDateStamp", | ||
"WhiteBalance", | ||
"GPSProcessingMethod", | ||
"GPSTimeStamp", | ||
"DateTime", | ||
"Flash", | ||
"GPSLatitude", | ||
"GPSLatitudeRef", | ||
"GPSLongitude", | ||
"GPSLongitudeRef", | ||
"Make", | ||
"Model", | ||
"Orientation"); | ||
for (String attribute : attributes) { | ||
setIfNotNull(oldExif, newExif, attribute); | ||
} | ||
|
||
newExif.saveAttributes(); | ||
|
||
} catch (Exception ex) { | ||
Log.e("ExifDataCopier", "Error preserving Exif data on selected image: " + ex); | ||
} | ||
} | ||
|
||
private static void setIfNotNull(ExifInterface oldExif, ExifInterface newExif, String property) { | ||
if (oldExif.getAttribute(property) != null) { | ||
newExif.setAttribute(property, oldExif.getAttribute(property)); | ||
} | ||
} | ||
} |
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This file needs a license header (see existing source files).