refactoring, use less UrlUtil and more IFileStorage
This commit is contained in:
@@ -82,7 +82,12 @@ namespace keepass2android.Io
|
||||
UrlUtil.GetFileName(ioc.Path));
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return UrlUtil.GetExtension(ioc.Path);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -201,7 +201,12 @@ namespace keepass2android.Io
|
||||
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return UrlUtil.GetExtension(ioc.Path);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
return (!ioc.IsLocalFile()) && (ioc.CredSaveMode != IOCredSaveMode.SaveCred);
|
||||
}
|
||||
|
||||
@@ -448,7 +448,12 @@ namespace keepass2android.Io
|
||||
return _cachedStorage.GetFilenameWithoutPathAndExt(ioc);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return _cachedStorage.GetFileExtension(ioc);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
return _cachedStorage.RequiresCredentials(ioc);
|
||||
}
|
||||
|
||||
@@ -88,11 +88,13 @@ namespace keepass2android.Io
|
||||
IWriteTransaction OpenWriteTransaction(IOConnectionInfo ioc, bool useFileTransaction);
|
||||
|
||||
string GetFilenameWithoutPathAndExt(IOConnectionInfo ioc);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the the given ioc must be filled with username/password
|
||||
/// </summary>
|
||||
bool RequiresCredentials(IOConnectionInfo ioc);
|
||||
|
||||
string GetFileExtension(IOConnectionInfo ioc);
|
||||
|
||||
/// <summary>
|
||||
/// Returns true if the the given ioc must be filled with username/password
|
||||
/// </summary>
|
||||
bool RequiresCredentials(IOConnectionInfo ioc);
|
||||
|
||||
/// <summary>
|
||||
/// Creates the directory described by ioc
|
||||
|
||||
@@ -128,10 +128,12 @@ namespace keepass2android.Io
|
||||
}
|
||||
|
||||
//creates a local ioc where the sourceIoc can be stored to
|
||||
public static IOConnectionInfo GetInternalIoc(IOConnectionInfo sourceIoc, Context ctx)
|
||||
public static IOConnectionInfo GetInternalIoc(IOConnectionInfo sourceIoc, Context ctx, IKp2aApp app)
|
||||
{
|
||||
Java.IO.File internalDirectory = IoUtil.GetInternalDirectory(ctx);
|
||||
string targetPath = UrlUtil.GetFileName(sourceIoc.Path);
|
||||
var filestorage = app.GetFileStorage(sourceIoc);
|
||||
|
||||
string targetPath = filestorage.GetFilenameWithoutPathAndExt(sourceIoc);
|
||||
targetPath = targetPath.Trim("|\\?*<\":>+[]/'".ToCharArray());
|
||||
if (targetPath == "")
|
||||
targetPath = "internal";
|
||||
@@ -153,7 +155,7 @@ namespace keepass2android.Io
|
||||
|
||||
public static IOConnectionInfo ImportFileToInternalDirectory(IOConnectionInfo sourceIoc, Context ctx, IKp2aApp app)
|
||||
{
|
||||
var targetIoc = GetInternalIoc(sourceIoc, ctx);
|
||||
var targetIoc = GetInternalIoc(sourceIoc, ctx, app);
|
||||
|
||||
|
||||
IoUtil.Copy(targetIoc, sourceIoc, app);
|
||||
|
||||
@@ -177,7 +177,12 @@ namespace keepass2android.Io
|
||||
_jfs.GetFilename(IocToPath(ioc)));
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return UrlUtil.GetExtension(ioc.Path);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -314,7 +314,12 @@ namespace keepass2android.Io
|
||||
UrlUtil.GetFileName(ioc.Path));
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return UrlUtil.GetExtension(ioc.Path);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -78,7 +78,12 @@ namespace keepass2android.Io
|
||||
return _baseStorage.GetFilenameWithoutPathAndExt(ioc);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return _baseStorage.GetFileExtension(ioc);
|
||||
}
|
||||
|
||||
public bool RequiresCredentials(IOConnectionInfo ioc)
|
||||
{
|
||||
return _baseStorage.RequiresCredentials(ioc);
|
||||
}
|
||||
|
||||
@@ -491,6 +491,11 @@ namespace keepass2android.Io
|
||||
GetFilename(IocToPath(ioc)));
|
||||
}
|
||||
|
||||
public string GetFileExtension(IOConnectionInfo ioc)
|
||||
{
|
||||
return UrlUtil.GetExtension(OneDrive2ItemLocation.FromString(ioc.Path).LocalPathString);
|
||||
}
|
||||
|
||||
private string GetFilename(string path)
|
||||
{
|
||||
string localPath = "/"+OneDrive2ItemLocation.FromString(path).LocalPath;
|
||||
|
||||
Reference in New Issue
Block a user