public static void Launch(Activity act, SearchUrlTask task) { Intent i = new Intent(act, typeof(ShareUrlResults)); task.ToIntent(i); act.StartActivityForResult(i, 0); }
public static void Launch(Activity act, SearchUrlTask task, ActivityLaunchMode launchMode) { Intent i = new Intent(act, typeof(ShareUrlResults)); task.ToIntent(i); launchMode.Launch(act, i); }
private void StartQuery() { //launch SelectCurrentDbActivity (which is root of the stack (exception: we're even below!)) with the appropriate task. //will return the results later Intent i = new Intent(this, typeof (SelectCurrentDbActivity)); //don't show user notifications when an entry is opened. var task = new SearchUrlTask() {UrlToSearchFor = _requestedUrl, ShowUserNotifications = ShowUserNotificationsMode.WhenTotp}; task.ToIntent(i); StartActivityForResult(i, RequestCodeQuery); _startedQuery = true; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); SetContentView(Resource.Layout.open_db_selection); var toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.mytoolbar); SetSupportActionBar(toolbar); SupportActionBar.Title = GetString(Resource.String.select_database); //only load the AppTask if this is the "first" OnCreate (not because of kill/resume, i.e. savedInstanceState==null) // and if the activity is not launched from history (i.e. recent tasks) because this would mean that // the Activity was closed already (user cancelling the task or task complete) but is restarted due recent tasks. // Don't re-start the task (especially bad if tak was complete already) if (Intent.Flags.HasFlag(ActivityFlags.LaunchedFromHistory)) { AppTask = new NullTask(); } else { AppTask = AppTask.GetTaskInOnCreate(savedInstanceState, Intent); } _adapter = new OpenDatabaseAdapter(this); var gridView = FindViewById <GridView>(Resource.Id.gridview); gridView.Adapter = _adapter; if (!string.IsNullOrEmpty(Intent.GetStringExtra(Util.KeyFilename))) { //forward to password activity Intent i = new Intent(this, typeof(PasswordActivity)); IOConnectionInfo ioc = new IOConnectionInfo(); Util.SetIoConnectionFromIntent(ioc, Intent); Util.PutIoConnectionToIntent(ioc, i); i.PutExtra(PasswordActivity.KeyKeyfile, i.GetStringExtra(PasswordActivity.KeyKeyfile)); i.PutExtra(PasswordActivity.KeyPassword, i.GetStringExtra(PasswordActivity.KeyPassword)); LaunchingOther = true; StartActivityForResult(i, ReqCodeOpenNewDb); } else { if (Intent.Action == Intent.ActionView) { GetIocFromViewIntent(Intent); } else if (Intent.Action == Intent.ActionSend) { AppTask = new SearchUrlTask { UrlToSearchFor = Intent.GetStringExtra(Intent.ExtraText) }; } } _intentReceiver = new MyBroadcastReceiver(this); IntentFilter filter = new IntentFilter(); filter.AddAction(Intents.DatabaseLocked); RegisterReceiver(_intentReceiver, filter); }
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); }
private void StartQuery() { //launch FileSelectActivity (which is root of the stack (exception: we're even below!)) with the appropriate task. //will return the results later Intent i = new Intent(this, typeof (FileSelectActivity)); //don't show user notifications when an entry is opened. var task = new SearchUrlTask() {UrlToSearchFor = _requestedUrl, ShowUserNotifications = false}; task.ToIntent(i); StartActivityForResult(i, RequestCodeQuery); _startedQuery = true; }