Merge branch '1.0.0e'
This commit is contained in:
@@ -254,7 +254,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(IoUtil.GetInternalDirectory(activity.Activity).CanonicalPath));
|
||||
|
||||
var extDirectory = activity.Activity.GetExternalFilesDir(null);
|
||||
if ((extDirectory != null) && (ioc.Path.StartsWith(extDirectory.CanonicalPath)))
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Text;
|
||||
using Android.Content;
|
||||
using Android.OS;
|
||||
using Java.IO;
|
||||
using KeePassLib.Serialization;
|
||||
|
||||
@@ -53,13 +54,14 @@ namespace keepass2android.Io
|
||||
try
|
||||
{
|
||||
File filesDir = context.FilesDir.CanonicalFile;
|
||||
File noBackupDir = GetInternalDirectory(context).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;
|
||||
}
|
||||
@@ -92,5 +94,13 @@ namespace keepass2android.Io
|
||||
writeTransaction.CommitWrite();
|
||||
}
|
||||
}
|
||||
|
||||
public static Java.IO.File GetInternalDirectory(Context ctx)
|
||||
{
|
||||
if ((int)Android.OS.Build.VERSION.SdkInt >= 21)
|
||||
return ctx.NoBackupFilesDir;
|
||||
else
|
||||
return ctx.FilesDir;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user