Пример #1
0
        private void OnContactUsLongClicked(object sender, View.LongClickEventArgs e)
        {
            Android.Content.ClipboardManager clipboard = (Android.Content.ClipboardManager)GetSystemService(ClipboardService);
            ClipData clip = ClipData.NewPlainText("label", "*****@*****.**");

            clipboard.PrimaryClip = clip;

            Toast.MakeText(this, Resources.GetString(Resource.String.EmailCopiedLabel), ToastLength.Short).Show();
        }
Пример #2
0
        public static String GetClipboard(Context context)
        {
            Android.Content.ClipboardManager clipboardManager = (ClipboardManager)context.GetSystemService(Context.ClipboardService);
            var clip = clipboardManager.PrimaryClip;

            if (clip != null && clip.ItemCount > 0)
            {
                return(clip.GetItemAt(0).CoerceToText(context));
            }
            return("");
        }
Пример #3
0
        public static void CopyToClipboard(Context context, String text)
        {
            Android.Content.ClipboardManager clipboardManager = (ClipboardManager)context.GetSystemService(Context.ClipboardService);
            if (text == "")
            {
                text = "***";
            }
            ClipData clipData = Android.Content.ClipData.NewPlainText("KP2A", text);

            clipboardManager.PrimaryClip = clipData;
        }
Пример #4
0
 public static void CopyToClipboard(Context context, string text)
 {
     // if()
     if (Build.VERSION.SdkInt < BuildVersionCodes.Honeycomb)
     {
         Android.Text.ClipboardManager clipboard = (Android.Text.ClipboardManager)context.GetSystemService(Context.ClipboardService);
         clipboard.Text = text;
     }
     else
     {
         Android.Content.ClipboardManager clipboard = (Android.Content.ClipboardManager)context.GetSystemService(Context.ClipboardService);
         clipboard.PrimaryClip = ClipData.NewPlainText(null, text);
     }
 }
Пример #5
0
        public static void CopyToClipboard(Context context, String text)
        {
            Android.Content.ClipboardManager clipboardManager = (ClipboardManager)context.GetSystemService(Context.ClipboardService);
            ClipData clipData = Android.Content.ClipData.NewPlainText("KP2A", text);

            clipboardManager.PrimaryClip = clipData;
            if (text == "")
            {
                //on some devices, adding empty text does not seem to work. Try again with some garbage.
                clipData = Android.Content.ClipData.NewPlainText("KP2A", "***");
                clipboardManager.PrimaryClip = clipData;
                //seems to work better on some devices:
                try
                {
                    clipboardManager.Text = text;
                }
                catch (Exception exception)
                {
                    Kp2aLog.LogUnexpectedError(exception);
                }
            }
        }
Пример #6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(R.Layout.Main);
            btnKopyala  = FindViewById <Button>(R.Id.btnKopyala);
            btnYapistir = FindViewById <Button>(R.Id.btnYapistir);
            etKopyala   = FindViewById <EditText>(R.Id.etKopyala);
            etYapistir  = FindViewById <EditText>(R.Id.etYapistir);

            panoYoneticisi = (Android.Content.ClipboardManager)GetSystemService(ClipboardService);

            btnKopyala.Click += delegate
            {
                if (string.IsNullOrEmpty(etKopyala.Text))
                {
                    Toast.MakeText(this, "Kopyalanacak metin giriniz!", ToastLength.Short).Show();
                }
                else
                {
                    var clip = ClipData.NewPlainText("kopyala", etKopyala.Text);
                    panoYoneticisi.PrimaryClip = clip;
                    Toast.MakeText(this, "Metin kopyalandı!", ToastLength.Short).Show();
                }
            };

            btnYapistir.Click += delegate
            {
                if (!panoYoneticisi.HasPrimaryClip)
                {
                    Toast.MakeText(this, "Yapıştırılacak metin bulunamadı!", ToastLength.Short).Show();
                }
                else
                {
                    var clip = panoYoneticisi.PrimaryClip;
                    etYapistir.Text = clip.GetItemAt(0).Text;
                }
            };
        }
Пример #7
0
        private void OnContactUsClicked(object sender, EventArgs e)
        {
            var emailIntent = new Intent(Intent.ActionSend);

            // The intent does not have a URI, so declare the "text/plain" MIME type
            emailIntent.SetType("vnd.android.cursor.dir/email");
            emailIntent.PutExtra(Intent.ExtraEmail, new[] { "*****@*****.**" }); // recipients
            emailIntent.PutExtra(Intent.ExtraSubject, "Message from BibleWords game");
            emailIntent.PutExtra(Intent.ExtraText, string.Empty);

            try
            {
                StartActivityForResult(emailIntent, _emailRequestCode);
            }
            catch (Exception ex)
            {
                Android.Content.ClipboardManager clipboard = (Android.Content.ClipboardManager)GetSystemService(ClipboardService);
                ClipData clip = ClipData.NewPlainText("label", "*****@*****.**");
                clipboard.PrimaryClip = clip;

                Toast.MakeText(this, Resources.GetString(Resource.String.EmailCopiedLabel), ToastLength.Short).Show();
            }
        }
Пример #8
0
        /// <summary>
        /// Append rows to the table grid
        /// @param table The layout to add the rows to
        /// </summary>
        /// <param name="aTable">if set to <c>true</c> it is [a table] and false if it is a view</param>
        private void newAppendRows(bool aTable)
        {
            _aTable.RemoveAllViews();
            if (_data == null)
            {
                return;
            }
            int rowSize = _data.Length;

            if (rowSize == 0)
            {
                return;
            }
            int colSize = _data[0].getFields().Length;

            //Go through all the rows of data
            for (int i = 0; i < rowSize; i++)
            {
                int      rowNo = i;
                TableRow row   = new TableRow(this);
                //Make every second row dark gray
                if (i % 2 == 1)
                {
                    row.SetBackgroundColor(Color.DarkGray);
                }
                //Go through all the columns
                for (int j = 0; j < colSize; j++)
                {
                    if (!aTable || j > 0)
                    {
                        TextView c = new TextView(this);
                        c.TextSize = _fontSize;
                        if (_maxWidth > 0)
                        {
                            c.SetMaxWidth(_maxWidth);
                        }
                        if (aTable)
                        {
                            c.Text = _data[i].getFields()[j].getFieldData();
                        }
                        else
                        {
                            c.Text = _data[i].getFields()[j].getFieldData();
                        }
                        c.SetBackgroundColor(getBackgroundColor(_data[i].getFields()[j].getFieldType(), (i % 2 == 1)));
                        c.SetPadding(5, 5, 5, 5);
                        // Adding a onClickListener to copy cell value to clip board
                        //ToDo: if the field is a BLOB field make it possible to retrieve / change it
                        c.Click += (sender, e) =>
                        {
                            // if the field is not a BLOB field copy it to the clip board
                            string            text = c.Text;
                            BuildVersionCodes currentapiVersion = Android.OS.Build.VERSION.SdkInt;

                            try
                            {
                                if (currentapiVersion >= BuildVersionCodes.Honeycomb)
                                { // HONEYCOMB
                                    Android.Content.ClipboardManager clipboard = (Android.Content.ClipboardManager)GetSystemService(ClipboardService);
                                    ClipData clip = ClipData.NewPlainText("simple text", text);
                                    clipboard.PrimaryClip = clip;
                                }
                                else
                                {
                                    Android.Text.ClipboardManager clipboard = (Android.Text.ClipboardManager)GetSystemService(ClipboardService);
                                    clipboard.Text = text;
                                }
                                ExceptionHandler.toastMsg(_cont, GetText(Resource.String.CopiedToClipboard));
                            }
                            catch (Exception ex)
                            {
                                ExceptionHandler.toastMsg(this, ex.Message);
                                ExceptionHandler.logDActivity(ex.ToString(), _logging, TAG);
                            }
                        };
                        row.AddView(c);
                    }
                    // Add a cell with "Select"
                    if (j == colSize - 1 &&
                        (aTable || (_canInsertInView || _canUpdateView || _canDeleteView)))
                    {
                        TextView c = addSelectField(rowNo, aTable);
                        row.AddView(c);
                    }
                }
                _trLastRow = row;
                _aTable.AddView(row, new TableLayout.LayoutParams());
            }
        }