refactor SftpFileStorage creation
This commit is contained in:
@@ -25,7 +25,7 @@ namespace keepass2android.Io
|
|||||||
public abstract bool UserShouldBackup { get; }
|
public abstract bool UserShouldBackup { get; }
|
||||||
|
|
||||||
|
|
||||||
private readonly IJavaFileStorage _jfs;
|
protected readonly IJavaFileStorage _jfs;
|
||||||
private readonly IKp2aApp _app;
|
private readonly IKp2aApp _app;
|
||||||
|
|
||||||
public JavaFileStorage(IJavaFileStorage jfs, IKp2aApp app)
|
public JavaFileStorage(IJavaFileStorage jfs, IKp2aApp app)
|
||||||
|
|||||||
@@ -1,17 +1,39 @@
|
|||||||
using Android.Content;
|
using Android.Content;
|
||||||
|
using Java.Nio.FileNio;
|
||||||
#if !EXCLUDE_JAVAFILESTORAGE
|
#if !EXCLUDE_JAVAFILESTORAGE
|
||||||
|
|
||||||
namespace keepass2android.Io
|
namespace keepass2android.Io
|
||||||
{
|
{
|
||||||
public class SftpFileStorage: JavaFileStorage
|
public class SftpFileStorage: JavaFileStorage
|
||||||
{
|
{
|
||||||
public SftpFileStorage(Context ctx, IKp2aApp app) :
|
public SftpFileStorage(Context ctx, IKp2aApp app, bool debugEnabled) :
|
||||||
base(new Keepass2android.Javafilestorage.SftpStorage(ctx.ApplicationContext), app)
|
base(new Keepass2android.Javafilestorage.SftpStorage(ctx.ApplicationContext), app)
|
||||||
{
|
{
|
||||||
}
|
var storage = BaseStorage;
|
||||||
|
if (debugEnabled)
|
||||||
|
{
|
||||||
|
string? logFilename = null;
|
||||||
|
if (Kp2aLog.LogToFile)
|
||||||
|
{
|
||||||
|
logFilename = Kp2aLog.LogFilename;
|
||||||
|
}
|
||||||
|
storage.SetJschLogging(true, logFilename);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
storage.SetJschLogging(false, null);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private Keepass2android.Javafilestorage.SftpStorage BaseStorage
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
return _jfs as Keepass2android.Javafilestorage.SftpStorage;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public override bool UserShouldBackup
|
public override bool UserShouldBackup
|
||||||
{
|
{
|
||||||
get { return true; }
|
get { return true; }
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -832,7 +832,7 @@ namespace keepass2android
|
|||||||
new OneDrive2FullFileStorage(),
|
new OneDrive2FullFileStorage(),
|
||||||
new OneDrive2MyFilesFileStorage(),
|
new OneDrive2MyFilesFileStorage(),
|
||||||
new OneDrive2AppFolderFileStorage(),
|
new OneDrive2AppFolderFileStorage(),
|
||||||
CreateSftpFileStorage(),
|
new SftpFileStorage(LocaleManager.LocalizedAppContext, this, IsFtpDebugEnabled()),
|
||||||
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this, IsFtpDebugEnabled),
|
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this, IsFtpDebugEnabled),
|
||||||
new WebDavFileStorage(this),
|
new WebDavFileStorage(this),
|
||||||
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
|
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
|
||||||
@@ -854,33 +854,8 @@ namespace keepass2android
|
|||||||
return PreferenceManager.GetDefaultSharedPreferences(LocaleManager.LocalizedAppContext)
|
return PreferenceManager.GetDefaultSharedPreferences(LocaleManager.LocalizedAppContext)
|
||||||
.GetBoolean(LocaleManager.LocalizedAppContext.GetString(Resource.String.FtpDebug_key), false);
|
.GetBoolean(LocaleManager.LocalizedAppContext.GetString(Resource.String.FtpDebug_key), false);
|
||||||
}
|
}
|
||||||
#if !EXCLUDE_JAVAFILESTORAGE
|
|
||||||
#if !NoNet
|
|
||||||
private IFileStorage CreateSftpFileStorage()
|
|
||||||
{
|
|
||||||
Context ctx = LocaleManager.LocalizedAppContext;
|
|
||||||
SftpFileStorage fileStorage = new SftpFileStorage(ctx, this);
|
|
||||||
|
|
||||||
var storage = new SftpStorage(ctx);
|
public void TriggerReload(Context ctx, Action<bool> actionOnResult)
|
||||||
if (IsFtpDebugEnabled())
|
|
||||||
{
|
|
||||||
string? logFilename = null;
|
|
||||||
if (Kp2aLog.LogToFile)
|
|
||||||
{
|
|
||||||
logFilename = Kp2aLog.LogFilename;
|
|
||||||
}
|
|
||||||
storage.SetJschLogging(true, logFilename);
|
|
||||||
} else
|
|
||||||
{
|
|
||||||
storage.SetJschLogging(false, null);
|
|
||||||
}
|
|
||||||
|
|
||||||
return fileStorage;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
#endif
|
|
||||||
|
|
||||||
public void TriggerReload(Context ctx, Action<bool> actionOnResult)
|
|
||||||
{
|
{
|
||||||
Handler handler = new Handler(Looper.MainLooper);
|
Handler handler = new Handler(Looper.MainLooper);
|
||||||
handler.Post(() =>
|
handler.Post(() =>
|
||||||
|
|||||||
Reference in New Issue
Block a user