protected override void OnCreate(Bundle savedInstanceState) { new ActivityDesign(this).ApplyTheme(); base.OnCreate(savedInstanceState); ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(this); App.Kp2a.AskYesNoCancel(UiStringKey.ActivateAutoFillService_title, UiStringKey.ActivateAutoFillService_message, UiStringKey.ActivateAutoFillService_btnKeyboard, UiStringKey.ActivateAutoFillService_btnAutoFill, delegate { //yes CopyToClipboardService.ActivateKeyboard(this); Finish(); }, delegate { //no Intent intent = new Intent(Android.Provider.Settings.ActionAccessibilitySettings); StartActivity(intent); prefs.Edit().PutBoolean(GetString(Resource.String.OpenKp2aKeyboardAutomatically_key), false).Commit(); Toast.MakeText(this, Resource.String.ActivateAutoFillService_toast, ToastLength.Long).Show(); Finish(); }, delegate { //cancel Finish(); }, (sender, args) => Finish() //dismiss , this); }
protected override void OnStart() { base.OnStart(); if (PreferenceManager.GetDefaultSharedPreferences(this) .GetBoolean(GetString(Resource.String.UseKp2aKeyboardInKp2a_key), false)) { CopyToClipboardService.ActivateKeyboard(this); } }
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); } }