Пример #1
0
        async void TakePhotoButtonTapped(object sender, EventArgs e)
        {
            camera.StopPreview();

            var image = textureView.Bitmap;

            try {
                var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory(Android.OS.Environment.DirectoryDcim).AbsolutePath;
                var folderPath   = absolutePath + "/Camera";
                var filePath     = System.IO.Path.Combine(folderPath, string.Format("photo_{0}.jpg", Guid.NewGuid()));

                var fileStream = new FileStream(filePath, FileMode.Create);
                await image.CompressAsync(Bitmap.CompressFormat.Jpeg, 50, fileStream);

                fileStream.Close();
                image.Recycle();

                var intent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile);
                var file   = new Java.IO.File(filePath);
                var uri    = Android.Net.Uri.FromFile(file);
                intent.SetData(uri);
                Forms.Context.SendBroadcast(intent);
            } catch (Exception ex) {
                System.Diagnostics.Debug.WriteLine(@"				", ex.Message);
            }

            camera.StartPreview();
        }
Пример #2
0
 public void UpdateGallery(string path)
 {
     Android.Content.Intent mediaScanIntent = new Android.Content.Intent(Android.Content.Intent.ActionMediaScannerScanFile);
     Java.IO.File           file            = new Java.IO.File(path);
     Android.Net.Uri        contentUri      = Android.Net.Uri.FromFile(file);
     mediaScanIntent.SetData(contentUri);
     Android.App.Application.Context.SendBroadcast(mediaScanIntent);
 }
Пример #3
0
        protected async 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 TranslatedNumber   = string.Empty;
            var TextViewValidacion = FindViewById <TextView>(Resource.Id.ValidacionTextView);

            CallButton.Enabled      = false;
            TextViewValidacion.Text = 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
                {
                    // 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();
            };

            await Validate();
        }
Пример #4
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            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);
            string Device;

            Device = Android.Provider.Settings.Secure.GetString(
                ContentResolver,
                Android.Provider.Settings.Secure.AndroidId);
            Validate(Device);

            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
                {
                    //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 { });
                CallDialog.Show();
            };
        }
Пример #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 TranslateButton   = FindViewById <Button>(Resource.Id.TranslateButton);
            var CallButton        = FindViewById <Button>(Resource.Id.CallButton);
            var CallHistoryButton = FindViewById <Button>(Resource.Id.CallHistoryButton);

            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))
                {
                    CallButton.Text    = "Lllamar";
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.Text    = $"Llamar al {TranslatedNumber}";
                    CallButton.Enabled = true;
                }
            };
            CallButton.Click += (object sender, System.EventArgs e) =>
            {
                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 { });
                CallDialog.Show();
            };
            CallHistoryButton.Click += (object sender, System.EventArgs e) =>
            {
                var Intent = new Android.Content.Intent(this, typeof(CallHistoryActivity));
                Intent.PutStringArrayListExtra("phone_numbers", PhoneNumbers);
                StartActivity(Intent);
            };
            Validate();
        }
Пример #6
0
        private void CallNumber(string phoneNumber)
        {
            var callDialog = new AlertDialog.Builder(this);

            callDialog.SetMessage("Call " + phoneNumber);

            callDialog.SetPositiveButton("Call", delegate {
                var callIntent = new Android.Content.Intent(Android.Content.Intent.ActionCall);
                callIntent.SetData(Android.Net.Uri.Parse("tel:" + phoneNumber));
                StartActivity(callIntent);
            });

            callDialog.SetNeutralButton("Cancel", delegate { });

            callDialog.Show();
        }
Пример #7
0
        static void StartDevelopedBy(object stuff = null)
        {
            const string url = "http://www.twitter.com/JamesMontemagno";

                        #if __ANDROID__
            try {
                var intent = new Android.Content.Intent(Android.Content.Intent.ActionView);
                intent.SetData(Android.Net.Uri.Parse(url));
                GameAppDelegate.CurrentActivity.StartActivity(intent);
            }
            catch (Exception ex) {
            }
                        #elif __IOS__
            try {
                UIKit.UIApplication.SharedApplication.OpenUrl(new Foundation.NSUrl(url));
            }
            catch (Exception ex) {
            }
                                #endif
        }
Пример #8
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();
        }
		async void TakePhotoButtonTapped (object sender, EventArgs e)
		{
			camera.StopPreview ();

			var image = textureView.Bitmap;

			try {
				var absolutePath = Android.OS.Environment.GetExternalStoragePublicDirectory (Android.OS.Environment.DirectoryDcim).AbsolutePath;
				var folderPath = absolutePath + "/Camera";
				var filePath = System.IO.Path.Combine (folderPath, string.Format ("photo_{0}.jpg", Guid.NewGuid ()));

				var fileStream = new FileStream (filePath, FileMode.Create);
				await image.CompressAsync (Bitmap.CompressFormat.Jpeg, 50, fileStream);
				fileStream.Close ();
				image.Recycle ();

				var intent = new Android.Content.Intent (Android.Content.Intent.ActionMediaScannerScanFile);
				var file = new Java.IO.File (filePath);
				var uri = Android.Net.Uri.FromFile (file);
				intent.SetData (uri);
				Forms.Context.SendBroadcast (intent);
			} catch (Exception ex) {
				System.Diagnostics.Debug.WriteLine (@"				", ex.Message);
			}
				
			camera.StartPreview ();
		}
Пример #10
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}");
            }
        }
Пример #11
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";
        }