mirror of
https://github.com/bitwarden/android.git
synced 2024-12-25 18:38:27 +03:00
[PM-3741] [PM-3750] Improvements to local storage handling (#2795)
* [PM-3741] [PM-3750] Improvements to local storage handling * Update src/Android/MainActivity.cs Co-authored-by: Federico Maccaroni <fedemkr@gmail.com> --------- Co-authored-by: Federico Maccaroni <fedemkr@gmail.com>
This commit is contained in:
parent
5a0c2115a1
commit
bb2f1f0f5f
4 changed files with 17 additions and 6 deletions
|
@ -3,5 +3,11 @@
|
||||||
public static class Constants
|
public static class Constants
|
||||||
{
|
{
|
||||||
public const string PACKAGE_NAME = "com.x8bit.bitwarden";
|
public const string PACKAGE_NAME = "com.x8bit.bitwarden";
|
||||||
|
public const string TEMP_CAMERA_IMAGE_NAME = "temp_camera_image.jpg";
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// This directory must also be declared in filepaths.xml
|
||||||
|
/// </summary>
|
||||||
|
public const string TEMP_CAMERA_IMAGE_DIR = "camera_temp";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -239,18 +239,22 @@ namespace Bit.Droid
|
||||||
string fileName = null;
|
string fileName = null;
|
||||||
if (data != null && data.Data != null)
|
if (data != null && data.Data != null)
|
||||||
{
|
{
|
||||||
uri = data.Data;
|
if (data.Data.ToString()?.Contains(Constants.PACKAGE_NAME) != true)
|
||||||
fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
|
{
|
||||||
|
uri = data.Data;
|
||||||
|
fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
// camera
|
// 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);
|
uri = FileProvider.GetUriForFile(this, "com.x8bit.bitwarden.fileprovider", file);
|
||||||
fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
|
fileName = $"photo_{DateTime.UtcNow.ToString("yyyyMMddHHmmss")}.jpg";
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uri == null)
|
if (uri == null || fileName == null)
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
<?xml version="1.0" encoding="utf-8" ?>
|
<?xml version="1.0" encoding="utf-8" ?>
|
||||||
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
<paths xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
<cache-path name="cache" path="." />
|
<cache-path name="cache" path="." />
|
||||||
<files-path name="internal" path="." />
|
<files-path name="temp_camera_images" path="camera_temp/" />
|
||||||
</paths>
|
</paths>
|
||||||
|
|
|
@ -190,7 +190,8 @@ namespace Bit.Droid.Services
|
||||||
{
|
{
|
||||||
try
|
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())
|
if (!file.Exists())
|
||||||
{
|
{
|
||||||
file.ParentFile.Mkdirs();
|
file.ParentFile.Mkdirs();
|
||||||
|
|
Loading…
Reference in a new issue