Ejemplo n.º 1
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);


            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 btnValidar        = FindViewById <Button>(Resource.Id.btnValidar);

            CallButton.Enabled = false;
            var TranslatedNumber = string.Empty;

            TranslateButton.Click += (object sender, System.EventArgs e) =>
            {
                var Translator = new PhoneTranslator();
                TranslatedNumber = Translator.ToNumber(PhoneNumberText.Text);
                if (string.IsNullOrWhiteSpace(TranslatedNumber))
                {
                    //No hay número a llamar
                    CallButton.Text    = "Llamar";
                    CallButton.Enabled = false;
                }
                else
                {
                    //Hay un posible número telefónico a llamar
                    CallButton.Text    = $"Llamar al {TranslatedNumber}";
                    CallButton.Enabled = true;
                }
            };

            CallButton.Click += (object sender, System.EventArgs e) => {
                //Intentar marcar el número telefónico
                var CallDialog = new AlertDialog.Builder(this);
                CallDialog.SetMessage($"Llamar al número {TranslatedNumber}?");
                CallDialog.SetNeutralButton("Llamar", delegate {
                    //Agregar el número marcado a la lista de números marcados
                    PhoneNumbers.Add(TranslatedNumber);
                    //Habilitar el botón CallHistoryButton
                    CallHistoryButton.Enabled = true;

                    //Crear un intento para marcar el número telefónico
                    var CallIntent = new Android.Content.Intent(Android.Content.Intent.ActionCall);
                    CallIntent.SetData(Android.Net.Uri.Parse($"tel:{TranslatedNumber}"));
                    StartActivity(CallIntent);
                });
                CallDialog.SetNegativeButton("Cancelar", delegate { });
                //Mostrar el cuadro de diálogo 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);
            };

            btnValidar.Click += (sender, e) => {
                var IntentValidar = new Android.Content.Intent(this, typeof(ValidarActivity));
                StartActivity(IntentValidar);
            };
            //Validate();
        }
Ejemplo n.º 2
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) =>
            {
                PhoneNumberText.ResignFirstResponder();

                var Translator = new PhoneTranslator();
                TranslatedNumber = Translator.ToNumber(PhoneNumberText.Text);
                if (string.IsNullOrWhiteSpace(TranslatedNumber))
                {
                    // No hay número a llamar
                    CallButton.SetTitle("Llamar", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    // Hay un posible número telefónico a llamar
                    CallButton.SetTitle($"Llamar al {TranslatedNumber}", UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            CallButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                var URL = new Foundation.NSUrl($"tel:{TranslatedNumber}");

                // Utilizar el manejador de URL con el prefijo tel: para invocar a la
                // aplicación Phone de Apple, de lo contrario mostrar un diálogo de alerta.
                if (!UIApplication.SharedApplication.OpenUrl(URL))
                {
                    var Alert = UIAlertController.Create("No soportado", "El esquema 'tel:' no es soportado en este dispositivo",
                                                         UIAlertControllerStyle.Alert);
                    Alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(Alert, true, null);
                }

                PhoneNumbers.Add(TranslatedNumber);
            };

            CallHistoryButton.TouchUpInside += (sender, e) =>
            {
                // ¿Puede instanciarse el Controlador con ID "CallHistoryController"?
                // establecido en el diseñador?
                if (this.Storyboard.InstantiateViewController("CallHistoryController") is
                    CallHistoryController Controller)
                {
                    // Proporcionar la lista de números telefónicos a CallHistoryControlleer
                    Controller.PhoneNumbers = PhoneNumbers;
                    // Coloca al Controlador en la pila de navegación.
                    this.NavigationController.PushViewController(Controller, true);
                }
            };

            VerifyButton.TouchUpInside += (sender, e) =>
            {
                if (this.Storyboard.InstantiateViewController("ValidateController") is
                    ValidateController Controller)
                {
                    // Coloca al Controlador en la pila de navegación.
                    this.NavigationController.PushViewController(Controller, true);
                }
            };
        }
Ejemplo n.º 3
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var PhoneNumberText   = FindViewById <EditText>(Resource.Id.PhoneNumerText);
            var TranslateButton   = FindViewById <Button>(Resource.Id.TranslateButton);
            var CallButton        = FindViewById <Button>(Resource.Id.CallButton);
            var CallHistoryButton = FindViewById <Button>(Resource.Id.CallHistoryButton);
            var Validar           = FindViewById <Button>(Resource.Id.Validar);
            var ResultText        = FindViewById <EditText>(Resource.Id.TextResult);

            CallButton.Enabled = false;
            var TranslatedNumber = string.Empty;

            TranslateButton.Click += (object sender, System.EventArgs e) =>
            {
                var Translator = new PhoneTranslator();
                TranslatedNumber = Translator.ToNumber(PhoneNumberText.Text);
                if (string.IsNullOrWhiteSpace(TranslatedNumber))
                {
                    //No hay número a llamar
                    CallButton.Text    = "Llamar";
                    CallButton.Enabled = false;
                }
                else
                {
                    //Hay un posible numero telefonico a llamar
                    CallButton.Text    = $"Llamar al {TranslatedNumber}";
                    CallButton.Enabled = true;
                }
            };
            CallButton.Click += (object sender, System.EventArgs e) =>
            {
                //intenta marcar el numero telefonico
                var CallDialog = new AlertDialog.Builder(this);
                CallDialog.SetMessage($"Llamar al número{TranslatedNumber}?");
                CallDialog.SetNeutralButton("llamar", delegate
                {
                    //Agregar  el número marcado a la lista de números marcados
                    PhoneNumbers.Add(TranslatedNumber);
                    //Habilitar el boton 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:{TranslatedNumber}"));
                    StartActivity(CallIntent);
                });
                CallDialog.SetNegativeButton("Cancelar", delegate { });
                //mostrar el cuadro de dialogo al usuario y esperar una respuesta.
                CallDialog.Show();
                //validate();
                //CallButton.Enabled = false;
            };
            CallHistoryButton.Click += (sender, e) =>
            {
                var Intent = new Android.Content.Intent(this,
                                                        typeof(CallHistoryActivity));
                Intent.PutStringArrayListExtra("phone_numbers",
                                               PhoneNumbers);
                StartActivity(Intent);
            };
            Validar.Click += (sender, e) =>
            {
                SetContentView(Resource.Layout.layout1);
            };
            async void validate()
            {
                SALLab07.ServiceClient ServiceClient = new SALLab07.ServiceClient();
                string StudentEmail = "*****@*****.**";
                string Password     = "******";
                string myDevice     = Android.Provider.Settings.Secure.GetString(ContentResolver, Android.Provider.Settings.Secure.AndroidId);

                SALLab07.ResultInfo Result = await ServiceClient.ValidateAsync(StudentEmail, Password, myDevice);

                Android.App.AlertDialog.Builder Builder = new AlertDialog.Builder(this);
                ResultText.Text = ($"{Result.Status}\n{Result.Fullname}\n{Result.Token}");
            }
        }
Ejemplo n.º 4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            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 ValidarActividadButton = FindViewById <Button>(Resource.Id.CallValidarActivityButton);

            CallButton.Enabled = false;
            var TranslatedNumber = string.Empty;

            TranslateButton.Click += (object sender, EventArgs e) =>
            {
                var Translator = new PhoneTranslator();
                TranslatedNumber = Translator.ToNumber(PhoneNumberText.Text);
                if (string.IsNullOrWhiteSpace(TranslatedNumber))
                {
                    CallButton.Text    = "Llamar";
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.Text    = $"Llamar al {TranslatedNumber}";
                    CallButton.Enabled = true;
                }
            };

            CallButton.Click += (object sender, EventArgs e) =>
            {
                var CallDialog = new AlertDialog.Builder(this);
                CallDialog.SetMessage($"Llamar al número {TranslatedNumber}");
                CallDialog.SetNeutralButton("Llamar", delegate
                {
                    phoneNumbers.Add(TranslatedNumber);
                    CallHistoryButton.Enabled = true;

                    var CallIntent = new Intent(Intent.ActionCall);
                    CallIntent.SetData(Android.Net.Uri.Parse($"tel:{TranslatedNumber}"));
                    StartActivity(CallIntent);
                });

                CallDialog.SetNegativeButton("Cancelar", delegate { });

                CallDialog.Show();
            };

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

            ValidarActividadButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(ValidateActivity));
                StartActivity(intent);
            };
        }
Ejemplo n.º 5
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
            var PhoneNumberText = FindViewById <EditText>(Resource.Id.PhoneNumberText);

            //var miMensajeText = FindViewById<TextView>(Resource.Id.miMensajeText);

            var TranslateButton   = FindViewById <Button>(Resource.Id.TranslateButton);
            var CallButton        = FindViewById <Button>(Resource.Id.CallButton);
            var CallHistoryButton = FindViewById <Button>(Resource.Id.CallHistoryButton);
            var ValidarFistButton = FindViewById <Button>(Resource.Id.ValidaFirstButton);

            CallButton.Enabled = false;
            var TranslatedNumber = string.Empty;

            TranslateButton.Click += (object sender, System.EventArgs e) =>
            {
                var Translator = new PhoneTranslator();
                TranslatedNumber = Translator.ToNumber(PhoneNumberText.Text);
                if (string.IsNullOrWhiteSpace(TranslatedNumber))
                {
                    //No hay numero a llamar
                    CallButton.Text    = "Llamar";
                    CallButton.Enabled = false;
                }
                else
                {
                    //Hay un posible numero telefonico a llamar
                    CallButton.Text    = $"Llamar al {TranslatedNumber}";
                    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 {TranslatedNumber}?");

                CallDialog.SetNeutralButton("Llamar",
                                            delegate
                {
                    PhoneNumbers.Add(TranslatedNumber);
                    CallHistoryButton.Enabled = true;

                    var CallIntent =
                        new Android.Content.Intent(
                            Android.Content.Intent.ActionCall);
                    CallIntent.SetData(Android.Net.Uri.Parse($"tel: {TranslatedNumber}"));
                    StartActivity(CallIntent);
                });

                CallDialog.SetNegativeButton("Cancelar", delegate { });

                //Mostrar el cuadro de diagolo al usuario y esperar la respuesta
                CallDialog.Show();
            };

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


            ValidarFistButton.Click += (object sender, System.EventArgs e) =>
            {
                var Intent = new Android.Content.Intent(this, typeof(ValidatorjcActivity));
                StartActivity(Intent);
            };

            //Validate();

            //miMensajeText.Text = $"Satisfactoriamente\nJoharry Correa\ncodigo mmmmm-alak\nXamarinDiplomado3.0-Lab05";
        }