| @@ -289,6 +289,52 @@ namespace keepass2android | |||||||
| 	        } | 	        } | ||||||
|         } |         } | ||||||
|  |  | ||||||
|  | 	    void AddBinaryOrAsk(Uri filename) | ||||||
|  | 	    { | ||||||
|  |  | ||||||
|  | 	        string strItem = GetFileName(filename); | ||||||
|  | 	        if (String.IsNullOrEmpty(strItem)) | ||||||
|  | 	            strItem = "attachment.bin"; | ||||||
|  |  | ||||||
|  | 	        if (State.Entry.Binaries.Get(strItem) != null) | ||||||
|  | 	        { | ||||||
|  | 	            AlertDialog.Builder builder = new AlertDialog.Builder(this); | ||||||
|  | 	            builder.SetTitle(GetString(Resource.String.AskOverwriteBinary_title)); | ||||||
|  |  | ||||||
|  | 	            builder.SetMessage(GetString(Resource.String.AskOverwriteBinary)); | ||||||
|  |  | ||||||
|  | 	            builder.SetPositiveButton(GetString(Resource.String.AskOverwriteBinary_yes), (dlgSender, dlgEvt) => | ||||||
|  | 	            { | ||||||
|  | 	                AddBinary(filename, true); | ||||||
|  | 	            }); | ||||||
|  |  | ||||||
|  | 	            builder.SetNegativeButton(GetString(Resource.String.AskOverwriteBinary_no), (dlgSender, dlgEvt) => | ||||||
|  | 	            { | ||||||
|  | 	                AddBinary(filename, false); | ||||||
|  | 	            }); | ||||||
|  |  | ||||||
|  | 	            builder.SetNeutralButton(GetString(Android.Resource.String.Cancel), | ||||||
|  | 	                (dlgSender, dlgEvt) => { }); | ||||||
|  |  | ||||||
|  | 	            Dialog dialog = builder.Create(); | ||||||
|  | 	            dialog.Show(); | ||||||
|  |  | ||||||
|  |  | ||||||
|  | 	        } | ||||||
|  | 	        else | ||||||
|  | 	            AddBinary(filename, true); | ||||||
|  | 	    } | ||||||
|  |  | ||||||
|  |         protected override void OnResume() | ||||||
|  | 	    { | ||||||
|  | 	        if (_uriToAddOrAsk != null) | ||||||
|  | 	        { | ||||||
|  |                 AddBinaryOrAsk(_uriToAddOrAsk); | ||||||
|  | 	            _uriToAddOrAsk = null; | ||||||
|  | 	        } | ||||||
|  |             base.OnResume(); | ||||||
|  | 	    } | ||||||
|  |  | ||||||
| 	    private void CreateNewFromKpEntryTemplate(Database db, PwEntry templateEntry) | 	    private void CreateNewFromKpEntryTemplate(Database db, PwEntry templateEntry) | ||||||
| 		{ | 		{ | ||||||
| 			var entry = new PwEntry(true, true); | 			var entry = new PwEntry(true, true); | ||||||
| @@ -574,40 +620,6 @@ namespace keepass2android | |||||||
| 			return result; | 			return result; | ||||||
| 		} | 		} | ||||||
|  |  | ||||||
| 		void AddBinaryOrAsk(Uri filename) |  | ||||||
| 		{ |  | ||||||
|  |  | ||||||
| 			string strItem = GetFileName(filename); |  | ||||||
| 			if (String.IsNullOrEmpty(strItem)) |  | ||||||
| 				strItem = "attachment.bin"; |  | ||||||
|  |  | ||||||
| 			if(State.Entry.Binaries.Get(strItem) != null) |  | ||||||
| 			{ |  | ||||||
| 				AlertDialog.Builder builder = new AlertDialog.Builder(this); |  | ||||||
| 				builder.SetTitle(GetString(Resource.String.AskOverwriteBinary_title)); |  | ||||||
|  |  | ||||||
| 				builder.SetMessage(GetString(Resource.String.AskOverwriteBinary)); |  | ||||||
|  |  | ||||||
| 				builder.SetPositiveButton(GetString(Resource.String.AskOverwriteBinary_yes), (dlgSender, dlgEvt) =>  |  | ||||||
| 				                                                                                                         { |  | ||||||
| 						AddBinary(filename, true); |  | ||||||
| 					}); |  | ||||||
|  |  | ||||||
| 				builder.SetNegativeButton(GetString(Resource.String.AskOverwriteBinary_no), (dlgSender, dlgEvt) =>  |  | ||||||
| 				                                                                                                         { |  | ||||||
| 						AddBinary(filename, false); |  | ||||||
| 					}); |  | ||||||
|  |  | ||||||
| 				builder.SetNeutralButton(GetString(Android.Resource.String.Cancel),  |  | ||||||
| 				                         (dlgSender, dlgEvt) => {}); |  | ||||||
|  |  | ||||||
| 				Dialog dialog = builder.Create(); |  | ||||||
| 				dialog.Show(); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 			} else |  | ||||||
| 				AddBinary(filename, true); |  | ||||||
| 		} |  | ||||||
| 		 | 		 | ||||||
| 		void AddBinary(Uri filename, bool overwrite) | 		void AddBinary(Uri filename, bool overwrite) | ||||||
| 		{ | 		{ | ||||||
| @@ -762,12 +774,8 @@ namespace keepass2android | |||||||
| 						} | 						} | ||||||
| 						uri = Uri.Parse(s); | 						uri = Uri.Parse(s); | ||||||
| 					} | 					} | ||||||
| 					AddBinaryOrAsk(uri); | 				    _uriToAddOrAsk = uri; //we can't launch a dialog in onActivityResult, so delay this to onResume		 | ||||||
| 						 |  | ||||||
| 				} | 				} | ||||||
| 				Reload(); |  | ||||||
|  |  | ||||||
|  |  | ||||||
| 				break; | 				break; | ||||||
| 			case Result.Canceled: | 			case Result.Canceled: | ||||||
| 				Reload(); | 				Reload(); | ||||||
| @@ -905,6 +913,7 @@ namespace keepass2android | |||||||
|  |  | ||||||
| 	    private string[] _additionalKeys = null; | 	    private string[] _additionalKeys = null; | ||||||
| 	    private List<View> _editModeHiddenViews; | 	    private List<View> _editModeHiddenViews; | ||||||
|  | 	    private Uri _uriToAddOrAsk; | ||||||
|  |  | ||||||
| 	    public string[] AdditionalKeys | 	    public string[] AdditionalKeys | ||||||
| 	    { | 	    { | ||||||
|   | |||||||
| @@ -28,12 +28,6 @@ | |||||||
| 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider" android:authorities="keepass2android.keepass2android_debug.android-filechooser.localfile" android:exported="false" /> | 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider" android:authorities="keepass2android.keepass2android_debug.android-filechooser.localfile" android:exported="false" /> | ||||||
| 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.history.HistoryProvider" android:authorities="keepass2android.keepass2android_debug.android-filechooser.history" android:exported="false" /> | 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.history.HistoryProvider" android:authorities="keepass2android.keepass2android_debug.android-filechooser.history" android:exported="false" /> | ||||||
| 		<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="user" android:theme="@style/Afc.Theme.Light"> | 		<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="user" android:theme="@style/Afc.Theme.Light"> | ||||||
| 			<intent-filter> |  | ||||||
| 				<action android:name="android.intent.action.GET_CONTENT" /> |  | ||||||
| 				<data android:mimeType="*/*" /> |  | ||||||
| 				<category android:name="android.intent.category.DEFAULT" /> |  | ||||||
| 				<category android:name="android.intent.category.OPENABLE" /> |  | ||||||
| 			</intent-filter> |  | ||||||
| 		</activity> | 		</activity> | ||||||
| 		<service android:name="keepass2android.softkeyboard.KP2AKeyboard" android:permission="android.permission.BIND_INPUT_METHOD"> | 		<service android:name="keepass2android.softkeyboard.KP2AKeyboard" android:permission="android.permission.BIND_INPUT_METHOD"> | ||||||
| 			<intent-filter> | 			<intent-filter> | ||||||
| @@ -123,6 +117,7 @@ | |||||||
| 	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | 	<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> | ||||||
| 	<uses-permission android:name="android.permission.INTERNET" /> | 	<uses-permission android:name="android.permission.INTERNET" /> | ||||||
| 	<uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 	<uses-permission android:name="android.permission.GET_ACCOUNTS" /> | ||||||
|  | 	<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||||||
| 	<uses-permission android:name="android.permission.USE_CREDENTIALS" /> | 	<uses-permission android:name="android.permission.USE_CREDENTIALS" /> | ||||||
| 	<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> | 	<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" /> | ||||||
| 	<uses-permission android:name="keepass2android.keepass2android_debug.permission.KP2aInternalFileBrowsing" /> | 	<uses-permission android:name="keepass2android.keepass2android_debug.permission.KP2aInternalFileBrowsing" /> | ||||||
|   | |||||||
| @@ -33,12 +33,6 @@ | |||||||
| 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider" android:authorities="keepass2android.keepass2android.android-filechooser.localfile" android:exported="false" /> | 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider" android:authorities="keepass2android.keepass2android.android-filechooser.localfile" android:exported="false" /> | ||||||
| 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.history.HistoryProvider" android:authorities="keepass2android.keepass2android.android-filechooser.history" android:exported="false" /> | 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.history.HistoryProvider" android:authorities="keepass2android.keepass2android.android-filechooser.history" android:exported="false" /> | ||||||
| 		<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="user" android:theme="@style/Afc.Theme.Light"> | 		<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="user" android:theme="@style/Afc.Theme.Light"> | ||||||
| 			<intent-filter> |  | ||||||
| 				<action android:name="android.intent.action.GET_CONTENT" /> |  | ||||||
| 				<data android:mimeType="*/*" /> |  | ||||||
| 				<category android:name="android.intent.category.DEFAULT" /> |  | ||||||
| 				<category android:name="android.intent.category.OPENABLE" /> |  | ||||||
| 			</intent-filter> |  | ||||||
| 		</activity> | 		</activity> | ||||||
|  |  | ||||||
| 		<service android:name="keepass2android.softkeyboard.KP2AKeyboard" android:permission="android.permission.BIND_INPUT_METHOD"> | 		<service android:name="keepass2android.softkeyboard.KP2AKeyboard" android:permission="android.permission.BIND_INPUT_METHOD"> | ||||||
| @@ -149,6 +143,7 @@ | |||||||
| 	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | 	<uses-permission android:name="android.permission.READ_EXTERNAL_STORAGE" /> | ||||||
| 	<uses-permission android:name="android.permission.INTERNET" /> | 	<uses-permission android:name="android.permission.INTERNET" /> | ||||||
| 	<uses-permission android:name="android.permission.GET_ACCOUNTS" /> | 	<uses-permission android:name="android.permission.GET_ACCOUNTS" /> | ||||||
|  | 	<uses-permission android:name="android.permission.FOREGROUND_SERVICE" /> | ||||||
| 	<uses-permission android:name="android.permission.USE_CREDENTIALS" android:maxSdkVersion="22" /> | 	<uses-permission android:name="android.permission.USE_CREDENTIALS" android:maxSdkVersion="22" /> | ||||||
| 	<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" android:maxSdkVersion="22" /> | 	<uses-permission android:name="android.permission.MANAGE_ACCOUNTS" android:maxSdkVersion="22" /> | ||||||
| 	<uses-permission android:name="keepass2android.keepass2android.permission.KP2aInternalFileBrowsing" /> | 	<uses-permission android:name="keepass2android.keepass2android.permission.KP2aInternalFileBrowsing" /> | ||||||
|   | |||||||
| @@ -15,12 +15,6 @@ | |||||||
| 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider" android:authorities="keepass2android.keepass2android_nonet.android-filechooser.localfile" android:exported="false" /> | 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.localfile.LocalFileProvider" android:authorities="keepass2android.keepass2android_nonet.android-filechooser.localfile" android:exported="false" /> | ||||||
| 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.history.HistoryProvider" android:authorities="keepass2android.keepass2android_nonet.android-filechooser.history" android:exported="false" /> | 		<provider android:name="group.pals.android.lib.ui.filechooser.providers.history.HistoryProvider" android:authorities="keepass2android.keepass2android_nonet.android-filechooser.history" android:exported="false" /> | ||||||
| 		<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="user" android:theme="@style/Afc.Theme.Light"> | 		<activity android:name="group.pals.android.lib.ui.filechooser.FileChooserActivity" android:configChanges="keyboard|keyboardHidden|orientation|screenSize" android:screenOrientation="user" android:theme="@style/Afc.Theme.Light"> | ||||||
| 			<intent-filter> |  | ||||||
| 				<action android:name="android.intent.action.GET_CONTENT" /> |  | ||||||
| 				<data android:mimeType="*/*" /> |  | ||||||
| 				<category android:name="android.intent.category.DEFAULT" /> |  | ||||||
| 				<category android:name="android.intent.category.OPENABLE" /> |  | ||||||
| 			</intent-filter> |  | ||||||
| 		</activity> | 		</activity> | ||||||
|  |  | ||||||
| 		<service android:name="keepass2android.softkeyboard.KP2AKeyboard" android:permission="android.permission.BIND_INPUT_METHOD"> | 		<service android:name="keepass2android.softkeyboard.KP2AKeyboard" android:permission="android.permission.BIND_INPUT_METHOD"> | ||||||
|   | |||||||
| @@ -48,6 +48,7 @@ | |||||||
|    |    | ||||||
|  |  | ||||||
|   <!--  Preference settings --> |   <!--  Preference settings --> | ||||||
|  |   <string name="AutoReturnFromQuery_key">AutoReturnFromQuery_key</string> | ||||||
|   <string name="algorithm_key">algorithm</string> |   <string name="algorithm_key">algorithm</string> | ||||||
|     <string name="app_key">app</string> |     <string name="app_key">app</string> | ||||||
|     <string name="app_timeout_key">app_timeout_key</string> |     <string name="app_timeout_key">app_timeout_key</string> | ||||||
|   | |||||||
| @@ -221,6 +221,8 @@ | |||||||
|   <string name="edit">Edit</string> |   <string name="edit">Edit</string> | ||||||
|   <string name="rijndael">Rijndael (AES)</string> |   <string name="rijndael">Rijndael (AES)</string> | ||||||
|   <string name="root">Root</string> |   <string name="root">Root</string> | ||||||
|  |   <string name="AutoReturnFromQuery_title">Automatically return from query screen</string> | ||||||
|  |   <string name="AutoReturnFromQuery_summary">When looking up an entry for an app or website: automatically return from query screen if there is only one matching entry in the database.</string> | ||||||
|  |  | ||||||
|   <string name="KeyDerivFunc">Key derivation function</string> |   <string name="KeyDerivFunc">Key derivation function</string> | ||||||
|    |    | ||||||
|   | |||||||
| @@ -402,6 +402,14 @@ | |||||||
|          |          | ||||||
|       </Preference> |       </Preference> | ||||||
|  |  | ||||||
|  | 		  <CheckBoxPreference | ||||||
|  | 		    android:enabled="true" | ||||||
|  | 		    android:persistent="true" | ||||||
|  | 		    android:summary="@string/AutoReturnFromQuery_summary" | ||||||
|  | 		    android:defaultValue="true" | ||||||
|  | 		    android:title="@string/AutoReturnFromQuery_title" | ||||||
|  | 		    android:key="@string/AutoReturnFromQuery_key" /> | ||||||
|  |  | ||||||
|       </PreferenceScreen> |       </PreferenceScreen> | ||||||
| 		<PreferenceScreen | 		<PreferenceScreen | ||||||
| 			  android:key="@string/QuickUnlock_prefs_key" | 			  android:key="@string/QuickUnlock_prefs_key" | ||||||
|   | |||||||
| @@ -25,6 +25,7 @@ using Android.Runtime; | |||||||
| using Android.Views; | using Android.Views; | ||||||
| using Android.Widget; | using Android.Widget; | ||||||
| using Android.Content.PM; | using Android.Content.PM; | ||||||
|  | using Android.Preferences; | ||||||
| using KeePassLib.Utility; | using KeePassLib.Utility; | ||||||
|  |  | ||||||
| namespace keepass2android | namespace keepass2android | ||||||
| @@ -134,7 +135,7 @@ namespace keepass2android | |||||||
| 			} | 			} | ||||||
| 			 | 			 | ||||||
| 			//if there is exactly one match: open the entry | 			//if there is exactly one match: open the entry | ||||||
| 			if ((Group.Entries.Count() == 1) && autoReturnFromQuery) | 			if ((Group.Entries.Count() == 1) && autoReturnFromQuery && PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(GetString(Resource.String.AutoReturnFromQuery_key),true)) | ||||||
| 			{ | 			{ | ||||||
| 				LaunchActivityForEntry(Group.Entries.Single(),0); | 				LaunchActivityForEntry(Group.Entries.Single(),0); | ||||||
| 				return; | 				return; | ||||||
|   | |||||||
| @@ -385,7 +385,16 @@ namespace keepass2android | |||||||
|                 { |                 { | ||||||
|  |  | ||||||
|                     var intent = new Intent(Settings.ActionRequestSetAutofillService); |                     var intent = new Intent(Settings.ActionRequestSetAutofillService); | ||||||
|  |                     if (((AutofillManager) Activity.GetSystemService(Java.Lang.Class.FromType(typeof(AutofillManager)))) | ||||||
|  |                         .HasEnabledAutofillServices) | ||||||
|  |                     { | ||||||
|  |                         intent.SetData(Android.Net.Uri.Parse("package:" + Context.PackageName + "notexisting")); //if we use our package name, the activity won't launch | ||||||
|  |                     } | ||||||
|  |                     else | ||||||
|  |                     { | ||||||
|                         intent.SetData(Android.Net.Uri.Parse("package:" + Context.PackageName)); |                         intent.SetData(Android.Net.Uri.Parse("package:" + Context.PackageName)); | ||||||
|  |                     } | ||||||
|  |  | ||||||
|                     try |                     try | ||||||
|                     { |                     { | ||||||
|                         Context.StartActivity(intent); |                         Context.StartActivity(intent); | ||||||
| @@ -401,6 +410,10 @@ namespace keepass2android | |||||||
|                             .Show(); |                             .Show(); | ||||||
|  |  | ||||||
|                     } |                     } | ||||||
|  |                     catch (Exception e) | ||||||
|  |                     { | ||||||
|  |                         Kp2aLog.LogUnexpectedError(e); | ||||||
|  |                     } | ||||||
|                 }; |                 }; | ||||||
|             } |             } | ||||||
|  |  | ||||||
| @@ -527,11 +540,6 @@ namespace keepass2android | |||||||
|                 else |                 else | ||||||
|                 { |                 { | ||||||
|                     autofillPref.Summary = Activity.GetString(Resource.String.not_enabled); |                     autofillPref.Summary = Activity.GetString(Resource.String.not_enabled); | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|  |  | ||||||
|                 } |                 } | ||||||
|  |  | ||||||
|             } |             } | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 PhilippC
					PhilippC