protected override void OnCreate(Bundle savedInstanceState) { _design.ApplyTheme(); base.OnCreate(savedInstanceState); Android.Util.Log.Debug("KP2A", "Creating GBA"); AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent); // Likely the app has been killed exit the activity if (!App.Kp2a.GetDb().Loaded) { Finish(); return; } _prefs = PreferenceManager.GetDefaultSharedPreferences(this); SetContentView(ContentResourceId); if (FindViewById(Resource.Id.fabCancelAddNew) != null) { FindViewById(Resource.Id.fabAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fabAddNewGroup).Visibility = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Gone; }; FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Visible; }; } if (FindViewById(Resource.Id.cancel_insert_element) != null) { FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements(); FindViewById(Resource.Id.insert_element).Click += (sender, args) => InsertElements(); Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this); } SetResult(KeePass.ExitNormal); }
protected override void OnCreate(Bundle bundle) { _design.ApplyTheme(); base.OnCreate(bundle); //use FlagSecure to make sure the last (revealed) character of the password is not visible in recent apps Util.MakeSecureDisplay(this); _ioc = App.Kp2a.GetDbForQuickUnlock()?.Ioc; if (_ioc == null) { Finish(); return; } SetContentView(Resource.Layout.QuickUnlock); var toolbar = FindViewById <AndroidX.AppCompat.Widget.Toolbar>(Resource.Id.mytoolbar); SetSupportActionBar(toolbar); var collapsingToolbar = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar); collapsingToolbar.SetTitle(GetString(Resource.String.QuickUnlock_prefs)); if (App.Kp2a.GetDbForQuickUnlock().KpDatabase.Name != "") { FindViewById(Resource.Id.filename_label).Visibility = ViewStates.Visible; ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetDbForQuickUnlock().KpDatabase.Name; } else { if ( PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.RememberRecentFiles_key), Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default))) { ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetFileStorage(_ioc).GetDisplayName(_ioc); } else { ((TextView)FindViewById(Resource.Id.filename_label)).Text = "*****"; } } TextView txtLabel = (TextView)FindViewById(Resource.Id.QuickUnlock_label); _quickUnlockLength = App.Kp2a.QuickUnlockKeyLength; if (PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.QuickUnlockHideLength_key), false)) { txtLabel.Text = GetString(Resource.String.QuickUnlock_label_secure); } else { txtLabel.Text = GetString(Resource.String.QuickUnlock_label, new Java.Lang.Object[] { _quickUnlockLength }); } EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password); pwd.SetEms(_quickUnlockLength); Util.MoveBottomBarButtons(Resource.Id.QuickUnlock_buttonLock, Resource.Id.QuickUnlock_button, Resource.Id.bottom_bar, this); Button btnUnlock = (Button)FindViewById(Resource.Id.QuickUnlock_button); btnUnlock.Click += (object sender, EventArgs e) => { OnUnlock(pwd); }; Button btnLock = (Button)FindViewById(Resource.Id.QuickUnlock_buttonLock); btnLock.Text = btnLock.Text.Replace("ß", "ss"); btnLock.Click += (object sender, EventArgs e) => { App.Kp2a.Lock(false); Finish(); }; pwd.EditorAction += (sender, args) => { if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down))) { OnUnlock(pwd); } }; _intentReceiver = new QuickUnlockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_intentReceiver, filter); Util.SetNoPersonalizedLearning(FindViewById <EditText>(Resource.Id.QuickUnlock_password)); if (bundle != null) { numFailedAttempts = bundle.GetInt(NumFailedAttemptsKey, 0); } }
private void Query(string url, bool autoReturnFromQuery) { try { //first: search for exact url Group = _db.SearchForExactUrl(url); if (!url.StartsWith("androidapp://")) { //if no results, search for host (e.g. "accounts.google.com") if (!Group.Entries.Any()) { Group = _db.SearchForHost(url, false); } //if still no results, search for host, allowing subdomains ("www.google.com" in entry is ok for "accounts.google.com" in search (but not the other way around) if (!Group.Entries.Any()) { Group = _db.SearchForHost(url, true); } } //if no results returned up to now, try to search through other fields as well: if (!Group.Entries.Any()) { Group = _db.SearchForText(url); } //search for host as text if (!Group.Entries.Any()) { Group = _db.SearchForText(UrlUtil.GetHost(url.Trim())); } } catch (Exception e) { Toast.MakeText(this, e.Message, ToastLength.Long).Show(); SetResult(Result.Canceled); Finish(); return; } //if there is exactly one match: open the entry if ((Group.Entries.Count() == 1) && autoReturnFromQuery && PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(GetString(Resource.String.AutoReturnFromQuery_key), true)) { LaunchActivityForEntry(Group.Entries.Single(), 0); return; } //show results: if (Group == null || (!Group.Entries.Any())) { SetContentView(Resource.Layout.searchurlresults_empty); } SetGroupTitle(); FragmentManager.FindFragmentById <GroupListFragment>(Resource.Id.list_fragment).ListAdapter = new PwGroupListAdapter(this, Group); View selectOtherEntry = FindViewById(Resource.Id.select_other_entry); var newTask = new SelectEntryForUrlTask(url); if (AppTask is SelectEntryTask currentSelectTask) { newTask.ShowUserNotifications = currentSelectTask.ShowUserNotifications; } selectOtherEntry.Click += (sender, e) => { GroupActivity.Launch(this, newTask); }; View createUrlEntry = FindViewById(Resource.Id.add_url_entry); if (App.Kp2a.GetDb().CanWrite) { createUrlEntry.Visibility = ViewStates.Visible; createUrlEntry.Click += (sender, e) => { GroupActivity.Launch(this, new CreateEntryThenCloseTask { Url = url, ShowUserNotifications = (AppTask as SelectEntryTask)?.ShowUserNotifications ?? true }); Toast.MakeText(this, GetString(Resource.String.select_group_then_add, new Java.Lang.Object[] { GetString(Resource.String.add_entry) }), ToastLength.Long).Show(); }; } else { createUrlEntry.Visibility = ViewStates.Gone; } Util.MoveBottomBarButtons(Resource.Id.select_other_entry, Resource.Id.add_url_entry, Resource.Id.bottom_bar, this); }
protected override void OnCreate(Bundle bundle) { _design.ApplyTheme(); base.OnCreate(bundle); //use FlagSecure to make sure the last (revealed) character of the password is not visible in recent apps if (PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean( GetString(Resource.String.ViewDatabaseSecure_key), true)) { Window.SetFlags(WindowManagerFlags.Secure, WindowManagerFlags.Secure); } _ioc = App.Kp2a.GetDb().Ioc; if (_ioc == null) { Finish(); return; } SetContentView(Resource.Layout.QuickUnlock); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar); SetSupportActionBar(toolbar); var collapsingToolbar = FindViewById <CollapsingToolbarLayout>(Resource.Id.collapsing_toolbar); collapsingToolbar.SetTitle(GetString(Resource.String.QuickUnlock_prefs)); if (App.Kp2a.GetDb().KpDatabase.Name != "") { FindViewById(Resource.Id.filename_label).Visibility = ViewStates.Visible; ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetDb().KpDatabase.Name; } else { if ( PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.RememberRecentFiles_key), Resources.GetBoolean(Resource.Boolean.RememberRecentFiles_default))) { ((TextView)FindViewById(Resource.Id.filename_label)).Text = App.Kp2a.GetFileStorage(_ioc).GetDisplayName(_ioc); } else { ((TextView)FindViewById(Resource.Id.filename_label)).Text = "*****"; } } TextView txtLabel = (TextView)FindViewById(Resource.Id.QuickUnlock_label); _quickUnlockLength = App.Kp2a.QuickUnlockKeyLength; txtLabel.Text = GetString(Resource.String.QuickUnlock_label, new Java.Lang.Object[] { _quickUnlockLength }); EditText pwd = (EditText)FindViewById(Resource.Id.QuickUnlock_password); pwd.SetEms(_quickUnlockLength); Util.MoveBottomBarButtons(Resource.Id.QuickUnlock_buttonLock, Resource.Id.QuickUnlock_button, Resource.Id.bottom_bar, this); Button btnUnlock = (Button)FindViewById(Resource.Id.QuickUnlock_button); btnUnlock.Click += (object sender, EventArgs e) => { OnUnlock(_quickUnlockLength, pwd); }; Button btnLock = (Button)FindViewById(Resource.Id.QuickUnlock_buttonLock); btnLock.Text = btnLock.Text.Replace("ß", "ss"); btnLock.Click += (object sender, EventArgs e) => { App.Kp2a.LockDatabase(false); Finish(); }; pwd.EditorAction += (sender, args) => { if ((args.ActionId == ImeAction.Done) || ((args.ActionId == ImeAction.ImeNull) && (args.Event.Action == KeyEventActions.Down))) { OnUnlock(_quickUnlockLength, pwd); } }; _intentReceiver = new QuickUnlockBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_intentReceiver, filter); if ((int)Build.VERSION.SdkInt >= 23) { Kp2aLog.Log("requesting fingerprint permission"); RequestPermissions(new[] { Manifest.Permission.UseFingerprint }, FingerprintPermissionRequestCode); } else { } }
protected override void OnCreate(Bundle savedInstanceState) { _design.ApplyTheme(); base.OnCreate(savedInstanceState); Android.Util.Log.Debug("KP2A", "Creating GBA"); AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent); // Likely the app has been killed exit the activity if (!App.Kp2a.GetDb().Loaded) { Finish(); return; } _prefs = PreferenceManager.GetDefaultSharedPreferences(this); SetContentView(ContentResourceId); if (FindViewById(Resource.Id.enable_autofill) != null) { FindViewById(Resource.Id.enable_autofill).Click += (sender, args) => { var intent = new Intent(Settings.ActionRequestSetAutofillService); intent.SetData(Android.Net.Uri.Parse("package:" + PackageName)); try { StartActivity(intent); } catch (ActivityNotFoundException e) { //this exception was reported by many Huawei users Kp2aLog.LogUnexpectedError(e); new AlertDialog.Builder(this) .SetTitle(Resource.String.autofill_enable) .SetMessage(Resource.String.autofill_enable_failed) .SetPositiveButton(Resource.String.ok, (o, eventArgs) => { }) .Show(); const string autofillservicewasenabled = "AutofillServiceWasEnabled"; _prefs.Edit().PutBoolean(autofillservicewasenabled, true).Commit(); UpdateBottomBarElementVisibility(Resource.Id.autofill_infotext, false); } }; } if (FindViewById(Resource.Id.info_dont_show_autofill_again) != null) { FindViewById(Resource.Id.info_dont_show_autofill_again).Click += (sender, args) => { _prefs.Edit().PutBoolean(autofillservicewasenabled_prefskey, true).Commit(); UpdateAutofillInfo(); }; } if (FindViewById(Resource.Id.fabCancelAddNew) != null) { FindViewById(Resource.Id.fabAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fabAddNewGroup).Visibility = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Gone; }; FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Visible; }; } if (FindViewById(Resource.Id.cancel_insert_element) != null) { FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements(); FindViewById(Resource.Id.insert_element).Click += (sender, args) => InsertElements(); Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this); } if (FindViewById(Resource.Id.show_autofill_info) != null) { FindViewById(Resource.Id.show_autofill_info).Click += (sender, args) => Util.GotoUrl(this, "https://philippc.github.io/keepass2android/OreoAutoFill.html"); Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this); } if (FindViewById(Resource.Id.configure_notification_channels) != null) { FindViewById(Resource.Id.configure_notification_channels).Click += (sender, args) => { Intent intent = new Intent(Settings.ActionChannelNotificationSettings); intent.PutExtra(Settings.ExtraChannelId, App.NotificationChannelIdQuicklocked); intent.PutExtra(Settings.ExtraAppPackage, PackageName); try { StartActivity(intent); } catch (Exception e) { new AlertDialog.Builder(this) .SetTitle("Unexpected error") .SetMessage( "Opening the settings failed. Please report this to [email protected] including information about your device vendor and OS. Please try to configure the notifications by long pressing a KP2A notification. Details: " + e.ToString()) .Show(); } UpdateAndroid8NotificationInfo(true); }; FindViewById(Resource.Id.ignore_notification_channel).Click += (sender, args) => { UpdateAndroid8NotificationInfo(true); }; } SetResult(KeePass.ExitNormal); }
protected override void OnCreate(Bundle savedInstanceState) { _design.ApplyTheme(); base.OnCreate(savedInstanceState); Android.Util.Log.Debug("KP2A", "Creating GBA"); AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent); // Likely the app has been killed exit the activity if (!App.Kp2a.GetDb().Loaded) { Finish(); return; } _prefs = PreferenceManager.GetDefaultSharedPreferences(this); SetContentView(ContentResourceId); if (FindViewById(Resource.Id.enable_autofill) != null) { FindViewById(Resource.Id.enable_autofill).Click += (sender, args) => { var intent = new Intent(Settings.ActionRequestSetAutofillService); intent.SetData(Android.Net.Uri.Parse("package:" + PackageName)); try { StartActivity(intent); } catch (ActivityNotFoundException e) { //this exception was reported by many Huawei users Kp2aLog.LogUnexpectedError(e); new AlertDialog.Builder(this) .SetTitle(Resource.String.autofill_enable) .SetMessage(Resource.String.autofill_enable_failed) .SetPositiveButton(Resource.String.ok, (o, eventArgs) => { }) .Show(); const string autofillservicewasenabled = "AutofillServiceWasEnabled"; _prefs.Edit().PutBoolean(autofillservicewasenabled, true).Commit(); UpdateBottomBarElementVisibility(Resource.Id.autofill_infotext, false); } }; } if (FindViewById(Resource.Id.fabCancelAddNew) != null) { FindViewById(Resource.Id.fabAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fabAddNewGroup).Visibility = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Gone; }; FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Visible; }; } if (FindViewById(Resource.Id.cancel_insert_element) != null) { FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements(); FindViewById(Resource.Id.insert_element).Click += (sender, args) => InsertElements(); Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this); } if (FindViewById(Resource.Id.show_autofill_info) != null) { FindViewById(Resource.Id.show_autofill_info).Click += (sender, args) => Util.GotoUrl(this, "https://philippc.github.io/keepass2android/OreoAutoFill.html"); Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this); } if (FindViewById(Resource.Id.configure_notification_channels) != null) { FindViewById(Resource.Id.configure_notification_channels).Click += (sender, args) => { Intent intent = new Intent(Settings.ActionChannelNotificationSettings); intent.PutExtra(Settings.ExtraChannelId, App.NotificationChannelIdQuicklocked); intent.PutExtra(Settings.ExtraAppPackage, PackageName); try { StartActivity(intent); } catch (Exception e) { new AlertDialog.Builder(this) .SetTitle("Unexpected error") .SetMessage( "Opening the settings failed. Please report this to [email protected] including information about your device vendor and OS. Please try to configure the notifications by long pressing a KP2A notification. Details: " + e.ToString()) .Show(); } UpdateAndroid8NotificationInfo(true); }; FindViewById(Resource.Id.ignore_notification_channel).Click += (sender, args) => { UpdateAndroid8NotificationInfo(true); }; } string lastInfoText; if (IsTimeForInfotext(out lastInfoText)) { FingerprintUnlockMode um; Enum.TryParse(_prefs.GetString(Database.GetFingerprintModePrefKey(App.Kp2a.GetDb().Ioc), ""), out um); bool isFingerprintEnabled = (um == FingerprintUnlockMode.FullUnlock); string masterKeyKey = "MasterKey" + isFingerprintEnabled; string emergencyKey = "Emergency"; string backupKey = "Backup"; List <string> applicableInfoTextKeys = new List <string> { masterKeyKey }; if (App.Kp2a.GetFileStorage(App.Kp2a.GetDb().Ioc).UserShouldBackup) { applicableInfoTextKeys.Add(backupKey); } if (App.Kp2a.GetDb().Entries.Count > 15) { applicableInfoTextKeys.Add(emergencyKey); } List <string> enabledInfoTextKeys = new List <string>(); foreach (string key in applicableInfoTextKeys) { if (!InfoTextWasDisabled(key)) { enabledInfoTextKeys.Add(key); } } if (enabledInfoTextKeys.Any()) { string infoTextKey = "", infoHead = "", infoMain = "", infoNote = ""; if (enabledInfoTextKeys.Count > 1) { foreach (string key in enabledInfoTextKeys) { if (key == lastInfoText) { enabledInfoTextKeys.Remove(key); break; } } infoTextKey = enabledInfoTextKeys[new Random().Next(enabledInfoTextKeys.Count)]; } if (infoTextKey == masterKeyKey) { infoHead = GetString(Resource.String.masterkey_infotext_head); infoMain = GetString(Resource.String.masterkey_infotext_main); if (isFingerprintEnabled) { infoNote = GetString(Resource.String.masterkey_infotext_fingerprint_note); } } else if (infoTextKey == emergencyKey) { infoHead = GetString(Resource.String.emergency_infotext_head); infoMain = GetString(Resource.String.emergency_infotext_main); } else if (infoTextKey == backupKey) { infoHead = GetString(Resource.String.backup_infotext_head); infoMain = GetString(Resource.String.backup_infotext_main); infoNote = GetString(Resource.String.backup_infotext_note, GetString(Resource.String.menu_app_settings), GetString(Resource.String.menu_db_settings), GetString(Resource.String.export_prefs)); } FindViewById <TextView>(Resource.Id.info_head).Text = infoHead; FindViewById <TextView>(Resource.Id.info_main).Text = infoMain; var additionalInfoText = FindViewById <TextView>(Resource.Id.info_additional); additionalInfoText.Text = infoNote; additionalInfoText.Visibility = string.IsNullOrEmpty(infoNote) ? ViewStates.Gone : ViewStates.Visible; if (infoTextKey != "") { RegisterInfoTextDisplay(infoTextKey); FindViewById(Resource.Id.info_ok).Click += (sender, args) => { UpdateBottomBarElementVisibility(Resource.Id.infotext, false); }; FindViewById(Resource.Id.info_dont_show_again).Click += (sender, args) => { UpdateBottomBarElementVisibility(Resource.Id.infotext, false); DisableInfoTextDisplay(infoTextKey); }; UpdateBottomBarElementVisibility(Resource.Id.infotext, true); } } } SetResult(KeePass.ExitNormal); }
protected override void OnCreate(Bundle savedInstanceState) { _design.ApplyTheme(); base.OnCreate(savedInstanceState); Android.Util.Log.Debug("KP2A", "Creating GBA"); AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent); // Likely the app has been killed exit the activity if (!App.Kp2a.GetDb().Loaded) { Finish(); return; } _prefs = PreferenceManager.GetDefaultSharedPreferences(this); SetContentView(ContentResourceId); if (FindViewById(Resource.Id.enable_autofill) != null) { FindViewById(Resource.Id.enable_autofill).Click += (sender, args) => { var intent = new Intent(Settings.ActionRequestSetAutofillService); intent.SetData(Android.Net.Uri.Parse("package:" + PackageName)); StartActivity(intent); }; } if (FindViewById(Resource.Id.fabCancelAddNew) != null) { FindViewById(Resource.Id.fabAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Visible; FindViewById(Resource.Id.fabAddNewGroup).Visibility = AddGroupEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = AddEntryEnabled ? ViewStates.Visible : ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Gone; }; FindViewById(Resource.Id.fabCancelAddNew).Click += (sender, args) => { FindViewById(Resource.Id.fabCancelAddNew).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewGroup).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNewEntry).Visibility = ViewStates.Gone; FindViewById(Resource.Id.fabAddNew).Visibility = ViewStates.Visible; }; } if (FindViewById(Resource.Id.cancel_insert_element) != null) { FindViewById(Resource.Id.cancel_insert_element).Click += (sender, args) => StopMovingElements(); FindViewById(Resource.Id.insert_element).Click += (sender, args) => InsertElements(); Util.MoveBottomBarButtons(Resource.Id.cancel_insert_element, Resource.Id.insert_element, Resource.Id.bottom_bar, this); } if (FindViewById(Resource.Id.show_autofill_info) != null) { FindViewById(Resource.Id.show_autofill_info).Click += (sender, args) => Util.GotoUrl(this, "https://philippc.github.io/keepass2android/OreoAutoFill.html"); Util.MoveBottomBarButtons(Resource.Id.show_autofill_info, Resource.Id.enable_autofill, Resource.Id.autofill_buttons, this); } SetResult(KeePass.ExitNormal); }
private void Query(string url, bool autoReturnFromQuery) { try { Group = GetSearchResultsForUrl(url); } catch (Exception e) { Toast.MakeText(this, e.Message, ToastLength.Long).Show(); SetResult(Result.Canceled); Finish(); return; } //if there is exactly one match: open the entry if ((Group.Entries.Count() == 1) && autoReturnFromQuery && PreferenceManager.GetDefaultSharedPreferences(this).GetBoolean(GetString(Resource.String.AutoReturnFromQuery_key), true)) { LaunchActivityForEntry(Group.Entries.Single(), 0); return; } //show results: if (Group == null || (!Group.Entries.Any())) { SetContentView(Resource.Layout.searchurlresults_empty); } SetGroupTitle(); FragmentManager.FindFragmentById <GroupListFragment>(Resource.Id.list_fragment).ListAdapter = new PwGroupListAdapter(this, Group); View selectOtherEntry = FindViewById(Resource.Id.select_other_entry); var newTask = new SearchUrlTask() { AutoReturnFromQuery = false, UrlToSearchFor = url }; if (AppTask is SelectEntryTask currentSelectTask) { newTask.ShowUserNotifications = currentSelectTask.ShowUserNotifications; } selectOtherEntry.Click += (sender, e) => { GroupActivity.Launch(this, newTask, new ActivityLaunchModeRequestCode(0)); }; View createUrlEntry = FindViewById(Resource.Id.add_url_entry); if (App.Kp2a.OpenDatabases.Any(db => db.CanWrite)) { createUrlEntry.Visibility = ViewStates.Visible; createUrlEntry.Click += (sender, e) => { GroupActivity.Launch(this, new CreateEntryThenCloseTask { Url = url, ShowUserNotifications = (AppTask as SelectEntryTask)?.ShowUserNotifications ?? ShowUserNotificationsMode.Always }, new ActivityLaunchModeRequestCode(0)); Toast.MakeText(this, GetString(Resource.String.select_group_then_add, new Java.Lang.Object[] { GetString(Resource.String.add_entry) }), ToastLength.Long).Show(); }; } else { createUrlEntry.Visibility = ViewStates.Gone; } Util.MoveBottomBarButtons(Resource.Id.select_other_entry, Resource.Id.add_url_entry, Resource.Id.bottom_bar, this); }