public override void OnReceive(Context context, Intent intent)
        {
            String action = intent.Action;

            //check if we have a last opened entry
            //this should always be non-null, but if the OS has killed the app, it might occur.
            if (App.Kp2a.LastOpenedEntry == null)
            {
                Intent i = new Intent(context, typeof(AppKilledInfo));
                i.SetFlags(ActivityFlags.ClearTask | ActivityFlags.NewTask | ActivityFlags.ExcludeFromRecents);
                context.StartActivity(i);
                return;
            }

            if (action.Equals(Intents.CopyUsername))
            {
                String username = App.Kp2a.LastOpenedEntry.OutputStrings.ReadSafe(PwDefs.UserNameField);
                if (username.Length > 0)
                {
                    CopyToClipboardService.CopyValueToClipboardWithTimeout(context, username);
                }
                context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
            }
            else if (action.Equals(Intents.CopyPassword))
            {
                String password = App.Kp2a.LastOpenedEntry.OutputStrings.ReadSafe(PwDefs.PasswordField);
                if (password.Length > 0)
                {
                    CopyToClipboardService.CopyValueToClipboardWithTimeout(context, password);
                }
                context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
            }
            else if (action.Equals(Intents.CopyTotp))
            {
                String totp = App.Kp2a.LastOpenedEntry.OutputStrings.ReadSafe(UpdateTotpTimerTask.TotpKey);
                if (totp.Length > 0)
                {
                    CopyToClipboardService.CopyValueToClipboardWithTimeout(context, totp);
                }
                context.SendBroadcast(new Intent(Intent.ActionCloseSystemDialogs)); //close notification drawer
            }
            else if (action.Equals(Intents.CheckKeyboard))
            {
                CopyToClipboardService.ActivateKeyboard(context);
            }
        }
Example #2
0
 public void HandleClick()
 {
     CopyToClipboardService.CopyValueToClipboardWithTimeout(_context, _stringView.Text);
 }