mirror of
https://github.com/moparisthebest/keepass2android
synced 2024-11-11 20:15:04 -05:00
import keyfile and database to NoBackup-Internal files folder instead of standard app files directory
This commit is contained in:
parent
9c45bcb090
commit
3a64e4aa2e
@ -252,7 +252,8 @@ namespace keepass2android.Io
|
|||||||
//check if we need to request the external-storage-permission at runtime
|
//check if we need to request the external-storage-permission at runtime
|
||||||
if (ioc.IsLocalFile())
|
if (ioc.IsLocalFile())
|
||||||
{
|
{
|
||||||
bool requiresPermission = !ioc.Path.StartsWith(activity.Activity.FilesDir.CanonicalPath);
|
bool requiresPermission = !(ioc.Path.StartsWith(activity.Activity.FilesDir.CanonicalPath)
|
||||||
|
|| ioc.Path.StartsWith(activity.Activity.NoBackupFilesDir.CanonicalPath));
|
||||||
|
|
||||||
var extDirectory = activity.Activity.GetExternalFilesDir(null);
|
var extDirectory = activity.Activity.GetExternalFilesDir(null);
|
||||||
if ((extDirectory != null) && (ioc.Path.StartsWith(extDirectory.CanonicalPath)))
|
if ((extDirectory != null) && (ioc.Path.StartsWith(extDirectory.CanonicalPath)))
|
||||||
|
@ -53,13 +53,14 @@ namespace keepass2android.Io
|
|||||||
try
|
try
|
||||||
{
|
{
|
||||||
File filesDir = context.FilesDir.CanonicalFile;
|
File filesDir = context.FilesDir.CanonicalFile;
|
||||||
|
File noBackupDir = context.NoBackupFilesDir.CanonicalFile;
|
||||||
File ourFile = new File(path).CanonicalFile;
|
File ourFile = new File(path).CanonicalFile;
|
||||||
//http://www.java2s.com/Tutorial/Java/0180__File/Checkswhetherthechilddirectoryisasubdirectoryofthebasedirectory.htm
|
//http://www.java2s.com/Tutorial/Java/0180__File/Checkswhetherthechilddirectoryisasubdirectoryofthebasedirectory.htm
|
||||||
|
|
||||||
File parentFile = ourFile;
|
File parentFile = ourFile;
|
||||||
while (parentFile != null)
|
while (parentFile != null)
|
||||||
{
|
{
|
||||||
if (filesDir.Equals(parentFile))
|
if ((filesDir.Equals(parentFile) || noBackupDir.Equals(parentFile)))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -764,7 +764,7 @@ namespace keepass2android
|
|||||||
targetPath = targetPath.Trim("|\\?*<\":>+[]/'".ToCharArray());
|
targetPath = targetPath.Trim("|\\?*<\":>+[]/'".ToCharArray());
|
||||||
if (targetPath == "")
|
if (targetPath == "")
|
||||||
targetPath = "imported";
|
targetPath = "imported";
|
||||||
if (new File(Activity.FilesDir, targetPath).Exists())
|
if (new File(Activity.NoBackupFilesDir, targetPath).Exists())
|
||||||
{
|
{
|
||||||
int c = 1;
|
int c = 1;
|
||||||
var ext = UrlUtil.GetExtension(targetPath);
|
var ext = UrlUtil.GetExtension(targetPath);
|
||||||
@ -775,9 +775,9 @@ namespace keepass2android
|
|||||||
targetPath = filenameWithoutExt + c;
|
targetPath = filenameWithoutExt + c;
|
||||||
if (!String.IsNullOrEmpty(ext))
|
if (!String.IsNullOrEmpty(ext))
|
||||||
targetPath += "." + ext;
|
targetPath += "." + ext;
|
||||||
} while (new File(Activity.FilesDir, targetPath).Exists());
|
} while (new File(Activity.NoBackupFilesDir, targetPath).Exists());
|
||||||
}
|
}
|
||||||
var targetIoc = IOConnectionInfo.FromPath(new File(Activity.FilesDir, targetPath).CanonicalPath);
|
var targetIoc = IOConnectionInfo.FromPath(new File(Activity.NoBackupFilesDir, targetPath).CanonicalPath);
|
||||||
|
|
||||||
IoUtil.Copy(targetIoc, sourceIoc, App.Kp2a);
|
IoUtil.Copy(targetIoc, sourceIoc, App.Kp2a);
|
||||||
return targetIoc;
|
return targetIoc;
|
||||||
|
Loading…
Reference in New Issue
Block a user