fix captured media filename having multiple suffixes
This commit is contained in:
parent
4f316d5b54
commit
14e3e8c40c
|
@ -1106,31 +1106,29 @@ public class InAppWebViewChromeClient extends WebChromeClient implements PluginR
|
||||||
String prefix = "";
|
String prefix = "";
|
||||||
String suffix = "";
|
String suffix = "";
|
||||||
String dir = "";
|
String dir = "";
|
||||||
String filename = "";
|
|
||||||
|
|
||||||
if (intentType.equals(MediaStore.ACTION_IMAGE_CAPTURE)) {
|
if (intentType.equals(MediaStore.ACTION_IMAGE_CAPTURE)) {
|
||||||
prefix = "image-";
|
prefix = "image";
|
||||||
suffix = ".jpg";
|
suffix = ".jpg";
|
||||||
dir = Environment.DIRECTORY_PICTURES;
|
dir = Environment.DIRECTORY_PICTURES;
|
||||||
} else if (intentType.equals(MediaStore.ACTION_VIDEO_CAPTURE)) {
|
} else if (intentType.equals(MediaStore.ACTION_VIDEO_CAPTURE)) {
|
||||||
prefix = "video-";
|
prefix = "video";
|
||||||
suffix = ".mp4";
|
suffix = ".mp4";
|
||||||
dir = Environment.DIRECTORY_MOVIES;
|
dir = Environment.DIRECTORY_MOVIES;
|
||||||
}
|
}
|
||||||
|
|
||||||
filename = prefix + String.valueOf(System.currentTimeMillis()) + suffix;
|
|
||||||
|
|
||||||
// for versions below 6.0 (23) we use the old File creation & permissions model
|
// for versions below 6.0 (23) we use the old File creation & permissions model
|
||||||
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
if (Build.VERSION.SDK_INT < Build.VERSION_CODES.M) {
|
||||||
// only this Directory works on all tested Android versions
|
// only this Directory works on all tested Android versions
|
||||||
// ctx.getExternalFilesDir(dir) was failing on Android 5.0 (sdk 21)
|
// ctx.getExternalFilesDir(dir) was failing on Android 5.0 (sdk 21)
|
||||||
File storageDir = Environment.getExternalStoragePublicDirectory(dir);
|
File storageDir = Environment.getExternalStoragePublicDirectory(dir);
|
||||||
|
String filename = String.format("%s-%d%s", prefix, System.currentTimeMillis(), suffix);
|
||||||
return new File(storageDir, filename);
|
return new File(storageDir, filename);
|
||||||
}
|
}
|
||||||
|
|
||||||
Activity activity = inAppBrowserActivity != null ? inAppBrowserActivity : Shared.activity;
|
Activity activity = inAppBrowserActivity != null ? inAppBrowserActivity : Shared.activity;
|
||||||
File storageDir = activity.getApplicationContext().getExternalFilesDir(null);
|
File storageDir = activity.getApplicationContext().getExternalFilesDir(null);
|
||||||
return File.createTempFile(filename, suffix, storageDir);
|
return File.createTempFile(prefix, suffix, storageDir);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Boolean isArrayEmpty(String[] arr) {
|
private Boolean isArrayEmpty(String[] arr) {
|
||||||
|
|
Loading…
Reference in New Issue