diff options
| -rw-r--r-- | main/res/values/changelog_release.xml | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/ImageSelectActivity.java | 84 |
2 files changed, 50 insertions, 40 deletions
diff --git a/main/res/values/changelog_release.xml b/main/res/values/changelog_release.xml index 599adc5..bf751ac 100644 --- a/main/res/values/changelog_release.xml +++ b/main/res/values/changelog_release.xml @@ -2,6 +2,12 @@ <resources> <!-- changelog for the release branch --> <string name="changelog_release" translatable="false">\n + <b>Next bugfix release</b>\n + <b>Bugfixes:</b>\n + · Twitter problem fixed\n + · Some phones wouldn\'t let c:geo add new pictures to logs\n + · ... + \n <b>2014.01.22</b>\n <b>Bugfixes:</b>\n · Select log photo from alternate sources on Android 4.4\n diff --git a/main/src/cgeo/geocaching/ImageSelectActivity.java b/main/src/cgeo/geocaching/ImageSelectActivity.java index d6d32ec..766149c 100644 --- a/main/src/cgeo/geocaching/ImageSelectActivity.java +++ b/main/src/cgeo/geocaching/ImageSelectActivity.java @@ -227,51 +227,55 @@ public class ImageSelectActivity extends AbstractActivity { return; } - final Uri selectedImage = data.getData(); - if (Build.VERSION.SDK_INT < VERSION_CODES.KITKAT) { - String[] filePathColumn = { MediaColumns.DATA }; - - Cursor cursor = null; - try { - cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); - if (cursor == null) { + // null is an acceptable result if the image has been placed in the imageUri file by the + // camera application. + if (data != null) { + final Uri selectedImage = data.getData(); + if (Build.VERSION.SDK_INT < VERSION_CODES.KITKAT) { + String[] filePathColumn = { MediaColumns.DATA }; + + Cursor cursor = null; + try { + cursor = getContentResolver().query(selectedImage, filePathColumn, null, null, null); + if (cursor == null) { + showFailure(); + return; + } + cursor.moveToFirst(); + + int columnIndex = cursor.getColumnIndex(filePathColumn[0]); + String filePath = cursor.getString(columnIndex); + if (StringUtils.isBlank(filePath)) { + showFailure(); + return; + } + imageUri = Uri.parse(filePath); + } catch (Exception e) { + Log.e("ImageSelectActivity.onActivityResult", e); showFailure(); - return; + } finally { + if (cursor != null) { + cursor.close(); + } } - cursor.moveToFirst(); - int columnIndex = cursor.getColumnIndex(filePathColumn[0]); - String filePath = cursor.getString(columnIndex); - if (StringUtils.isBlank(filePath)) { - showFailure(); - return; - } - imageUri = Uri.parse(filePath); - } catch (Exception e) { - Log.e("ImageSelectActivity.onActivityResult", e); - showFailure(); - } finally { - if (cursor != null) { - cursor.close(); + Log.d("SELECT IMAGE data = " + data.toString()); + } else { + InputStream input = null; + OutputStream output = null; + try { + input = getContentResolver().openInputStream(selectedImage); + final File outputFile = ImageUtils.getOutputImageFile(); + output = new FileOutputStream(outputFile); + LocalStorage.copy(input, output); + imageUri = Uri.fromFile(outputFile); + } catch (FileNotFoundException e) { + Log.e("ImageSelectActivity.onStartResult", e); + } finally { + IOUtils.closeQuietly(input); + IOUtils.closeQuietly(output); } } - - Log.d("SELECT IMAGE data = " + data.toString()); - } else { - InputStream input = null; - OutputStream output = null; - try { - input = getContentResolver().openInputStream(selectedImage); - final File outputFile = ImageUtils.getOutputImageFile(); - output = new FileOutputStream(outputFile); - LocalStorage.copy(input, output); - imageUri = Uri.fromFile(outputFile); - } catch (FileNotFoundException e) { - Log.e("ImageSelectActivity.onStartResult", e); - } finally { - IOUtils.closeQuietly(input); - IOUtils.closeQuietly(output); - } } if (requestCode == SELECT_NEW_IMAGE) { |
