Merge pull request #2457 from hyproman/persist-ftp-debug-perf

Persist ftp debug preference
This commit is contained in:
PhilippC
2023-11-21 07:11:33 +01:00
committed by GitHub
4 changed files with 33 additions and 7 deletions

View File

@@ -25,7 +25,7 @@ namespace keepass2android.Io
public abstract bool UserShouldBackup { get; }
private readonly IJavaFileStorage _jfs;
protected readonly IJavaFileStorage _jfs;
private readonly IKp2aApp _app;
public JavaFileStorage(IJavaFileStorage jfs, IKp2aApp app)

View File

@@ -1,17 +1,39 @@
using Android.Content;
using Java.Nio.FileNio;
#if !EXCLUDE_JAVAFILESTORAGE
namespace keepass2android.Io
{
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)
{
}
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; }
}

View File

@@ -832,7 +832,7 @@ namespace keepass2android
new OneDrive2FullFileStorage(),
new OneDrive2MyFilesFileStorage(),
new OneDrive2AppFolderFileStorage(),
new SftpFileStorage(LocaleManager.LocalizedAppContext, this),
new SftpFileStorage(LocaleManager.LocalizedAppContext, this, IsFtpDebugEnabled()),
new NetFtpFileStorage(LocaleManager.LocalizedAppContext, this, IsFtpDebugEnabled),
new WebDavFileStorage(this),
new PCloudFileStorage(LocaleManager.LocalizedAppContext, this),
@@ -855,7 +855,7 @@ namespace keepass2android
.GetBoolean(LocaleManager.LocalizedAppContext.GetString(Resource.String.FtpDebug_key), false);
}
public void TriggerReload(Context ctx, Action<bool> actionOnResult)
public void TriggerReload(Context ctx, Action<bool> actionOnResult)
{
Handler handler = new Handler(Looper.MainLooper);
handler.Post(() =>

View File

@@ -401,7 +401,11 @@ namespace keepass2android
#if !EXCLUDE_JAVAFILESTORAGE && !NoNet
private void OnJSchDebugChanged(object sender, Preference.PreferenceChangeEventArgs e)
{
SetJSchLogging((bool)e.NewValue);
bool debugEnabled = (bool)e.NewValue;
SetJSchLogging(debugEnabled);
string prefKey = Application.Context.GetString(Resource.String.FtpDebug_key);
PreferenceManager.SharedPreferences.Edit().PutBoolean(prefKey, debugEnabled).Apply();
}
private void SetJSchLogging(bool enabled)