Example #1
0
        private async Task DescifrarArchivos(byte[] keyMaterial, bool eliminarArchivos)
        {
            foreach (var archivo in adaptador.archivos)
            {
                string rutaDestino = Path.Combine(Path.GetDirectoryName(archivo.Nombre), Path.GetFileNameWithoutExtension(archivo.Nombre));

                AlertDialog.Builder mensajeInformacion = new AlertDialog.Builder(this);
                mensajeInformacion.SetTitle("Error al descifrar");
                try
                {
                    await Crypto.CifradoDescifradoAsincrono(keyMaterial, archivo.Nombre, rutaDestino, false);

                    if (eliminarArchivos)
                    {
                        File.Delete(archivo.Nombre);
                    }
                }
                catch (System.Security.Cryptography.CryptographicException)
                {
                    mensajeInformacion.SetMessage("Esto puede deberse a una de las siguientes razones:\n1-El archivo está dañado\n2-El archivo no fue cifrado con Encrypto");
                    mensajeInformacion.Show();
                    File.Delete(rutaDestino);
                }
                catch (FileNotFoundException)
                {
                    mensajeInformacion.SetMessage("El archivo " + Path.GetFileName(archivo.Nombre) + " no pudo ser encontrado");
                    mensajeInformacion.Show();
                    File.Delete(rutaDestino);
                }
                catch (DirectoryNotFoundException)
                {
                    mensajeInformacion.SetMessage("El directorio destino '" + Path.GetDirectoryName(archivo.Nombre) + "' no pudo ser encontrado");
                    mensajeInformacion.Show();
                    File.Delete(rutaDestino);
                }
                catch (Javax.Crypto.IllegalBlockSizeException)
                {
                    mensajeInformacion.SetMessage("El archivo " + Path.GetFileName(archivo.Nombre) + " no pudo ser cifrado. La contraseña es incorrecta");
                    mensajeInformacion.Show();
                    File.Delete(rutaDestino);
                }
                catch (Exception)
                {
                    mensajeInformacion.SetMessage("Error desconocido");
                    mensajeInformacion.Show();
                    File.Delete(rutaDestino);
                }
            }
        }
 private void pruebecita(object sender, EventArgs e)
 {
     AlertDialog.Builder ventanaEmergente = new AlertDialog.Builder(this);
     ventanaEmergente.SetTitle("Ejercicio 1");
     ventanaEmergente.SetMessage(_editText1.Text.ToString());
     ventanaEmergente.Show();
 }
Example #3
0
        private void MMultipleDelete_Click(object sender, EventArgs e)
        {
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

            alertDialog.SetTitle("Are you sure?");
            alertDialog.SetMessage("Do you want to delete this item?");
            alertDialog.SetPositiveButton("yes", delegate
            {
                // throw new NotImplementedException();
                List <Product> listaNouaProduse = new List <Product>(); //construim o noua lista de produse

                listaNouaProduse.AddRange(mProducts);                   //populez lista noua
                foreach (Product product in mProductsCD)                //luam fiecare produs din lista copiata-> daca produsul respectiv are Id-ul magazinului egal cu ceea ce am selectat in spinner-> in lista noua de produse se adauga produsul

                {
                    if (product.Checked) //am inclus Checked ca si coloana[Ignore] in clasa Produse
                    {
                        listaNouaProduse.Remove(product);
                        db.deleteProduct(product);
                        mProductsCopy.Remove(product); //ca sa sterg produsele din lista copie de la filtrare
                        Toast.MakeText(this, "The selected products were deleted!", ToastLength.Long).Show();
                    }
                }

                mProducts = listaNouaProduse;   //la lista noastra initiala de produse se adauga listaNouaProduse(am sters din ea elemente)

                mAdapter.mProducts = mProducts; //se actualizeaza adapterul cu lista noua
                mAdapter.NotifyDataSetChanged();
            });

            alertDialog.SetNegativeButton("NO", (IDialogInterfaceOnClickListener)null);
            alertDialog.Create();
            alertDialog.Show();
        }
Example #4
0
        // Alert Dialog box-if you want to delete something press Yes - then the product is deleted
        private void MAdapter_CellClick_ButtonDelete(object sender, Product e)
        {
            // throw new NotImplementedException();
            this.RunOnUiThread(() =>
            {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);

                alertDialog.SetTitle("Are you sure?");
                alertDialog.SetMessage("Do you want to delete this item?");
                alertDialog.SetPositiveButton("yes", delegate
                {
                    alertDialog.Dispose();

                    //e.Position = mAdapter.mProducts.IndexOf(e);
                    db.deleteProduct(e);
                    mAdapter.mProducts.Remove(e);
                    mProductsCopy.Remove(e);
                    mAdapter.NotifyItemRemoved(e.Position);

                    Toast.MakeText(this, " The product " + e.ToString() + " was deleted! ", ToastLength.Long).Show();
                });
                alertDialog.SetNegativeButton("NO", (IDialogInterfaceOnClickListener)null);
                alertDialog.Create();
                alertDialog.Show();
            });
        }
Example #5
0
 private void ConfirmSelectedCollaborators(object sender, EventArgs e)
 {
     if (assignUserList.Count > 0)
     {
         AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
         alertBuilder.SetCancelable(false);
         alertBuilder.SetMessage("Do you want to share this report with this selected users?");
         alertBuilder.SetTitle("Share Report");
         alertBuilder.SetPositiveButton("Yes", (sender1, args) =>
         {
             Intent formActivity = new Intent(this, typeof(FormActivity));
             formActivity.PutExtra(Resources.GetString(Resource.String.assign_user_list_type), Resources.GetString(Resource.String.add_collaborators));
             formActivity.PutIntegerArrayListExtra(Resources.GetString(Resource.String.assign_user_id_list), assignUserList);
             SetResult(Result.Ok, formActivity);
             Finish();
         });
         alertBuilder.SetNegativeButton("No", (sender1, args) =>
         {
             assignUserList.Clear();
             alertBuilder.Dispose();
             userListAdapter = new UserListAdapter(this, userCompanies, selectedUserList, userListType);
             userListAdapter.ButtonClickedOnAssignInvite += ButtonClickDelegate;
             expandableListView.SetAdapter(userListAdapter);
         });
         alertBuilder.Show();
     }
     else
     {
         Utility.DisplayToast(this, "Please select a user to share report");
     }
 }
Example #6
0
        protected override void OnListItemClick(ListView l, View v, int position, long id) // checked item click
        {
            base.OnListItemClick(l, v, position, id);

            RunOnUiThread(() =>
            {
                AlertDialog.Builder builder;
                builder = new AlertDialog.Builder(this);
                builder.SetTitle(" Confirm ");
                builder.SetMessage(" Are you done with this item ?");
                builder.SetCancelable(true);

                builder.SetPositiveButton(" OK ", delegate
                {
                    //remove item from listview
                    var item = Items[position];
                    Items.Remove(item);
                    adapter.Remove(item);

                    //reset listview l
                    l.ClearChoices();
                    l.RequestLayout();

                    UpdatedStoredData();
                });

                builder.SetNegativeButton(" Cancel ", delegate
                                          { return; });

                builder.Show(); //Launches the popup!
            }
                          );
        }
Example #7
0
        private void ShowLoginDialog()
        {
            var alert = new AlertDialog.Builder(this);

            alert.SetTitle("请登录");
            var view = View.Inflate(this, Resource.Layout.login_dialog, null);

            alert.SetView(view);
            alert.SetPositiveButton("登录", (EventHandler <DialogClickEventArgs>)null);
            var dialog = alert.Show();

            dialog.GetButton((int)DialogButtonType.Positive).Click += async(sender, args) =>
            {
                var username = view.FindViewById <EditText>(Resource.Id.et_name).Text;
                var password = view.FindViewById <EditText>(Resource.Id.et_pwd).Text;
                var token    = await API.Login(username, password);

                if (token != null)
                {
                    Toast.MakeText(this, "登录成功!", ToastLength.Short).Show();
                    refresh();
                    this.token = token;
                    GetSharedPreferences("config", FileCreationMode.Private)
                    .Edit().PutString("token", token).Apply();
                    dialog.Dismiss();
                }

                Toast.MakeText(this, "登录失败!", ToastLength.Short).Show();
            };
        }
        private void FabOnClick(object sender, EventArgs eventArgs)
        {
            View view = (View)sender;

            string rec = Android.Content.PM.PackageManager.FeatureMicrophone;

            if (rec != "android.hardware.microphone")
            {
                var alert = new AlertDialog.Builder(recButton.Context);
                alert.SetTitle("You don't seem to have a microphone to record with");
                alert.SetPositiveButton("OK", (sender, e) =>
                {
                    textBox.Text = "No microphone present";
                    return;
                });

                alert.Show();
            }
            else
            {
                isRecording = !isRecording;
            }
            if (isRecording)
            {
                var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

                voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                StartActivityForResult(voiceIntent, VOICE);
            }
        }
Example #9
0
        private void MprofileTracker_mOnProfileChanged(object sender, OnProfileChangedEventArgs e)
        {
            if (e.mProfile != null)
            {
                try
                {
                    Profile p    = e.mProfile;
                    int     idUS = bd.loginfacebook(p.Id);
                    if (idUS != 0)//consulta para iniciar sesion
                    {
                        Intent i   = new Intent(this, typeof(Inicio));
                        string aux = Convert.ToString(idUS);
                        i.PutExtra("idUs", aux);
                        StartActivity(i);
                    }
                    else
                    {
                        AlertDialog alerta = new AlertDialog.Builder(this).Create();
                        alerta.SetTitle("Error ");
                        alerta.SetMessage("FB no esta enlazado a ninguna cuenta de usuario");
                        alerta.SetButton("Aceptar", (a, b) => { });
                        alerta.Show();
                    }

                    // tengo que crear el layout del  config y pasar los datos a una sesion para almacenarlos entre pestañas
                }
                catch (Java.Lang.Exception ex) { }
            }
            else
            {
            }
        }
Example #10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.search_layout);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);
            SupportActionBar.SetDisplayShowTitleEnabled(false);

            try
            {
                var ingridients = Intent.GetStringArrayListExtra("Ingridients");
                StartSearch(GetSearchUrl(ingridients));
            }
            catch (Exception)
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Connetction Error");
                alert.SetMessage("Check your conection");
                alert.SetPositiveButton("OK", HandlePositiveButtonClick);
                alert.SetCancelable(false);
                alert.Show();
            }
        }
Example #11
0
        private void BtnLogin_Click(object sender, EventArgs e)//login normal
        {
            try
            {
                string correo = correoLogin.Text;
                string pass   = passLogin.Text;
                int    aux    = 0;
                aux = bd.LoginNormal(correo, pass).Idusuario;

                if (aux != 0)
                {
                    Intent i = new Intent(this, typeof(MainActivity));
                    i.PutExtra("idUs", Convert.ToString(aux));
                    StartActivity(i);
                }
                else
                {
                    AlertDialog alerta = new AlertDialog.Builder(this).Create();
                    alerta.SetTitle("Error ");
                    alerta.SetMessage("El usuario o la contraseña son incorrectos. Compruebe su conexion a internet");
                    alerta.SetButton("Aceptar", (a, b) => { });
                    alerta.Show();
                }
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message);
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }
        }
Example #12
0
        private async Task CifrarArchivos(byte[] keyMaterial, bool eliminarArchivos)
        {
            AlertDialog.Builder mensajeInformacion = new AlertDialog.Builder(this);
            mensajeInformacion.SetTitle("Error al cifrar");
            foreach (var archivo in adaptador.archivos)
            {
                string rutaDestino;
                try
                {
                    rutaDestino = Path.Combine(Path.GetDirectoryName(archivo.Nombre), Path.GetFileName(archivo.Nombre)) + ".crypt";
                    await Crypto.CifradoDescifradoAsincrono(keyMaterial, archivo.Nombre, rutaDestino, true);

                    if (eliminarArchivos)
                    {
                        File.Delete(archivo.Nombre);
                    }
                    archivosProcesados.Add(rutaDestino);
                }
                catch (System.Security.Cryptography.CryptographicException)
                {
                    mensajeInformacion.SetMessage("El archivo " + Path.GetFileName(archivo.Nombre) + " no pudo ser cifrado");
                    mensajeInformacion.Show();
                }
                catch (FileNotFoundException)
                {
                    mensajeInformacion.SetMessage("El archivo " + Path.GetFileName(archivo.Nombre) + " no pudo ser encontrado");
                    mensajeInformacion.Show();
                }
                catch (DirectoryNotFoundException)
                {
                    mensajeInformacion.SetMessage("El directorio destino '" + Path.GetDirectoryName(archivo.Nombre) + "' no pudo ser encontrado");
                    mensajeInformacion.Show();
                }
                catch (Javax.Crypto.IllegalBlockSizeException)
                {
                    mensajeInformacion.SetMessage("El archivo " + Path.GetFileName(archivo.Nombre) + " no pudo ser cifrado. La contraseña es incorrecta");
                    mensajeInformacion.Show();
                }
                catch (Exception)
                {
                    mensajeInformacion.SetMessage("Error desconocido");
                    mensajeInformacion.Show();
                }
            }
        }
Example #13
0
        // Display that there's not enough questions to play the game and redirect to the `ListQuestionsActivity`.
        private void ShowNotEnoughQuestionsAlert()
        {
            AlertDialog notEnoughQuestionsAlert = new AlertDialog.Builder(this).Create();

            notEnoughQuestionsAlert.SetCanceledOnTouchOutside(false);
            notEnoughQuestionsAlert.SetMessage(string.Format("Sorry, you don't have enough questions to play this game! Please add at least {0} using the 'MANAGE QUESTIONS' section", minNumberOfQuestions));
            notEnoughQuestionsAlert.SetButton("Okay", (sender, args) => { StartActivity(typeof(ListQuestionsActivity)); Finish(); });
            notEnoughQuestionsAlert.Show();
        }
Example #14
0
        public void ShowAlert(string str)
        {
            var alert = new AlertDialog.Builder(this);

            alert.SetTitle(str);
            alert.SetPositiveButton("OK", (senderAlert, args) => { StartActivity(typeof(a_Schools)); });

            //run the alert in UI thread to display in the screen
            RunOnUiThread(() => { alert.Show(); });
        }
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.institutions_info);



            var toolbar = FindViewById <V7Toolbar>(Resource.Id.toolbar);

            SetSupportActionBar(toolbar);

            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            SupportActionBar.SetDisplayShowHomeEnabled(true);


            // Create your application here
            FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Visible;


            model.db_select select = new model.db_select();

            list = await select.get_institutions(Preferences.Get("cypher1", "").ToString(), Preferences.Get("cypher2", "").ToString());

            //Toast.MakeText(ApplicationContext, list[0].DocAdSoyad, ToastLength.Long).Show();

            listView1 = FindViewById <ListView>(Resource.Id.listView1);
            FindViewById <SearchView>(Resource.Id.searchView1).QueryTextChange += search;
            AD = new List <string>();

            foreach (var item in list)
            {
                AD.Add(item.AD);
            }
            mAdapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleListItem1, AD);
            if (!mAdapter.IsEmpty)
            {
                FindViewById <ListView>(Resource.Id.listView1).Adapter = mAdapter;
            }
            else
            {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetTitle("Bildiriş");
                alertDialog.SetMessage("Xəta baş verdi");
                alertDialog.SetNeutralButton("Geriyə", delegate {
                    alertDialog.Dispose();
                });
                alertDialog.Show();
            }

            FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Gone;
        }
Example #16
0
        private void ShowPauseDialog()
        {
            View dialogView = LayoutInflater.Inflate(Resource.Layout.spinner_dialog, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetView(dialogView);
            builder.SetCancelable(false);
            builder.SetTitle(INFECTION_STATUS_PAUSE_DIALOG_TITLE);
            builder.SetMessage(INFECTION_STATUS_PAUSE_DIALOG_MESSAGE);
            _picker          = dialogView.FindViewById(Resource.Id.picker) as NumberPicker;
            _picker.MinValue = 0;
            _picker.MaxValue = 4;
            _picker.DescendantFocusability = DescendantFocusability.BlockDescendants;
            _picker.SetDisplayedValues(
                new[]
            {
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_NO_REMINDER,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_ONE_HOUR,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_TWO_HOURS,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_FOUR_HOURS,
                INFECTION_STATUS_PAUSE_DIALOG_OPTION_EIGHT_HOURS,
            });

            builder.SetPositiveButton(INFECTION_STATUS_PAUSE_DIALOG_OK_BUTTON, (sender, args) =>
            {
                switch (_picker.Value)
                {
                case 1:
                case 2:
                case 3:
                case 4:
                    StartReminderService((int)Math.Pow(2, _picker.Value - 1));
                    break;
                }
                StopGoogleAPI();
                (sender as AlertDialog)?.Dismiss();
            });

            if (Android.OS.Build.VERSION.SdkInt > Android.OS.BuildVersionCodes.M)
            {
                AlertDialog alertDialog = builder.Create();
                alertDialog.Window.DecorView.LayoutDirection = LayoutUtils.GetLayoutDirection();
                alertDialog.Show();
            }
            else
            {
                builder.Create();
                builder.Show();
            }
        }
        void enableGPS()
        {
            Boolean enabled = service.IsProviderEnabled(provider);

            if (!enabled)
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Location Services Not Active");

                alert.SetMessage("Please enable Location Services and GPS");
                alert.SetPositiveButton("Ok", (c, ev) =>
                {
                    StartActivity(new Intent(Settings.ActionLocationSourceSettings));
                });
                alert.Show();
            }
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);

            Button sendEmail      = FindViewById <Button>(Resource.Id.sendButton);
            Button sendSMS        = FindViewById <Button>(Resource.Id.sendSMSButton);
            Button displayMessage = FindViewById <Button>(Resource.Id.displayMessageButton);

            EditText recipient = FindViewById <EditText>(Resource.Id.email);
            EditText subject   = FindViewById <EditText>(Resource.Id.subject);
            EditText message   = FindViewById <EditText>(Resource.Id.message);

            sendEmail.Click += delegate
            {
                if (recipient.Text.Trim().Length == 0 || subject.Text.Trim().Length == 0 || message.Text.Trim().Length == 0)
                {
                    var dialog = new AlertDialog.Builder(this);
                    dialog.SetTitle("Error");
                    dialog.SetMessage("You must supply a recipient, subject and a message");
                    dialog.SetNeutralButton("OK", (s, a) => { });
                    dialog.Show();
                }
                else
                {
                    var email = new Intent(Intent.ActionSend);
                    email.PutExtra(Intent.ExtraEmail, new string[] { recipient.Text });
                    email.PutExtra(Intent.ExtraSubject, subject.Text);
                    email.PutExtra(Intent.ExtraText, message.Text);
                    email.SetType("message/rfc822");

                    StartActivity(email);
                };
            };

            sendSMS.Click += (sender, args) =>
            {
                string url    = string.Format("smsto:{0}", recipient.Text);
                var    uri    = Android.Net.Uri.Parse(url);
                var    intent = new Intent(Intent.ActionSendto, uri);
                intent.PutExtra("sms_body", message.Text);
                StartActivity(intent);
            };
        }
Example #19
0
        private void OnItemSelected(string protocolId)
        {
            if (protocolId == "kp2a")
            {
                //send user to market page of regular edition to get more protocols
                Util.GotoUrl(this, GetString(Resource.String.MarketURL) + "keepass2android.keepass2android");
                return;
            }

            if (protocolId.Contains(","))
            {
                //bring up a selection dialog to select the variant of the file storage
                AlertDialog.Builder builder = new AlertDialog.Builder(this);

                builder.SetItems(protocolId.Split(",").Select(singleProtocolId => App.Kp2a.GetStorageDisplayName(singleProtocolId)).ToArray(),
                                 delegate(object sender, DialogClickEventArgs args)
                {
                    string[] singleProtocolIds = protocolId.Split(",");
                    OnItemSelected(singleProtocolIds[args.Which]);
                });
                builder.Show();
                return;
            }

            var field = typeof(Resource.String).GetField("filestoragehelp_" + protocolId);

            if (field == null)
            {
                //no help available
                ReturnProtocol(protocolId);
            }
            else
            {
                //set help:
                string help = GetString((int)field.GetValue(null));

                new AlertDialog.Builder(this)
                .SetTitle(GetString(Resource.String.app_name))
                .SetMessage(help)
                .SetPositiveButton(Android.Resource.String.Ok, (sender, args) => ReturnProtocol(protocolId))
                .Create()
                .Show();
            }
        }
Example #20
0
        public async void ShowBackgroundActivityDialog()
        {
            if (await _viewModel.IsRunning())
            {
                string messageCombined = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_MESSAGE_PART1 + "\n\n" +
                                         INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_MESSAGE_PART2 + "\n\n" +
                                         INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_MESSAGE_PART3;
                View     dialogView  = LayoutInflater.Inflate(Resource.Layout.background_activity_dialog, null);
                TextView headerText  = dialogView.FindViewById <TextView>(Resource.Id.background_activity_dialog_header);
                TextView messageText = dialogView.FindViewById <TextView>(Resource.Id.background_activity_dialog_message);
                headerText.Text      = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_TITLE;
                messageText.Text     = messageCombined;
                _positiveButton      = dialogView.FindViewById <Button>(Resource.Id.background_activity_dialog_button_yes);
                _negativeButton      = dialogView.FindViewById <Button>(Resource.Id.background_activity_dialog_button_no);
                _dontShowButton      = dialogView.FindViewById <Button>(Resource.Id.background_activity_dialog_button_dont_show);
                _positiveButton.Text = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_OK_BUTTON.ToUpper();
                _negativeButton.Text = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_NOK_BUTTON.ToUpper();
                _dontShowButton.Text = INFECTION_STATUS_BACKGROUND_ACTIVITY_DIALOG_DONT_SHOW_BUTTON.ToUpper();

                AlertDialog builder = new AlertDialog.Builder(this)
                                      .SetView(dialogView)
                                      .SetCancelable(false)
                                      .Create();
                SetIsBackgroundActivityDialogShowEnableNewUser(false);
                _positiveButton.Click += new SingleClick((sender, args) =>
                {
                    StopBatteryOptimizationSetting(this);
                    builder.Dismiss();
                }).Run;
                _negativeButton.Click += new SingleClick((sender, args) =>
                {
                    IsAppLaunchedToShowDialog = false;
                    builder.Dismiss();
                }).Run;

                _dontShowButton.Click += new SingleClick((sender, args) =>
                {
                    SetIsBackgroundActivityDialogShowEnable(false);
                    builder.Dismiss();
                }).Run;
                builder.Show();
                AdjustLines(_dontShowButton, _positiveButton, _negativeButton);
            }
        }
Example #21
0
        public void GetJsonData()
        {
            try
            {
                var    assembly = typeof(MainActivity).GetTypeInfo().Assembly;
                Stream stream   = assembly.GetManifestResourceStream($"{assembly.GetName().Name}.slangWordsList.json");

                using (var reader = new StreamReader(stream))
                {
                    var json = reader.ReadToEnd();
                    var myDeserializedClass = JsonConvert.DeserializeObject <List <MatchedWord> >(json);

                    if (editTextInput.Text.Equals(myDeserializedClass[0].SlangWord, StringComparison.OrdinalIgnoreCase))
                    {
                        showResult.Text = myDeserializedClass[0].Description;
                    }
                    else if (editTextInput.Text.Equals(myDeserializedClass[1].SlangWord, StringComparison.OrdinalIgnoreCase))
                    {
                        showResult.Text = myDeserializedClass[1].Description;
                    }
                    else if (editTextInput.Text.Equals(myDeserializedClass[2].SlangWord, StringComparison.OrdinalIgnoreCase))
                    {
                        showResult.Text = myDeserializedClass[2].Description;
                    }
                    else
                    {
                        showResult.Text = Constants.NoMatch;
                    }
                }
            }
            catch (Exception ex)
            {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetTitle(Constants.Error);
                alertDialog.SetMessage(Constants.ErrorNotify + ex.Message);
                alertDialog.SetNeutralButton(Constants.Ok, delegate
                {
                    alertDialog.Dispose();
                });
                alertDialog.Show();
            }
        }
Example #22
0
        private void ItemLongClicked(object sender, AdapterView.ItemLongClickEventArgs args)
        {
            var contact = contacts[args.Position];

            var alert = new AlertDialog.Builder(this).Create();

            alert.SetTitle("Delete");
            alert.SetMessage(string.Format("Are you sure to delete {0}?", contact.Name));

            alert.SetButton("Yes", delegate
            {
                contacts.Remove(contact);
                adapter.NotifyDataSetChanged();
            });
            alert.SetButton2("No", delegate
            {
            });

            alert.Show();
        }
Example #23
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            SetContentView(Resource.Layout.activity_main);

            try
            {
                SidUs = (Intent.GetStringExtra("idUs"));
                idUS  = Convert.ToInt32(SidUs);
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message + "'asdasd'");
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }



            BottomNavigationView navigation = FindViewById <BottomNavigationView>(Resource.Id.navigation);

            navigation.SetOnNavigationItemSelectedListener(this);
            frame = FindViewById <FrameLayout>(Resource.Id.frameLayout);
            this.SetTitle(Resource.String.app_name);//nombre por defecto

            /// tengo que pasar el id

            Bundle bundle = new Bundle();

            bundle.PutString("idUs", SidUs);
            Inicio fragInfo = new Inicio();

            fragInfo.Arguments = bundle;
            var trans = SupportFragmentManager.BeginTransaction();

            trans.Replace(Resource.Id.frameLayout, fragInfo);
            trans.Commit();
        }
Example #25
0
        //==============================================================
        private void Cmd_adivinhar_Click(object sender, EventArgs e)
        {
            //analisa os dados inseridos versus o valor sorteado

            if (edit_valor.Text == "")
            {
                return;
            }

            string mensagem;
            int    valor_inserido = int.Parse(edit_valor.Text);

            if (valor_inserido < valor_sorteado)
            {
                mensagem = "O valor inserido é inferior ao sorteado.";
                numero_tentativas++;
            }
            else if (valor_inserido > valor_sorteado)
            {
                mensagem = "O valor inserido é superior ao sorteado.";
                numero_tentativas++;
            }
            else
            {
                //acertou

                mensagem = "Acertou.";
            }
            text_tentativas.Text = "Tentativas: " + numero_tentativas.ToString();

            AlertDialog.Builder caixa = new AlertDialog.Builder(this);
            caixa.SetTitle("Adivinha o Número");
            caixa.SetMessage(mensagem);
            caixa.SetPositiveButton("OK", delegate { });
            caixa.SetCancelable(false);
            caixa.Show();
        }
Example #26
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            Xamarin.Essentials.Platform.Init(this, savedInstanceState);

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

            this.babyEmotion = FindViewById <ImageView>(Resource.Id.babyEmotion);

            btn_voix_1   = FindViewById <Button>(Resource.Id.btn_voix_1);
            btn_voix_2   = FindViewById <Button>(Resource.Id.btn_voix_2);
            btn_voix_off = FindViewById <Button>(Resource.Id.btn_voix_off);

            initListeners();

            //Initialisation du référentiel
            AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
            alertDialog.SetTitle("Info");
            alertDialog.SetMessage("Posez le téléphone sur une surface plane, face vers le haut, et parallèle au sol");
            alertDialog.SetPositiveButton("C'est fait !", start);
            alertDialog.SetCancelable(false);
            alertDialog.Show();
        }
Example #27
0
        private void ShowDialogSelectKeySize()
        {
            string[] key_options = Resources.GetStringArray(Resource.Array.keyArray);
            var      builder     = new AlertDialog.Builder(this)
                                   .SetTitle("Выберите размер ключа")
                                   .SetNegativeButton("Отмена", CancelClicked)
                                   .SetPositiveButton("Oк", OKClicked)
                                   .SetSingleChoiceItems(key_options, 0, (o, e) =>
            {
                switch (e.Which)
                {
                case 0: key_size = Convert.ToInt32(key_options[0]); break;

                case 1: key_size = Convert.ToInt32(key_options[1]); break;

                case 2: key_size = Convert.ToInt32(key_options[2]); break;

                default: break;
                }
            });

            builder.Create();
            builder.Show();
        }
        public override void Prompt(PromptConfig config)
        {
            Utils.RequestMainThread(() => {
                var activity = this.GetTopActivity();

                var txt = new EditText(activity) {
                    Hint = config.Placeholder
                };
                if (config.Text != null)
                    txt.Text = config.Text;

                this.SetInputType(txt, config.InputType);

                var builder = new AlertDialog
                    .Builder(activity)
                    .SetCancelable(false)
                    .SetMessage(config.Message)
                    .SetTitle(config.Title)
                    .SetView(txt)
                    .SetPositiveButton(config.OkText, (s, a) =>
                        config.OnResult(new PromptResult {
                            Ok = true,
                            Text = txt.Text
                        })
                    );

                if (config.IsCancellable) {
                    builder.SetNegativeButton(config.CancelText, (s, a) =>
                        config.OnResult(new PromptResult {
                            Ok = false,
                            Text = txt.Text
                        })
                    );
                }

                builder.Show();
            });
        }
Example #29
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            var current = Connectivity.NetworkAccess;

            base.OnCreate(savedInstanceState);


            Xamarin.Essentials.Platform.Init(this, savedInstanceState);
            // Set our view from the "main" layout resource

            SetContentView(Resource.Layout.activity_main);

            if (current == NetworkAccess.Internet)
            {
                FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Gone;
                model.db_select select = new model.db_select();
                mail = FindViewById <EditText>(Resource.Id.mail);
                pass = FindViewById <EditText>(Resource.Id.pass);
                var savedChyper1  = Preferences.Get("cypher1", "");
                var savedCypher2  = Preferences.Get("cypher2", "");
                var savedUserData = Preferences.Get("user_data", "");
                if (savedChyper1 != "" && savedCypher2 != "" && savedUserData != "")
                {
                    FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Visible;

                    List <model.users> user_data = new List <model.users>();
                    user_data = JsonConvert.DeserializeObject <List <model.users> >(Preferences.Get("user_data", ""));


                    Intent next = new Intent(this, typeof(ProfileActivity));

                    StartActivity(next);
                    FindViewById <Button>(Resource.Id.button1).Text    = "Daxil ol";
                    FindViewById <Button>(Resource.Id.button1).Enabled = true;
                    FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Gone;
                }


                FindViewById <Button>(Resource.Id.button1).Click += async delegate
                {
                    string mailBox = FindViewById <EditText>(Resource.Id.mail).Text;
                    string passBox = FindViewById <EditText>(Resource.Id.pass).Text;

                    if (!string.IsNullOrEmpty(mailBox) && !string.IsNullOrEmpty(passBox))
                    {
                        if (IsValidEmail(mailBox))
                        {
                            FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Visible;
                            FindViewById <Button>(Resource.Id.button1).Enabled = false;
                            FindViewById <Button>(Resource.Id.button1).Text    = "Yüklənir...";

                            List <Cypher> cypher;

                            cypher = await select.SignIn(mail.Text, pass.Text);

                            if (!string.IsNullOrEmpty(cypher[0].cypher1) && !string.IsNullOrEmpty(cypher[0].cypher2))
                            {
                                List <model.users> user_data = new List <model.users>();
                                user_data = await select.UserAsync(cypher[0].cypher1, cypher[0].cypher2);

                                if (user_data.Count > 0)
                                {
                                    Intent next = new Intent(this, typeof(ProfileActivity));

                                    StartActivity(next);
                                    FindViewById <Button>(Resource.Id.button1).Text    = "Daxil ol";
                                    FindViewById <Button>(Resource.Id.button1).Enabled = true;


                                    Preferences.Set("user_data", JsonConvert.SerializeObject(user_data));
                                    Preferences.Set("cypher1", cypher[0].cypher1);
                                    Preferences.Set("cypher2", cypher[0].cypher2);
                                }
                                else
                                {
                                    AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                                    alertDialog.SetTitle("Bildiriş");
                                    alertDialog.SetMessage("Email və ya şifrənin düzgünlüyünə diqqət edin");
                                    alertDialog.Show();
                                    // Toast.MakeText(ApplicationContext, "email ve ya shifre yalnishdir", ToastLength.Long).Show();
                                    FindViewById <Button>(Resource.Id.button1).Text    = "Daxil ol";
                                    FindViewById <Button>(Resource.Id.button1).Enabled = true;
                                }
                            }
                            else
                            {
                                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                                alertDialog.SetTitle("Bildiriş");
                                alertDialog.SetMessage("Email və ya şifrənin düzgünlüyünə diqqət edin");
                                alertDialog.Show();
                                // Toast.MakeText(ApplicationContext, "email ve ya shifre yalnishdir", ToastLength.Long).Show();
                                FindViewById <Button>(Resource.Id.button1).Text    = "Daxil ol";
                                FindViewById <Button>(Resource.Id.button1).Enabled = true;
                            }
                            FindViewById <FrameLayout>(Resource.Id.progressBarHolder).Visibility = ViewStates.Gone;
                        }

                        else
                        {
                            FindViewById <EditText>(Resource.Id.mail).Error = "Zəhmət olmasa Email-nızın doğruluğuna diqqət edin";
                        }
                    }
                    else
                    {
                        if (string.IsNullOrEmpty(mailBox))
                        {
                            FindViewById <EditText>(Resource.Id.mail).Error = "Zəhmət olmasa Email-nızı doldurum";
                        }
                        if (string.IsNullOrEmpty(passBox))
                        {
                            FindViewById <EditText>(Resource.Id.pass).Error = "Zəhmət olmasa şifrənizi doldurum";
                        }
                    }
                };
            }
            else
            {
                AlertDialog.Builder alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetTitle("Bildiriş");
                alertDialog.SetMessage("Lütfən şəbəkə bağlantınızı yoxlayın");
                alertDialog.Show();
            }
        }
Example #30
0
        private void ButtonClickDelegate(User user, bool isCheckd)
        {
            if (isCheckd)
            {
                assignUserList.Add((Integer)user.UserId);

                if (userListType == resources.GetString(Resource.String.verify))
                {
                    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
                    alertBuilder.SetCancelable(false);
                    alertBuilder.SetMessage("Do you want to send this report to " + user.FullName + " for verification?");
                    alertBuilder.SetTitle("Send for Verification");
                    alertBuilder.SetPositiveButton("Yes", (sender, args) =>
                    {
                        Intent formActivity = new Intent(Application.Context, typeof(FormActivity));
                        formActivity.PutExtra(resources.GetString(Resource.String.assign_user_list_type),
                                              resources.GetString(Resource.String.verify));
                        formActivity.PutIntegerArrayListExtra(
                            resources.GetString(Resource.String.assign_user_id_list), assignUserList);
                        activity.SetResult(Result.Ok, formActivity);
                        activity.Finish();
                    });
                    alertBuilder.SetNegativeButton("No", (sender, args) =>
                    {
                        RemoveSelectedItem(user.UserId);
                        alertBuilder.Dispose();
                        userListAdapter = new UserListAdapter(this, userCompanies, selectedUserList, userListType);
                        userListAdapter.ButtonClickedOnAssignInvite += ButtonClickDelegate;
                        expandableListView.SetAdapter(userListAdapter);
                    });
                    alertBuilder.Show();
                }
                else if (userListType == resources.GetString(Resource.String.change_ownership))
                {
                    AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
                    alertBuilder.SetCancelable(false);
                    alertBuilder.SetMessage("Do you want to change ownership of this report to " +
                                            user.FullName + "?");
                    alertBuilder.SetTitle("Change Ownership");
                    alertBuilder.SetPositiveButton("Yes", (sender, args) =>
                    {
                        Intent formActivity = new Intent(Application.Context, typeof(FormActivity));
                        formActivity.PutExtra(resources.GetString(Resource.String.assign_user_list_type),
                                              resources.GetString(Resource.String.change_ownership));
                        formActivity.PutIntegerArrayListExtra(
                            resources.GetString(Resource.String.assign_user_id_list), assignUserList);
                        activity.SetResult(Result.Ok, formActivity);
                        activity.Finish();
                    });
                    alertBuilder.SetNegativeButton("No", (sender, args) =>
                    {
                        RemoveSelectedItem(user.UserId);
                        alertBuilder.Dispose();
                        userListAdapter = new UserListAdapter(this, userCompanies, selectedUserList, userListType);
                        userListAdapter.ButtonClickedOnAssignInvite += ButtonClickDelegate;
                        expandableListView.SetAdapter(userListAdapter);
                    });
                    alertBuilder.Show();
                }
                else
                {
                    Utility.DisplayToast(Application.Context, user.FullName + " has been added to report");
                }
                sharedPreferences.Edit().PutBoolean("ReportEditFlag", true).Commit();
            }
            else
            {
                RemoveSelectedItem(user.UserId);
                Utility.DisplayToast(Application.Context, "Removed " + user.FullName + " from report");
                sharedPreferences.Edit().PutBoolean("ReportEditFlag", false).Commit();
            }
        }
Example #31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.configCuenta);
            BtnFBLogin = FindViewById <LoginButton>(Resource.Id.fb_btn2);

            try
            {
                SiduS = (Intent.GetStringExtra("idUs"));
                idUS  = Convert.ToInt32(SiduS);
            }
            catch (Exception ex)
            {
                AlertDialog alerta = new AlertDialog.Builder(this).Create();
                alerta.SetTitle("Error ");
                alerta.SetMessage(ex.Message + "'asdasd'");
                alerta.SetButton("Aceptar", (a, b) => { });
                alerta.Show();
            }

            us = new Usuario();
            us = crus.mostrarDatosUsuario(idUS);


            var btnModificar = FindViewById <Button>(Resource.Id.btnModificar);

            txtNombre   = FindViewById <EditText>(Resource.Id.txtNombre);
            txtApellido = FindViewById <EditText>(Resource.Id.txtApellido);
            txtRut      = FindViewById <EditText>(Resource.Id.txtRut);


            txtContraseña    = FindViewById <EditText>(Resource.Id.txtPass);
            txtConfirmContra = FindViewById <EditText>(Resource.Id.txtConfirmPass);
            txtCorreo        = FindViewById <EditText>(Resource.Id.txtCorreo);
            txtConfirmCorreo = FindViewById <EditText>(Resource.Id.txtconfirmCorreo);
            txtFecNac        = FindViewById <Button>(Resource.Id.btnFecNac);

            spinnerTipoPrevision = FindViewById <Spinner>(Resource.Id.SpinnerTipoPre);
            spinnerPrevision     = FindViewById <Spinner>(Resource.Id.SpinnerPre);
            spinnerTipoSangre    = FindViewById <Spinner>(Resource.Id.SpinnerTipoSangre);
            spinnerFactorRh      = FindViewById <Spinner>(Resource.Id.SpinnerFactorRh);
            spinnerRegion        = FindViewById <Spinner>(Resource.Id.SpinnerRegion);
            spinnerCiudad        = FindViewById <Spinner>(Resource.Id.SpinnerCiudad);
            spinnerComuna        = FindViewById <Spinner>(Resource.Id.SpinnerComuna);
            spinnerTipoDiabetes  = FindViewById <Spinner>(Resource.Id.SpinnerTipoDiabetes);


            //carga de datos
            txtNombre.Text        = us.Nombre;
            txtApellido.Text      = us.Apellido;
            txtRut.Text           = us.Rut;
            txtCorreo.Text        = us.Uss;
            txtConfirmCorreo.Text = us.Uss;
            txtFecNac.Text        = us.FNac.ToShortDateString();



            //Spinners relacionados con isapres y fonasa

            spinnerTipoPrevision.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedPrev);
            var adapter = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraysTipoPrev, Android.Resource.Layout.SimpleSpinnerItem);

            adapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerTipoPrevision.Adapter = adapter;
            spinnerTipoPrevision.SetSelection(us.Fk_tipoPrevision - 1);


            //Spinner relacionados con tipo sangre
            spinnerTipoSangre.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedTipoSangre);
            var adapter2 = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraysTiposangre, Android.Resource.Layout.SimpleSpinnerItem);

            adapter2.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerTipoSangre.Adapter = adapter2;
            spinnerTipoSangre.SetSelection(us.Fk_TipoSangre - 1);

            //
            //Spinner Relacionado con factor Rh
            spinnerFactorRh.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedFactorRh);
            var adapter3 = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraysfactorRh, Android.Resource.Layout.SimpleSpinnerItem);

            adapter3.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerFactorRh.Adapter = adapter3;
            spinnerFactorRh.SetSelection(us.Fk_FactorRh - 1);

            //Spinner Region
            try
            {
                spinnerRegion.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedRegion);
                var adapterRegion = ArrayAdapter.CreateFromResource(
                    this, Resource.Array.Dropdown_arraysRegion, Android.Resource.Layout.SimpleSpinnerItem);
                adapterRegion.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
                spinnerRegion.Adapter = adapterRegion;
                spinnerRegion.SetSelection(us.Comuna.IdRegion - 1);
            }
            catch (Exception)
            {
                throw;
            }



            //Spinner Tipo Diabetes
            spinnerTipoDiabetes.ItemSelected += new EventHandler <AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedTipoDiabetes);
            var adapterDiabetes = ArrayAdapter.CreateFromResource(
                this, Resource.Array.Dropdown_arraystipoDiabetes, Android.Resource.Layout.SimpleSpinnerItem);

            adapterDiabetes.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            spinnerTipoDiabetes.Adapter = adapterDiabetes;
            spinnerTipoDiabetes.SetSelection(us.Fk_Eferglucosa - 1);



            //Spinner Comuna
            // spinnerComuna.ItemSelected += new EventHandler<AdapterView.ItemSelectedEventArgs>(spinner_ItemSelectedComuna);
            // var adapterComuna = ArrayAdapter.CreateFromResource(
            // this, Resource.Array.Dropdown_arraysComunasSantiago, Android.Resource.Layout.SimpleSpinnerItem);
            // adapterComuna.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            //spinnerComuna.Adapter = adapterComuna;


            btnModificar.Click += BtnModificar_Click;

            //llamada a botones
            txtFecNac.Click += Fecha_Click;

            try
            {
                //carga de datos
                txtNombre.Text   = us.Nombre;
                txtApellido.Text = us.Apellido;
                txtRut.Text      = us.Rut;
                //spinnerRegion.SetSelection(us.Comuna.IdRegion);
                // spinnerCiudad.SetSelection(us.Comuna.IdCiudad);
                // spinnerComuna.SetSelection(us.Comuna.IdComuna);
            }
            catch (Exception ex)
            {
                string toast = string.Format("Error: {0}", ex.Message);
                Toast.MakeText(this, toast, ToastLength.Long).Show();;
            }
        }