Skip to content

Commit e9c66e5

Browse files
committed
Fixed bug with media picked from gallery
* store media picked from gallery locally in mage's external app directory, instead of device public
1 parent d50a4d8 commit e9c66e5

File tree

5 files changed

+17
-7
lines changed

5 files changed

+17
-7
lines changed

CHANGELOG.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,14 +3,21 @@ All notable changes to this project will be documented in this file.
33
Adheres to [Semantic Versioning](http://semver.org/).
44

55
---
6-
## 5.1.1 (TBD)
6+
## 5.1.2 (TBD)
77

88
* TBD
99

1010
##### Features
1111

1212
##### Bug Fixes
1313

14+
## [5.1.1](https://github.com/ngageoint/mage-android/releases/tag/5.1.1) (11-10-2016)
15+
16+
##### Features
17+
18+
##### Bug Fixes
19+
* Media picked from gallery stored in wrong location causing attachment failure in some cases.
20+
1421
## [5.1.0](https://github.com/ngageoint/mage-android/releases/tag/5.1.0) (08-11-2016)
1522

1623
##### Features

mage/build.gradle

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ dependencies {
8989
}
9090

9191
//compile project(':sdk') // uncomment me to build locally
92-
compile "mil.nga.giat.mage:sdk:5.1.0" // comment me to build locally
92+
compile "mil.nga.giat.mage:sdk:5.1.1" // comment me to build locally
9393
compile "mil.nga.geopackage:geopackage-android:1.3.0"
9494
compile 'com.android.support:multidex:1.0.1'
9595
compile 'com.android.support:support-v4:23.1.1'

mage/src/main/AndroidManifest.xml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
<?xml version="1.0" encoding="utf-8"?>
22
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
33
package="mil.nga.giat.mage"
4-
android:versionCode="20"
5-
android:versionName="5.1.0">
4+
android:versionCode="21"
5+
android:versionName="5.1.1">
66

77
<permission
88
android:name="mil.nga.giat.mage.permission.MAPS_RECEIVE"

mage/src/main/java/mil/nga/giat/mage/observation/ObservationEditActivity.java

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -627,7 +627,9 @@ private void launchVideoIntent() {
627627
private void launchGalleryIntent() {
628628
Intent intent = new Intent(Intent.ACTION_GET_CONTENT);
629629
intent.setType("image/*, video/*");
630-
Log.i(LOG_NAME, "build version sdk int: " + Build.VERSION.SDK_INT);
630+
intent.addCategory(Intent.CATEGORY_OPENABLE);
631+
intent.putExtra(Intent.EXTRA_MIME_TYPES, new String[] {"image/*", "video/*"});
632+
631633
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.JELLY_BEAN_MR2) {
632634
intent.putExtra(Intent.EXTRA_ALLOW_MULTIPLE, true);
633635
}
@@ -752,9 +754,10 @@ protected void onActivityResult(int requestCode, int resultCode, Intent data) {
752754
case GALLERY_ACTIVITY_REQUEST_CODE:
753755
case CAPTURE_VOICE_ACTIVITY_REQUEST_CODE:
754756
Collection<Uri> uris = getUris(data);
757+
755758
for (Uri uri : uris) {
756759
try {
757-
File file = MediaUtility.copyImageFromGallery(getContentResolver().openInputStream(uri));
760+
File file = MediaUtility.copyMediaFromUri(getApplicationContext(), uri);
758761
Attachment a = new Attachment();
759762
a.setLocalPath(file.getAbsolutePath());
760763
attachmentsToCreate.add(a);

mage/src/main/java/mil/nga/giat/mage/profile/ProfileFragment.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -473,7 +473,7 @@ public void onActivityResult(int requestCode, int resultCode, Intent data) {
473473
List<Uri> uris = getUris(data);
474474
for (Uri uri : uris) {
475475
try {
476-
File avatarFile = MediaUtility.copyImageFromGallery(getActivity().getContentResolver().openInputStream(uri));
476+
File avatarFile = MediaUtility.copyMediaFromUri(getActivity(),uri);
477477
filePath = avatarFile.getAbsolutePath();
478478
} catch (IOException e) {
479479
Log.e(LOG_NAME, "Error copying gallery file for avatar to local storage", e);

0 commit comments

Comments
 (0)