void BuildPickSyllableTaskItems(List <PickSyllableOption> currentOptions) { var syllableAdapter = new PickSyllableAdapter(Activity.BaseContext, 0, currentOptions); llTaskItems.RemoveAllViews(); for (int i = 0; i < syllableAdapter.Count; i++) { var view = syllableAdapter.GetView(i, null, null); var item = currentOptions.ElementAt(i); var index = currentOptions.IndexOf(item); view.Touch += (sender, e) => { if (isSoundPlayedForSelectedItem == false) { imageClickedForSound(item); isSoundPlayedForSelectedItem = true; } using (var data = ClipData.NewPlainText("position", index.ToString())) { view.StartDrag(data, new View.DragShadowBuilder(view), null, 0); } }; llTaskItems.AddView(view); } }
public void CopyClipBoard(string text) { var clipboard = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService); var clip = ClipData.NewPlainText("Wifi Password", text); clipboard.PrimaryClip = clip; }
public void CopyText(string text) { ClipboardManager clipboard = (ClipboardManager)Application.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(text, text); clipboard.PrimaryClip = clip; }
public void CopyToClipboard(string content) { var clipboardManager = (ClipboardManager)Xamarin.Forms.Forms.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText("Android Clipboard", content); clipboardManager.PrimaryClip = clip; }
/// #endregion /// ------------------------------------------------------------------------------------------------ /// ------------------------------------------------------------------------------------------------ #region Protected Functions protected override void OnElementChanged(ElementChangedEventArgs <TableView> e) { try { base.OnElementChanged(e); Items = AppData.PropertyModel.SelectedAction.Action.Paragraphs; Control.ItemLongClick += (s, args) => { ClipData data = ClipData.NewPlainText("List", args.Position.ToString()); if (VisitActionDetailsPage.CurrentInstance.IsEditable) { if (VisitActionDetailsPage.CurrentInstance.SingleTypeCode != null) { if (!VisitActionDetailsPage.CurrentInstance.SingleTypeCode.Contains(Items[args.Position - 1].ParagraphType)) { CustomDragShadowBuilder myShadownScreen = new CustomDragShadowBuilder(args.View); args.View.StartDrag(data, myShadownScreen, null, 0); } } } }; } catch (Exception ex) { LogTracking.LogTrace(ex.ToString()); } }
protected override async void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); StatusBarUtil.SetColorStatusBars(this); SetContentView(Resource.Layout.SplashScreen); var tokenTemp = AccessTokenUtil.GetToken(this); ClipboardManager cm = (ClipboardManager)GetSystemService(Context.ClipboardService); ClipData cldata = ClipData.NewPlainText("label", "cnblogs.com"); cm.PrimaryClip = cldata; if (string.IsNullOrEmpty(tokenTemp.access_token) || tokenTemp.IsExpire) { await AuthorizationRequest.Client_Credentials((token) => { token.RefreshTime = DateTime.Now; AccessTokenUtil.SaveToken(token, this); }, error => { System.Diagnostics.Debug.Write(error); }); } Handler handler = new Handler(); handler.PostDelayed((() => { StartActivity(new Intent(this, typeof(MainActivity))); this.Finish(); }), 2000); // Create your application here }
public override void OnActivityCreated(Bundle savedInstanceState) { base.OnActivityCreated(savedInstanceState); //Current position should survive screen rotations. if (savedInstanceState != null) { mCategory = savedInstanceState.GetInt("category"); mCurPosition = savedInstanceState.GetInt("listPosition"); } PopulateTitles(mCategory); ListView lv = ListView; lv.ChoiceMode = ChoiceMode.Single; lv.CacheColorHint = Color.Transparent; lv.ItemLongClick += (o, e) => { String title = (String)((TextView)e.View).Text; // Set up clip data with the category||entry_id format. String textData = String.Format("{0}||{1}", mCategory, e.Position); ClipData data = ClipData.NewPlainText(title, textData); e.View.StartDrag(data, new MyDragShadowBuilder(e.View), null, 0); }; SelectPosition(mCurPosition); }
private void mostrarDueno(Usuario owner, Mascota m) { AlertDialog.Builder alert = new AlertDialog.Builder(this); alert.SetTitle(m.nombre + " fue adopado!"); string men = "Informacion de contacto\n"; men += "Nombre:\n" + owner.nombre + "\n"; men += "Telefono:\n" + owner.cel + "\n"; men += "Email:\n" + owner.email; alert.SetMessage(men); alert.SetPositiveButton("Aceptar", (senderAlert, args) => { // do nothing }); alert.SetNeutralButton("Copiar Telefono", delegate { // Create intent to dial phone ClipboardManager clipboard = (ClipboardManager)GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(owner.cel, owner.cel); clipboard.PrimaryClip = clip; }); alert.SetNegativeButton("Copiar Email", delegate { // Create intent to dial phone ClipboardManager clipboard = (ClipboardManager)GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(owner.cel, owner.email); clipboard.PrimaryClip = clip; }); Dialog dialog = alert.Create(); dialog.Show(); }
public static void SetText(string text) { var clipboardmanager = (ClipboardManager)Application.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText("text", text); clipboardmanager.PrimaryClip = clip; }
public void SetText(string text) { var clipboard = (ClipboardManager)Application.Context.GetSystemService(Context.ClipboardService); var clip = ClipData.NewPlainText(string.Empty, text); clipboard.PrimaryClip = clip; }
private void copyToClipboard(Context context, string copiedText) { ClipboardManager clipboard = (ClipboardManager)context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(copiedText, copiedText); clipboard.PrimaryClip = clip; }
public void copy(string copyText) { ClipboardManager clipboard = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText("TLExtension", copyText); clipboard.PrimaryClip = clip; }
internal static async void CopyTextToClipboard(Context context, Guid guid) { await DataStorageProviders.HistoryManager.OpenAsync(); var item = DataStorageProviders.HistoryManager.GetItem(guid); DataStorageProviders.HistoryManager.Close(); if (!(item.Data is ReceivedText)) { throw new Exception("Invalid received item type."); } await DataStorageProviders.TextReceiveContentManager.OpenAsync(); string text = DataStorageProviders.TextReceiveContentManager.GetItemContent(guid); DataStorageProviders.TextReceiveContentManager.Close(); Handler handler = new Handler(Looper.MainLooper); handler.Post(() => { ClipboardManager clipboard = (ClipboardManager)context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(text, text); clipboard.PrimaryClip = clip; }); ShowToast(context, "Text copied to clipboard.", ToastLength.Long); Finish?.Invoke(); }
private void Copy_Click(object sender, EventArgs e) { var manager = (ClipboardManager)GetSystemService(ClipboardService); var result = FindViewById <TextView>(Resource.Id.textViewPasswordResult); manager.PrimaryClip = ClipData.NewPlainText("Generated password", result.Text); }
void ConceptView_Touch_StartDrag(object sender, EventArgs e) { var v = sender as View; var motionEvent = (e as View.TouchEventArgs).Event; switch (motionEvent.Action & MotionEventActions.Mask) { case MotionEventActions.Down: touchDownX = motionEvent.RawX; touchDownY = motionEvent.RawY; break; case MotionEventActions.Move: float deltaX = motionEvent.RawX - touchDownX; float deltaY = motionEvent.RawY - touchDownY; int touchSlop = ViewConfiguration.Get(v.Context).ScaledTouchSlop / 4; if (Math.Abs(deltaX) > touchSlop || Math.Abs(deltaY) > touchSlop) { v.StartDrag(ClipData.NewPlainText("", ""), new View.DragShadowBuilder(v), v, 0); } break; case MotionEventActions.Up: if (!dragActionStartedHandled) { v.PerformClick(); } break; default: break; } }
public bool OnItemLongClick(AWidget.AdapterView parent, AViews.View view, int position, long id) { object selectedItem = null; //if (_element.ItemsSource.GetType().GetInterfaces().Any(x => x == typeof(IGroupedOrderable))) if (element.ItemsSource is IGroupedOrderableCollection grouped) { selectedItem = grouped.GetItemFromFlatIndex(id); } else { selectedItem = ((IList)element.ItemsSource)[(int)id]; } // Creating drag state DragItem dragItem = new DragItem(NormalizeListPosition(position), view, selectedItem); // Creating a blank clip data object (we won't depend on this) var data = ClipData.NewPlainText(string.Empty, string.Empty); // Creating the default drag shadow for the item (the translucent version of the view) // NOTE: Can create a custom view in order to change the dragged item view AViews.View.DragShadowBuilder shadowBuilder = new AViews.View.DragShadowBuilder(view); // Setting the original view cell to be invisible view.Visibility = AViews.ViewStates.Invisible; // NOTE: this method is introduced in Android 24, for earlier versions the StartDrag method should be used view.StartDragAndDrop(data, shadowBuilder, dragItem, 0); return(true); }
public void Copy(string title, string target) { ClipboardManager clipboard = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(target, target); clipboard.PrimaryClip = clip; }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Xamarin.Essentials.Platform.Init(this, savedInstanceState); SetContentView(Resource.Layout.activity_main); var btnCopy = FindViewById <Button>(Resource.Id.btn_copy); var btnPaste = FindViewById <Button>(Resource.Id.btn_paste); var txtCopy = FindViewById <EditText>(Resource.Id.txt_copy); var txtPaste = FindViewById <TextView> (Resource.Id.txt_paste); clipboardManager = (ClipboardManager)GetSystemService(ClipboardService); btnCopy.Click += delegate { var copyText = txtCopy.Text; clipData = ClipData.NewPlainText("text", copyText); clipboardManager.PrimaryClip = clipData; Toast.MakeText(this, Resource.String.msg_copy_text, ToastLength.Short).Show(); }; btnPaste.Click += delegate { ClipData.Item item = clipboardManager.PrimaryClip.GetItemAt(0); txtPaste.Text = item.Text; Toast.MakeText(this, Resource.String.msg_paste_text, ToastLength.Short).Show(); }; }
protected override void OnHandleIntent(Intent intent) { if (intent.Action == "CloudClipboardCopy") { var settings = new Classes.Settings(this); var text = settings.CloudClipboardText; Handler handler = new Handler(Looper.MainLooper); handler.Post(() => { try { ClipboardManager clipboard = (ClipboardManager)GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText(text, text); clipboard.PrimaryClip = clip; Toast.MakeText(this, "Copied", ToastLength.Short).Show(); } catch (Exception ex) { Log.Debug("CloudClipboardService", ex.Message); } }); } }
//Calls BuildDialog(object sender) private void BuildExerciseActivity_LongClick(object sender, Android.Views.View.LongClickEventArgs e) { CurrMyButton = (MyButton)sender; var data = ClipData.NewPlainText("name", CurrMyButton.Text); CurrMyButton.StartDrag(data, new View.DragShadowBuilder(CurrMyButton), null, 0); }
public void CopyToClipBoard(string str) { var clipboardManager = (ClipboardManager)Android.App.Application.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText("", str); clipboardManager.PrimaryClip = clip; }
public void CopyToClipboard(string value) { ClipboardManager clipboard = (ClipboardManager)FormContext.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText("Clipboard", value); clipboard.PrimaryClip = clip; }
private void Button20_Click(object sender, EventArgs e) { var clipboard = (ClipboardManager)GetSystemService(ClipboardService); var clip = ClipData.NewPlainText(" ", button20.Text); clipboard.PrimaryClip = clip; }
public void Copy(string text) { ClipboardManager clipboardManager = (ClipboardManager)Forms.Context.GetSystemService(Context.ClipboardService); ClipData clip = ClipData.NewPlainText("Clipboard", text); clipboardManager.PrimaryClip = clip; }
#pragma warning disable CS0618 private void rowLongClick(object sender, View.LongClickEventArgs e) { ClipData data = ClipData.NewPlainText("", ""); View.DragShadowBuilder shadowBuilder = new View.DragShadowBuilder(((View)sender)); ((View)sender).StartDrag(data, shadowBuilder, (View)sender, 0); }
protected void CopyToClipboard(string copyValue) { ClipboardManager mgr = (ClipboardManager)GetSystemService(Context.ClipboardService); ClipData data = ClipData.NewPlainText("hash", copyValue); mgr.PrimaryClip = data; }
public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) { var view = base.OnCreateView(inflater, container, savedInstanceState); SetupToolbar(view, Resource.String.qrCode, true); _progressBar = view.FindViewById <ProgressBar>(Resource.Id.appBarProgressBar); _image = view.FindViewById <ImageView>(Resource.Id.imageQrCode); var okButton = view.FindViewById <MaterialButton>(Resource.Id.buttonOk); okButton.Click += delegate { Dismiss(); }; var copyButton = view.FindViewById <MaterialButton>(Resource.Id.buttonCopyUri); copyButton.Click += delegate { var clipboard = (ClipboardManager)Context.GetSystemService(Context.ClipboardService); var clip = ClipData.NewPlainText("uri", _uri); clipboard.PrimaryClip = clip; Toast.MakeText(Context, Resource.String.uriCopiedToClipboard, ToastLength.Short).Show(); }; return(view); }
/// <summary> /// Sets text of the clipboard /// </summary> /// <param name="text">Text to set</param> /// <param name="label">Label to display (not required, Android only)</param> /// <returns>True if the operation was successful, false otherwise</returns> public Task <bool> SetClipboardText(string text, string label = null) { try { var sdk = (int)Android.OS.Build.VERSION.SdkInt; switch (sdk) { case < (int)Android.OS.BuildVersionCodes.Honeycomb: { var clipboard = (ClipboardManager)Application.Context.GetSystemService(Context.ClipboardService); clipboard.Text = text; break; } default: { var clipboard = (ClipboardManager)Application.Context.GetSystemService(Context.ClipboardService); clipboard.PrimaryClip = ClipData.NewPlainText(label ?? string.Empty, text); break; } } return(Task.FromResult(true)); } catch (Exception ex) { Console.WriteLine("Unable to copy to clipboard: " + ex.Message); return(Task.FromResult(false)); } }
public bool OnLongClick(View v) { var item = new ClipData.Item(v.Tag.JavaCast <Java.Lang.String>()); var mimeTypes = new String[1]; ClipData data = null; if (v is ImageView) { // image item only drags WITHIN THE APP mimeTypes[0] = "image/jpeg"; data = new ClipData(v.Tag.JavaCast <Java.Lang.String>().ToString(), mimeTypes, item); // TODO: allow image to drag to other apps } else if (v is TextView) { // use plain text, can drag outside the app data = ClipData.NewPlainText( new Java.Lang.String(v.Tag.ToString()), new Java.Lang.String((v as TextView).Text) ); } var dragShadowBuilder = new View.DragShadowBuilder(v); // flags required to drag to other apps v.StartDragAndDrop(data, dragShadowBuilder, v, (int)ADragFlags.Global | (int)ADragFlags.GlobalUriRead | (int)ADragFlags.GlobalUriWrite); return(true); }
private void BuildOptions(List <AbcRankOption> currentOptions) { // Shuffle options currentOptions.Shuffle(); // Add options to view flOptions.RemoveAllViews(); var adapter = new AbcRankAdapter(Activity.BaseContext, 0, currentOptions); for (var i = 0; i < currentOptions.Count; i++) { var view = adapter.GetView(i, null, null); var item = currentOptions.ElementAt(i); // Play sound if item has a media element that gets touched if (item.Media != null) { view.Touch += (sender, e) => { SoundPlayer.PlaySound(Activity.BaseContext, item.Media.SoundPath); }; } // Add drag view.Touch += (sender, e) => { var data = ClipData.NewPlainText("letter", item.Name); (sender as View).StartDrag(data, new View.DragShadowBuilder(sender as View), null, 0); }; flOptions.AddView(view); } }