public void TestToNumberWithMissingAlpha()
        {
            var number = PhoneTranslator.ToNumber("***##");

            Assert.AreEqual("", number);
            Assert.AreEqual(0, number.Length);
        }
        public void TestToNumberWithJustAlpha()
        {
            var number = "DEADBEEF";
            var len    = number.Length;

            number = PhoneTranslator.ToNumber(number);
            Assert.AreEqual("33232333", number);
            Assert.AreEqual(len, number.Length);
        }
Esempio n. 3
0
 private void BtnTranslate_TouchUpInside(object sender, EventArgs e)
 {
     lsTranslatedNumber = PhoneTranslator.ToNumber(txtPhoneword.Text);
     txtPhoneword.ResignFirstResponder();
     if (lsTranslatedNumber == "")
     {
         btnCall.SetTitle("Call", UIControlState.Normal);
         btnCall.Enabled = false;
     }
     else
     {
         btnCall.SetTitle("Call " + lsTranslatedNumber, UIControlState.Normal);
         btnCall.Enabled = true;
     }
 }
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            string translateNumber = "";

            TranslateButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                translateNumber = PhoneTranslator.ToNumber(PhoneNumberText.Text);

                PhoneNumberText.ResignFirstResponder();
                if (translateNumber == "")
                {
                    CallButton.SetTitle("Call ", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translateNumber,
                                        UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            CallButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // Use URL handler with tel: prefix to invoke Apple's Phone app...
                var url = new NSUrl("tel:" + translateNumber);

                // ...otherwise show an alert dialog
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            };

            // Perform any additional setup after loading the view, typically from a nib.
            Button.AccessibilityIdentifier = "myButton";
            Button.TouchUpInside          += delegate
            {
                var title = string.Format("{0} clicks!", count++);
                Button.SetTitle(title, UIControlState.Normal);
            };
        }
Esempio n. 5
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            TranslateButton.TouchUpInside += (object sender, EventArgs e) => {
                // Convert the phone number with text to a number
                // using PhoneTranslator.cs
                translatedNumber = PhoneTranslator.ToNumber(
                    PhoneNumberText.Text);

                // Dismiss the keyboard if text field was tapped
                PhoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call ", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translatedNumber,
                                        UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            CallButton.TouchUpInside += (object sender, EventArgs e) => {
                //Store the phone number that we're dialing in PhoneNumbers
                PhoneNumbers.Add(translatedNumber);

                // Use URL handler with tel: prefix to invoke Apple's Phone app...
                var url = new NSUrl("tel:" + translatedNumber);

                // otherwise show an alert dialog
                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            };
        }
Esempio n. 6
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            //translatebutton
            string translatedNumber = "";

            TranslateButton.TouchUpInside += (object sender, EventArgs e) => {
                // Convert the phone number with text to a number
                // using PhoneTranslator.cs
                translatedNumber = PhoneTranslator.ToNumber(PhoneNumberText.Text);

                // Dismiss the keyboard if text field was tapped
                PhoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };
            //callbutton
            CallButton.TouchUpInside += (object sender, EventArgs e) => {
                //var url = new NSUrl("tel:" + translatedNumber);
                //if (!UIApplication.SharedApplication.OpenUrl(url))
                //{
                //    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                //    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                //    PresentViewController(alert, true, null);
                //}

                Analytics.TrackEvent("Button is clicked at " + DateTime.Now.ToLongTimeString());

                Crashes.GenerateTestCrash();
            };
        }
Esempio n. 7
0
 void OnTranslate(object sender, EventArgs e)
 {
     try
     {
         translatedNumber = PhoneTranslator.ToNumber(PartnerModel.PhoneNumber);
         if (!string.IsNullOrWhiteSpace(translatedNumber))
         {
             //callButton.IsEnabled = true;
             //callButton.Text = "Call " + translatedNumber;
             //OnCall(null, null);
             PlacePhoneCallAsync();
         }
         else
         {
             //callButton.IsEnabled = false;
             //callButton.Text = "Call";
         }
     }
     catch (Exception ex)
     {
         Crashes.TrackError(ex);
     }
 }
Esempio n. 8
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);


            // Set our view from the "main" layout resource



            var PhoneNumberText   = FindViewById <EditText>(Resource.Id.PhoneNumberText);
            var TranslateButton   = FindViewById <Button>(Resource.Id.TranslateButton);
            var CallButton        = FindViewById <Button>(Resource.Id.CallButton);
            var CallHistoryButton = FindViewById <Button>(Resource.Id.CallHistoryButton);

            //  var ValidarButton= FindViewById<Button>(Resource.Id.ValidateButton);
            CallButton.Enabled = false;

            var TranslateNumber = string.Empty;

            TranslateButton.Click += (object sender, System.EventArgs e) =>
            {
                var Translator = new PhoneTranslator();
                TranslateNumber = Translator.ToNumber(PhoneNumberText.Text);
                if (string.IsNullOrWhiteSpace(TranslateNumber))
                {
                    //no hay numero a llamar
                    CallButton.Text    = "Llamar";
                    CallButton.Enabled = false;
                }
                else
                {
                    //Hay un posible numero telefonico a Llamar
                    CallButton.Text    = $"Llamar al {TranslateNumber}";
                    CallButton.Enabled = true;
                }
            };
            CallButton.Click += (object sender, System.EventArgs e) =>

            {
                //Intentar marcar el numero telefonico
                var CallDialog = new AlertDialog.Builder(this);
                CallDialog.SetMessage($"Llamar al numero {TranslateNumber}?");
                CallDialog.SetNeutralButton("Llamar", delegate
                {
                    //Agrega el numero marcado a la lista de numero marcado
                    PhoneNumbers.Add(TranslateNumber);
                    //Habilita el boton Call HistoryButton
                    CallHistoryButton.Enabled = true;


                    //Crear un intento para marcar el numero telefonico
                    var CallIntent = new Android.Content.Intent(Android.Content.Intent.ActionCall);
                    CallIntent.SetData(
                        Android.Net.Uri.Parse($"tel:{TranslateNumber}"));
                    StartActivity(CallIntent);
                });
                CallDialog.SetNegativeButton("Cancelar", delegate { });
                //Mostrar el cuadro de dialogo al usuario y esperar una respuesta.
                CallDialog.Show();
            };

            CallHistoryButton.Click += (sender, e) =>
            {
                var Intent = new Android.Content.Intent(this, typeof(CallHistoryActivity));
                Intent.PutStringArrayListExtra("phone_numbers", PhoneNumbers);
                StartActivity(Intent);
            };

            /* ValidarButton.Click += delegate {
             *   SetContentView(Resource.Layout.layoutValidate);
             *   Validate();
             * };*/
        }
        public void TestToNumberWithJustNumbers()
        {
            var number = PhoneTranslator.ToNumber("1234567890");

            Assert.AreEqual("1234567890", number);
        }
        public void TestToNumberWithJennysNumber()
        {
            var number = PhoneTranslator.ToNumber("8675309");

            Assert.AreEqual("8675309", number);
        }
Esempio n. 11
0
 public void TranslateIgnoresNonAlphanumeric()
 {
     Assert.AreSame("", PhoneTranslator.ToNumber(";"));
 }
Esempio n. 12
0
 public void TranslateReturnsRightNumberForLowerCase()
 {
     Assert.AreEqual("2", PhoneTranslator.ToNumber("a"));
 }
Esempio n. 13
0
 public void TranslateReturnsBlankIfNull()
 {
     Assert.AreSame("", PhoneTranslator.ToNumber(null));
 }