diff --git a/src/Android/Constants.cs b/src/Android/Constants.cs
index 398bfb708..b6fe75d1e 100644
--- a/src/Android/Constants.cs
+++ b/src/Android/Constants.cs
@@ -3,5 +3,11 @@
public static class Constants
{
public const string PACKAGE_NAME = "com.x8bit.bitwarden";
+ public const string TEMP_CAMERA_IMAGE_NAME = "temp_camera_image.jpg";
+
+ ///
+ /// This directory must also be declared in filepaths.xml
+ ///
+ public const string TEMP_CAMERA_IMAGE_DIR = "camera_temp";
}
}
diff --git a/src/Android/MainActivity.cs b/src/Android/MainActivity.cs
index 6792f3567..90d2ed45a 100644
--- a/src/Android/MainActivity.cs
+++ b/src/Android/MainActivity.cs
@@ -239,18 +239,22 @@ namespace Bit.Droid
string fileName = null;
if (data != null && data.Data != null)
{
- uri = data.Data;
- fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
+ if (data.Data.ToString()?.Contains(Constants.PACKAGE_NAME) != true)
+ {
+ uri = data.Data;
+ fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
+ }
}
else
{
// camera
- var file = new Java.IO.File(FilesDir, "temp_camera_photo.jpg");
+ var tmpDir = new Java.IO.File(FilesDir, Constants.TEMP_CAMERA_IMAGE_DIR);
+ var file = new Java.IO.File(tmpDir, Constants.TEMP_CAMERA_IMAGE_NAME);
uri = FileProvider.GetUriForFile(this, "com.x8bit.bitwarden.fileprovider", file);
fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
}
- if (uri == null)
+ if (uri == null || fileName == null)
{
return;
}
diff --git a/src/Android/Resources/xml/filepaths.xml b/src/Android/Resources/xml/filepaths.xml
index be754fbbb..d8e6022f2 100644
--- a/src/Android/Resources/xml/filepaths.xml
+++ b/src/Android/Resources/xml/filepaths.xml
@@ -1,5 +1,5 @@
-
+
diff --git a/src/Android/Services/FileService.cs b/src/Android/Services/FileService.cs
index c217f7a51..621e7ca44 100644
--- a/src/Android/Services/FileService.cs
+++ b/src/Android/Services/FileService.cs
@@ -190,7 +190,8 @@ namespace Bit.Droid.Services
{
try
{
- var file = new Java.IO.File(activity.FilesDir, "temp_camera_photo.jpg");
+ var tmpDir = new Java.IO.File(activity.FilesDir, Constants.TEMP_CAMERA_IMAGE_DIR);
+ var file = new Java.IO.File(tmpDir, Constants.TEMP_CAMERA_IMAGE_NAME);
if (!file.Exists())
{
file.ParentFile.Mkdirs();