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
|
||||
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);
|
||||
if ((extDirectory != null) && (ioc.Path.StartsWith(extDirectory.CanonicalPath)))
|
||||
|
@ -53,13 +53,14 @@ namespace keepass2android.Io
|
||||
try
|
||||
{
|
||||
File filesDir = context.FilesDir.CanonicalFile;
|
||||
File noBackupDir = context.NoBackupFilesDir.CanonicalFile;
|
||||
File ourFile = new File(path).CanonicalFile;
|
||||
//http://www.java2s.com/Tutorial/Java/0180__File/Checkswhetherthechilddirectoryisasubdirectoryofthebasedirectory.htm
|
||||
|
||||
File parentFile = ourFile;
|
||||
while (parentFile != null)
|
||||
{
|
||||
if (filesDir.Equals(parentFile))
|
||||
if ((filesDir.Equals(parentFile) || noBackupDir.Equals(parentFile)))
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
@ -764,7 +764,7 @@ namespace keepass2android
|
||||
targetPath = targetPath.Trim("|\\?*<\":>+[]/'".ToCharArray());
|
||||
if (targetPath == "")
|
||||
targetPath = "imported";
|
||||
if (new File(Activity.FilesDir, targetPath).Exists())
|
||||
if (new File(Activity.NoBackupFilesDir, targetPath).Exists())
|
||||
{
|
||||
int c = 1;
|
||||
var ext = UrlUtil.GetExtension(targetPath);
|
||||
@ -775,9 +775,9 @@ namespace keepass2android
|
||||
targetPath = filenameWithoutExt + c;
|
||||
if (!String.IsNullOrEmpty(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);
|
||||
return targetIoc;
|
||||
|
Loading…
Reference in New Issue
Block a user