Merge pull request #2457 from hyproman/persist-ftp-debug-perf
Persist ftp debug preference
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(),
 | 
				
			||||||
                            new SftpFileStorage(LocaleManager.LocalizedAppContext, this),
 | 
					                            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),
 | 
				
			||||||
@@ -855,7 +855,7 @@ namespace keepass2android
 | 
				
			|||||||
				.GetBoolean(LocaleManager.LocalizedAppContext.GetString(Resource.String.FtpDebug_key), false);
 | 
									.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 handler = new Handler(Looper.MainLooper);
 | 
				
			||||||
			handler.Post(() =>
 | 
								handler.Post(() =>
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -401,7 +401,11 @@ namespace keepass2android
 | 
				
			|||||||
#if !EXCLUDE_JAVAFILESTORAGE && !NoNet
 | 
					#if !EXCLUDE_JAVAFILESTORAGE && !NoNet
 | 
				
			||||||
        private void OnJSchDebugChanged(object sender, Preference.PreferenceChangeEventArgs e)
 | 
					        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)
 | 
					        private void SetJSchLogging(bool enabled)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user