From b43b6b27a39a12e57d9ef01ec1caf766eb798af6 Mon Sep 17 00:00:00 2001 From: Philipp Crocoll Date: Wed, 25 May 2016 07:19:25 +0200 Subject: [PATCH] fix Intent filter issue on Android 6 (https://keepass2android.codeplex.com/workitem/518) --- src/keepass2android/PasswordActivity.cs | 54 ++++++++++--------- .../Properties/AndroidManifest_debug.xml | 9 ++++ .../Properties/AndroidManifest_net.xml | 11 +++- .../Properties/AndroidManifest_nonet.xml | 11 +++- 4 files changed, 59 insertions(+), 26 deletions(-) diff --git a/src/keepass2android/PasswordActivity.cs b/src/keepass2android/PasswordActivity.cs index 6bcf5e84..0a1955c2 100644 --- a/src/keepass2android/PasswordActivity.cs +++ b/src/keepass2android/PasswordActivity.cs @@ -1127,33 +1127,39 @@ namespace keepass2android //started from "view" intent (e.g. from file browser) _ioConnection.Path = i.DataString; - if (! _ioConnection.Path.Substring(0, 7).Equals("file://")) + if (_ioConnection.Path.StartsWith("file://")) { - //TODO: this might no longer be required as we can handle http(s) and ftp as well (but we need server credentials therefore) - Toast.MakeText(this, Resource.String.error_can_not_handle_uri, ToastLength.Long).Show(); - Finish(); - return false; - } - - _ioConnection.Path = URLDecoder.Decode(_ioConnection.Path.Substring(7)); - - if (_ioConnection.Path.Length == 0) - { - // No file name - Toast.MakeText(this, Resource.String.FileNotFound, ToastLength.Long).Show(); - Finish(); - return false; - } - - File dbFile = new File(_ioConnection.Path); - if (! dbFile.Exists()) - { - // File does not exist - Toast.MakeText(this, Resource.String.FileNotFound, ToastLength.Long).Show(); - Finish(); - return false; + _ioConnection.Path = URLDecoder.Decode(_ioConnection.Path.Substring(7)); + + if (_ioConnection.Path.Length == 0) + { + // No file name + Toast.MakeText(this, Resource.String.FileNotFound, ToastLength.Long).Show(); + Finish(); + return false; + } + + File dbFile = new File(_ioConnection.Path); + if (!dbFile.Exists()) + { + // File does not exist + Toast.MakeText(this, Resource.String.FileNotFound, ToastLength.Long).Show(); + Finish(); + return false; + } + } + else + { + if (!_ioConnection.Path.StartsWith("content://")) + { + + Toast.MakeText(this, Resource.String.error_can_not_handle_uri, ToastLength.Long).Show(); + Finish(); + return false; + } } + _keyFileOrProvider = GetKeyFile(_ioConnection.Path); return true; } diff --git a/src/keepass2android/Properties/AndroidManifest_debug.xml b/src/keepass2android/Properties/AndroidManifest_debug.xml index e16af291..fd9682a6 100644 --- a/src/keepass2android/Properties/AndroidManifest_debug.xml +++ b/src/keepass2android/Properties/AndroidManifest_debug.xml @@ -77,6 +77,15 @@ + + + + + + + + + diff --git a/src/keepass2android/Properties/AndroidManifest_net.xml b/src/keepass2android/Properties/AndroidManifest_net.xml index d6627780..3dc4eb73 100644 --- a/src/keepass2android/Properties/AndroidManifest_net.xml +++ b/src/keepass2android/Properties/AndroidManifest_net.xml @@ -69,7 +69,16 @@ - + + + + + + + + + + diff --git a/src/keepass2android/Properties/AndroidManifest_nonet.xml b/src/keepass2android/Properties/AndroidManifest_nonet.xml index 22dabe6a..82674207 100644 --- a/src/keepass2android/Properties/AndroidManifest_nonet.xml +++ b/src/keepass2android/Properties/AndroidManifest_nonet.xml @@ -47,7 +47,16 @@ - + + + + + + + + + +