diff --git a/src/KeePassLib2Android/PwGroup.cs b/src/KeePassLib2Android/PwGroup.cs index 3751186c..793ff3bc 100644 --- a/src/KeePassLib2Android/PwGroup.cs +++ b/src/KeePassLib2Android/PwGroup.cs @@ -990,7 +990,7 @@ namespace KeePassLib if (contextString.Length > SearchContextStringMaxLength) { // Start 10% before actual data, and don't run over - var startPos = Math.Min(matchPos - (SearchContextStringMaxLength / 10), contextString.Length - SearchContextStringMaxLength); + var startPos = Math.Max(0, Math.Min(matchPos - (SearchContextStringMaxLength / 10), contextString.Length - SearchContextStringMaxLength)); contextString = "… " + contextString.Substring(startPos, SearchContextStringMaxLength) + ((startPos + SearchContextStringMaxLength < contextString.Length) ? " …" : null); } resultContexts[pe.Uuid] = new KeyValuePair(contextFieldName, contextString); diff --git a/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs b/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs index 893b250b..c9d1f867 100644 --- a/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs +++ b/src/Kp2aBusinessLogic/Io/AndroidContentStorage.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.IO; using System.Linq; using Android.Content; +using Android.Database; using Android.OS; using Android.Provider; using KeePassLib.Serialization; @@ -209,22 +210,23 @@ namespace keepass2android.Io public bool IsReadOnly(IOConnectionInfo ioc, OptionalOut reason = null) { - //on pre-Kitkat devices, we can't write content:// files - if (!IsKitKatOrLater) - { - Kp2aLog.Log("File is read-only because we're not on KitKat or later."); - if (reason != null) - reason.Result = UiStringKey.ReadOnlyReason_PreKitKat; - return true; - } + ICursor cursor = null; + try + { + //on pre-Kitkat devices, we can't write content:// files + if (!IsKitKatOrLater) + { + Kp2aLog.Log("File is read-only because we're not on KitKat or later."); + if (reason != null) + reason.Result = UiStringKey.ReadOnlyReason_PreKitKat; + return true; + } - //KitKat or later... - var uri = Android.Net.Uri.Parse(ioc.Path); - var cursor = _ctx.ContentResolver.Query(uri, null, null, null, null, null); + //KitKat or later... + var uri = Android.Net.Uri.Parse(ioc.Path); + cursor = _ctx.ContentResolver.Query(uri, null, null, null, null, null); - try - { if (cursor != null && cursor.MoveToFirst()) { int flags = cursor.GetInt(cursor.GetColumnIndex(DocumentsContract.Document.ColumnFlags)); @@ -235,14 +237,23 @@ namespace keepass2android.Io reason.Result = UiStringKey.ReadOnlyReason_ReadOnlyFlag; return true; } + else return false; } + else throw new Exception("couldn't move to first result element"); + } + catch (Exception e) + { + Kp2aLog.LogUnexpectedError(e); + //better return false here. We don't really know what happened (as this is unexpected). + //let the user try to write the file. If it fails they will get an exception string. + return false; } finally { if (cursor != null) cursor.Close(); } - return true; + } } diff --git a/src/keepass2android/FingerprintSamsungIdentifier.cs b/src/keepass2android/FingerprintSamsungIdentifier.cs index 399c468e..1e24601a 100644 --- a/src/keepass2android/FingerprintSamsungIdentifier.cs +++ b/src/keepass2android/FingerprintSamsungIdentifier.cs @@ -134,7 +134,11 @@ namespace keepass2android } catch (IllegalStateException ise) { - Kp2aLog.LogUnexpectedError(ise); + Kp2aLog.Log(ise.ToString()); + } + catch (System.Exception e) + { + Kp2aLog.LogUnexpectedError(e); } } } diff --git a/src/keepass2android/Properties/AndroidManifest_net.xml b/src/keepass2android/Properties/AndroidManifest_net.xml index d7205860..b2bbf289 100644 --- a/src/keepass2android/Properties/AndroidManifest_net.xml +++ b/src/keepass2android/Properties/AndroidManifest_net.xml @@ -1,7 +1,7 @@  diff --git a/src/keepass2android/Resources/values/strings.xml b/src/keepass2android/Resources/values/strings.xml index b0d301a5..98c09d62 100644 --- a/src/keepass2android/Resources/values/strings.xml +++ b/src/keepass2android/Resources/values/strings.xml @@ -616,6 +616,7 @@ Please note! This is a preview release and might come with some flaws! If you experience *anything* unexpected, please let me know (on Codeplex or by email). + Whenever you see a question if you want to enable error reports, please do so! Continue The URI you have entered does not look like a filename. Are you sure this is a valid file? @@ -655,7 +656,7 @@ - Version 1.0.0 - preview 4\n + Version 1.0.0 - preview 5\n * Fingerprint Unlock (requires Android 6.0+ or a Samsung device)\n * Added support for entry templates\n * Added "work offline" mode\n @@ -663,6 +664,9 @@ * Auto-complete mode for field names\n * Allow to remove items from recent files list\n * Request permissions at runtime in Android 6.0\n + * Bug fixes (in built-in keyboard, when selecting icons)\n + * Included option to send error reports\n + * Added help messages at several points\n * more to come...\n