mirror of
https://github.com/bitwarden/android.git
synced 2024-12-26 10:58:29 +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";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -238,19 +238,23 @@ namespace Bit.Droid
|
||||||
Android.Net.Uri uri = null;
|
Android.Net.Uri uri = null;
|
||||||
string fileName = null;
|
string fileName = null;
|
||||||
if (data != null && data.Data != null)
|
if (data != null && data.Data != null)
|
||||||
|
{
|
||||||
|
if (data.Data.ToString()?.Contains(Constants.PACKAGE_NAME) != true)
|
||||||
{
|
{
|
||||||
uri = data.Data;
|
uri = data.Data;
|
||||||
fileName = AndroidHelpers.GetFileName(ApplicationContext, uri);
|
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