From eeaa9f3280213d54f6a438925e7370ff22060aaa Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Mon, 15 Jun 2020 11:25:08 +0200 Subject: [PATCH] code cleanup --- src/keepass2android/BiometricModule.cs | 95 +----------------------- src/keepass2android/GroupBaseActivity.cs | 2 +- 2 files changed, 2 insertions(+), 95 deletions(-) diff --git a/src/keepass2android/BiometricModule.cs b/src/keepass2android/BiometricModule.cs index f514ea56..3b376352 100644 --- a/src/keepass2android/BiometricModule.cs +++ b/src/keepass2android/BiometricModule.cs @@ -21,100 +21,6 @@ using File = System.IO.File; namespace keepass2android { - - public static class Kp2aLog - { - private static bool? _logToFile; - - private static object _fileLocker = new object(); - - public static void Log(string message) - { - if (message != null) - Android.Util.Log.Debug("KP2A", message); - if (LogToFile) - { - lock (_fileLocker) - { - try - { - using (var streamWriter = System.IO.File.AppendText(LogFilename)) - { - string stringToLog = DateTime.Now + ":" + DateTime.Now.Millisecond + " -- " + message; - streamWriter.WriteLine(stringToLog); - } - } - catch (Exception e) - { - Android.Util.Log.Debug("KP2A", "Couldn't write to log file. " + e); - } - } - - } - - } - - private static string LogFilename - { - get { return Application.Context.FilesDir.CanonicalPath + "/keepass2android.log"; } - } - - private static bool LogToFile - { - get - { - if (_logToFile == null) - _logToFile = System.IO.File.Exists(LogFilename); - return (bool)_logToFile; - } - } - public static event EventHandler OnUnexpectedError; - - public static void LogUnexpectedError(Exception exception) - { - Log(exception.ToString()); - if (OnUnexpectedError != null) - OnUnexpectedError(null, exception); - } - - public static void CreateLogFile() - { - if (!System.IO.File.Exists(LogFilename)) - { - System.IO.File.Create(LogFilename).Dispose(); - _logToFile = true; - } - - - } - - public static void FinishLogFile() - { - if (System.IO.File.Exists(LogFilename)) - { - _logToFile = false; - int count = 0; - while (System.IO.File.Exists(LogFilename + "." + count)) - count++; - System.IO.File.Move(LogFilename, LogFilename + "." + count); - - } - - } - - public static void SendLog(Context ctx) - { - if (!System.IO.File.Exists(LogFilename)) - return; - Intent sendIntent = new Intent(); - sendIntent.SetAction(Intent.ActionSend); - sendIntent.PutExtra(Intent.ExtraText, File.ReadAllText(LogFilename)); - sendIntent.PutExtra(Intent.ExtraEmail, "crocoapps@gmail.com"); - sendIntent.PutExtra(Intent.ExtraSubject, "Keepass2Android log"); - sendIntent.SetType("text/plain"); - ctx.StartActivity(Intent.CreateChooser(sendIntent, "Send log to...")); - } - } public interface IBiometricAuthCallback { void OnBiometricAuthSucceeded(); @@ -215,6 +121,7 @@ namespace keepass2android get { var result = BiometricManager.From(Activity).CanAuthenticate(); + Kp2aLog.Log("BiometricHardware available = " + result); return result == BiometricManager.BiometricSuccess || result == BiometricManager.BiometricErrorNoneEnrolled; } diff --git a/src/keepass2android/GroupBaseActivity.cs b/src/keepass2android/GroupBaseActivity.cs index 5ff0a4fa..88ff105d 100644 --- a/src/keepass2android/GroupBaseActivity.cs +++ b/src/keepass2android/GroupBaseActivity.cs @@ -463,7 +463,7 @@ namespace keepass2android new AlertDialog.Builder(this) .SetTitle(Resource.String.autofill_enable) .SetMessage(Resource.String.autofill_enable_failed) - .SetPositiveButton(Resource.String.ok, (o, eventArgs) => { }) + .SetPositiveButton(Resource.String.Ok, (o, eventArgs) => { }) .Show(); const string autofillservicewasenabled = "AutofillServiceWasEnabled"; _prefs.Edit().PutBoolean(autofillservicewasenabled, true).Commit();