diff --git a/app/build.gradle b/app/build.gradle index 7ed0188..1ba3e47 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -6,7 +6,7 @@ android { applicationId "de.k3b.android.lossless_jpg_crop" // SAF ACTION_CREATE_DOCUMENT requires api-19 and later - minSdkVersion 19 + minSdkVersion 19 // Android 4.4 KitKat (API 19); Android 5.0 Lollipop (API 21); Android 6.0 Marshmallow (API 23); Android 7.0 Nougat (API 24) targetSdkVersion 28 // 1.0.0.190425 (1) initial version @@ -14,7 +14,7 @@ android { // 1.0.2.190515 (3) Bugfix: rotation; illegal filename // 1.1.0.190518 (4) Implemented Workflow: GET_CONTENT/PICK/share/SEND/SENDTO to pick/re-send a cropped photo // 1.1.1.190522 (5) Errorhandling/display errormessage; delete temp files; action com.android.camera.action.CROP - + versionCode 5 versionName "1.1.1.190522" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" diff --git a/app/src/main/java/de/k3b/android/lossless_jpg_crop/CropAreasChooseBaseActivity.java b/app/src/main/java/de/k3b/android/lossless_jpg_crop/CropAreasChooseBaseActivity.java index 3d73a91..616dfaf 100644 --- a/app/src/main/java/de/k3b/android/lossless_jpg_crop/CropAreasChooseBaseActivity.java +++ b/app/src/main/java/de/k3b/android/lossless_jpg_crop/CropAreasChooseBaseActivity.java @@ -241,6 +241,7 @@ protected File getSharedDir() { protected String createCropFileName() { Uri inUri = getSourceImageUri(getIntent()); String originalFileName = (inUri == null) ? "" : inUri.getLastPathSegment(); + originalFileName = TempFileUtil.getLastPath(originalFileName); return replaceExtension(originalFileName, TempFileUtil.TEMP_FILE_SUFFIX); } diff --git a/app/src/main/java/de/k3b/util/TempFileUtil.java b/app/src/main/java/de/k3b/util/TempFileUtil.java index bc9bce1..60e1579 100644 --- a/app/src/main/java/de/k3b/util/TempFileUtil.java +++ b/app/src/main/java/de/k3b/util/TempFileUtil.java @@ -34,4 +34,14 @@ static boolean shouldDeleteTempFile(String fileName, long lastModifiedInMilliSec && fileName.endsWith(TEMP_FILE_SUFFIX); } + public static String getLastPath(String originalFileName) { + if (originalFileName != null) { + int splitPos = originalFileName.lastIndexOf(File.separatorChar); + if (splitPos == -1) splitPos = originalFileName.lastIndexOf('/'); + if (splitPos >= 0) originalFileName = originalFileName.substring(splitPos + 1); + } + return originalFileName; + } + + } diff --git a/app/src/test/java/de/k3b/util/TempFileUnitTest.java b/app/src/test/java/de/k3b/util/TempFileUnitTest.java index 2b972bb..b796d0c 100644 --- a/app/src/test/java/de/k3b/util/TempFileUnitTest.java +++ b/app/src/test/java/de/k3b/util/TempFileUnitTest.java @@ -14,6 +14,16 @@ public class TempFileUnitTest { private static final String FILE_NAME = "hello" + TempFileUtil.TEMP_FILE_SUFFIX; + // + @Test + public void shouldGetPath() { + final String expected = "190020_llcrop_llcrop.jpg"; + String in = "primary:DCIM/test/" + expected; + assertEquals(expected, TempFileUtil.getLastPath(in)); + assertEquals(expected, TempFileUtil.getLastPath(expected)); + assertEquals(null, TempFileUtil.getLastPath(null)); + } + @Test public void shouldDeleteOldTempFile() { long fileDate = getTime(13, 1); diff --git a/fastlane/metadata/android/en-US/changelogs/6.txt b/fastlane/metadata/android/en-US/changelogs/6.txt new file mode 100644 index 0000000..fb02126 --- /dev/null +++ b/fastlane/metadata/android/en-US/changelogs/6.txt @@ -0,0 +1 @@ +#2 #3: bugfix created illegal local file name for send/get_content