예제 #1
0
        //Alert handler to improve code cleanliness
        public AlertDialog CreateAlert(AlertType type, string alertMessage, string alertTitle)
        {
            if (type == AlertType.Error)
            {
                AlertDialog.Builder dialogConnection = new AlertDialog.Builder(this);
                dialog = dialogConnection.Create();
                dialog.SetTitle(alertTitle);
                dialog.SetMessage(alertMessage);
            }
            else if (type == AlertType.Load)
            {
                dialog = new EDMTDialogBuilder()
                         .SetContext(this)
                         .SetMessage(alertMessage)
                         .Build();
            }
            else if (type == AlertType.Info)
            {
                AlertDialog.Builder dialogConnection = new AlertDialog.Builder(this);
                var btnOk = Resources.GetText(Resource.String.btnOk);
                dialogConnection.SetPositiveButton(btnOk, (senderAlert, args) => {
                    dialogConnection.Dispose();
                });
                dialog = dialogConnection.Create();
                dialog.SetTitle(alertTitle);
                dialog.SetMessage(alertMessage);
                dialog.SetCanceledOnTouchOutside(true);
            }

            dialog.Show();

            return(dialog);
        }
        void OnActionSheetRequested(Page sender, ActionSheetArguments arguments)
        {
            var builder = new AlertDialog.Builder(this);

            builder.SetTitle(arguments.Title);
            string[] items = arguments.Buttons.ToArray();
            builder.SetItems(items, (o, args) => arguments.Result.TrySetResult(items[args.Which]));

            if (arguments.Cancel != null)
            {
                builder.SetPositiveButton(arguments.Cancel, (o, args) => arguments.Result.TrySetResult(arguments.Cancel));
            }

            if (arguments.Destruction != null)
            {
                builder.SetNegativeButton(arguments.Destruction, (o, args) => arguments.Result.TrySetResult(arguments.Destruction));
            }

            AlertDialog dialog = builder.Create();

            builder.Dispose();
            //to match current functionality of renderer we set cancelable on outside
            //and return null
            dialog.SetCanceledOnTouchOutside(true);
            dialog.CancelEvent += (o, e) => arguments.SetResult(null);
            dialog.Show();
        }
예제 #3
0
        /// <summary>
        /// Dialog for editing phone number
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditPhone_Click(object sender, EventArgs e)
        {
            LayoutInflater inflater = LayoutInflater.From(this);
            View           view     = inflater.Inflate(Resource.Layout.dialog_profile_phone, null);

            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
            alertBuilder.SetView(view);

            var editPhone = view.FindViewById <EditText>(Resource.Id.dialog_edit_phone);

            // editPhone.Text = phone.Text;

            alertBuilder.SetTitle("Edit Phone")
            .SetPositiveButton("Submit", delegate
            {
                Toast.MakeText(this, "You clicked Submit!", ToastLength.Short).Show();
            })
            .SetNegativeButton("Cancel", delegate
            {
                alertBuilder.Dispose();
            });

            AlertDialog alertDialog = alertBuilder.Create();

            alertDialog.Show();
        }
 private void btnGeoWithAddress_Click(object sender, EventArgs e)
 {
     search_view = base.LayoutInflater.Inflate(Resource.Layout.search_alert_layout, null);
     AlertDialog.Builder builder = new AlertDialog.Builder(this);
     builder.SetView(search_view);
     builder.SetTitle("Search Location");
     builder.SetNegativeButton("Cancel", (send, arg) => { builder.Dispose(); });
     search_view.FindViewById <Button>(Resource.Id.btnSearch).Click += btnSearchClicked;
     alert = builder.Create();
     alert.Show();
 }
예제 #5
0
        private void AlertIncomplete(string message)
        {
            var alert = new AlertDialog.Builder(this);

            alert.SetTitle("Incorrect operation");
            alert.SetMessage(message);
            alert.SetNeutralButton("OK", (senderAlert, args) => { alert.Dispose(); });

            Dialog dialog = alert.Create();

            dialog.Show();
        }
예제 #6
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void DeleteAccount_Click(object sender, EventArgs e)
        {
            LayoutInflater inflater = LayoutInflater.From(this);
            View           view     = inflater.Inflate(Resource.Layout.dialog_delete_account, null);

            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
            alertBuilder.SetView(view);

            var email    = view.FindViewById <EditText>(Resource.Id.dialog_delete_email);
            var password = view.FindViewById <EditText>(Resource.Id.dialog_delete_password);


            alertBuilder.SetTitle("Delete Account")
            .SetPositiveButton("Submit", delegate
            {
                try
                {
                    //update current user
                    var user = auth.CurrentUser;
                    if (user != null)
                    {
                        uid = user.Uid;

                        //delete from auth
                        var reauth = auth.CurrentUser.ReauthenticateAsync(EmailAuthProvider
                                                                          .GetCredential(email.Text, password.Text)).ContinueWith(task => {
                            if (task.IsCompletedSuccessfully)
                            {
                                Task result = user.Delete().AddOnCompleteListener(this);
                                Toast.MakeText(this, "Yeah!", ToastLength.Short).Show();
                            }
                            else
                            {
                                Toast.MakeText(this, "Failed to reauthenticate account.", ToastLength.Short).Show();
                            }
                        });
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Sorry, an error occured during delete", ToastLength.Short).Show();
                }
            })
            .SetNegativeButton("No", delegate
            {
                alertBuilder.Dispose();
            });

            AlertDialog alertDialog = alertBuilder.Create();

            alertDialog.Show();
        }
예제 #7
0
        /// <summary>
        /// Dialog for editing first and last name
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void EditName_Click(object sender, EventArgs e)
        {
            LayoutInflater inflater = LayoutInflater.From(this);
            View           view     = inflater.Inflate(Resource.Layout.dialog_profile_name, null);

            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
            alertBuilder.SetView(view);

            var fName = view.FindViewById <EditText>(Resource.Id.dialog_edit_fname);
            var lName = view.FindViewById <EditText>(Resource.Id.dialog_edit_lname);

            //string[] fullName = name.Text.Split(" ");
            //fName.Text = fullName[0];
            //lName.Text = fullName[1];

            alertBuilder.SetTitle("Edit Name")
            .SetPositiveButton("Submit", delegate
            {
                try
                {
                    //get current user
                    if (auth.CurrentUser != null)
                    {
                        var document = db.Collection("users").Document(auth.CurrentUser.Uid);
                        var data     = new Dictionary <string, Java.Lang.Object>();
                        data.Add("FName", fName.Text);
                        data.Add("LName", lName.Text);

                        document.Update((IDictionary <string, Java.Lang.Object>)data);

                        Toast.MakeText(this, "Done!", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "Something went wrong. Sorry.", ToastLength.Long).Show();
                    }
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "Failed to update. Sorry.", ToastLength.Long).Show();
                }
            })
            .SetNegativeButton("Cancel", delegate
            {
                alertBuilder.Dispose();
            });

            AlertDialog alertDialog = alertBuilder.Create();

            alertDialog.Show();
        }
예제 #8
0
        private void ShowDialog()
        {
            var layoutInflater = LayoutInflater.From(this);
            var mView          = layoutInflater.Inflate(Resource.Layout.AddDialog, null);
            var addDialog      = new AlertDialog.Builder(this);

            addDialog.SetView(mView);
            var content = mView.FindViewById <EditText>(Resource.Id.editText1);

            addDialog.SetCancelable(false)
            .SetPositiveButton("Add", delegate { insertSingleItem(content); })
            .SetNegativeButton("Cancel", delegate { addDialog.Dispose(); });
            var adialog = addDialog.Create();

            addDialog.Show();
        }
예제 #9
0
        private void DeleteGameActionButton_Click(object sender, EventArgs e)
        {
            AlertDialog.Builder deleteAlert = new AlertDialog.Builder(this);
            deleteAlert.SetMessage("Do you really want to delete this game?");
            deleteAlert.SetTitle("Delete game");

            deleteAlert.SetPositiveButton("Delete", (alert, args) =>
            {
                repo.DeleteGame(gameId);
                Finish();
                Toast.MakeText(this, "Game was deleted.", ToastLength.Short).Show();
            }
                                          );

            deleteAlert.SetNegativeButton("Cancel", (alert, args) =>
            {
                deleteAlert.Dispose();
            });
            deleteAlert.Show();
        }
예제 #10
0
 public static void ShowPopup(Context context, Activity activity, PopupMessage parameters)
 {
     var(title, message, positiveButtonText, negativeButtonText, positiveClick, negativeClick) = parameters;
     AlertDialog.Builder builder = new AlertDialog.Builder(context);
     builder.SetTitle(title);
     builder.SetMessage(message);
     if (!string.IsNullOrEmpty(positiveButtonText))
     {
         builder.SetPositiveButton(positiveButtonText, (senderAlert, args) => positiveClick());
     }
     if (!string.IsNullOrEmpty(negativeButtonText))
     {
         builder.SetNegativeButton(negativeButtonText, (senderAlert, args) => negativeClick());
     }
     activity.RunOnUiThread(() => {
         Dialog dialog = builder.Create();
         dialog.Show();
         builder.Dispose();
     });
 }
예제 #11
0
        private void Update(IUpdateInterface updateInterface)
        {
            LinearLayout linearLayout = new LinearLayout(this);

            linearLayout.LayoutParameters = new LinearLayout.LayoutParams(Android.Views.ViewGroup.LayoutParams.MatchParent, Android.Views.ViewGroup.LayoutParams.WrapContent);
            linearLayout.Orientation      = Orientation.Vertical;
            EditText editText = new EditText(this);

            linearLayout.AddView(editText);
            AlertDialog.Builder dialogBuilder =
                new AlertDialog.Builder(this).SetTitle("Update");
            dialogBuilder.SetPositiveButton("UPDATE", delegate
            {
                dialogBuilder.Dispose();
                // input photoUrl or display name
                string data = editText.Text.ToString().Trim();
                if (!TextUtils.IsEmpty(data))
                {
                    updateInterface.OnUpdate(data);
                }
            });
            dialogBuilder.SetView(linearLayout);
            dialogBuilder.Show();
        }
예제 #12
0
        //function when keyboard is clicked
        private void ButtonClick(object sender, EventArgs e)
        {
            //the current button being pressed
            Button currentButton = (Button)sender;

            //play the game
            tvWord.Text = operation.GamePlay(currentButton.Text);
            if (tvWord.Text == "win")
            {
                alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetCancelable(false);
                alertDialog.SetTitle("HangMan:");
                alertDialog.SetMessage(operation.winMessage());
                alertDialog.SetNeutralButton("Next Word", delegate
                {
                    //when game wins
                    //next round
                    alertDialog.Dispose();
                    operation.RestartGame();
                    initGameScreen();
                });
                alertDialog.Show();
            }

            //disable button
            currentButton.Enabled = false;
            //get how many tries the user has left to play
            switch (operation.getTries())
            {
            case 0:
                imgHangMan.SetImageResource(Resource.Drawable.first);
                break;

            case 1:
                imgHangMan.SetImageResource(Resource.Drawable.second);
                break;

            case 2:
                imgHangMan.SetImageResource(Resource.Drawable.third);
                break;

            case 3:
                imgHangMan.SetImageResource(Resource.Drawable.fourth);
                break;

            case 4:
                imgHangMan.SetImageResource(Resource.Drawable.fifth);
                break;

            case 5:
                imgHangMan.SetImageResource(Resource.Drawable.sixth);
                break;

            case 6:
                imgHangMan.SetImageResource(Resource.Drawable.seventh);
                break;

            case 7:
                imgHangMan.SetImageResource(Resource.Drawable.eigth);
                break;

            case 8:
                imgHangMan.SetImageResource(Resource.Drawable.ninth);
                break;

            case 9:
                imgHangMan.SetImageResource(Resource.Drawable.lose);
                alertDialog = new AlertDialog.Builder(this);
                alertDialog.SetCancelable(false);
                alertDialog.SetTitle("HangMan:");
                alertDialog.SetMessage("You have lost the game");
                alertDialog.SetNeutralButton("Restart", delegate
                {
                    //what to do when lost
                    alertDialog.Dispose();
                    Database.AddPlayerScore(operation.getName(), operation.getScore());
                    operation.RestartGame();
                    operation.restartScore();
                    RestartGame();
                });
                alertDialog.Show();
                break;
            }
        }
예제 #13
0
        private TextView showCurrentDate;           // see Date Picker bello --hjoab

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);
            //SetContentView(Resource.Layout.activity_main);


            // RadioButton Sample

            RadioButton radio_Ferrari = FindViewById <RadioButton>
                                            (Resource.Id.radioFerrari);
            RadioButton radio_Mercedes = FindViewById <RadioButton>
                                             (Resource.Id.radioMercedes);
            RadioButton radio_Lambo = FindViewById <RadioButton>
                                          (Resource.Id.radioLamborghini);
            RadioButton radio_Audi = FindViewById <RadioButton>
                                         (Resource.Id.radioAudi);

            radio_Ferrari.Click  += onClickRadioButton;
            radio_Mercedes.Click += onClickRadioButton;
            radio_Lambo.Click    += onClickRadioButton;
            radio_Audi.Click     += onClickRadioButton;

            // Button Sample

            Button button = FindViewById <Button>(Resource.Id.MyButton);

            button.Click += delegate { button.Text = "Hello world I am your first App"; };

            CheckBox checkMe = FindViewById <CheckBox>(Resource.Id.checkBox1);

            checkMe.CheckedChange += (object sender, CompoundButton.CheckedChangeEventArgs e) =>
            {
                CheckBox check = (CheckBox)sender;
                if (check.Checked)
                {
                    check.Text = "Checkbox has been checked";
                    Toast.MakeText(this, "Checkbox checked!", ToastLength.Short).Show();
                }
                else
                {
                    check.Text = "Checkbox has not been checked";
                    Toast.MakeText(this, "Checkbox unchecked!", ToastLength.Short).Show();
                }
            };

            // ProgressBar Sample

            ProgressBar pb = FindViewById <ProgressBar>(Resource.Id.progressBar1);

            pb.Progress = 35;

            ToggleButton togglebutton = FindViewById <ToggleButton>(Resource.Id.togglebutton);

            togglebutton.Click += (s, e) =>
            {
                if (togglebutton.Checked)
                {
                    Toast.MakeText(this, "Torch is ON", ToastLength.Short).Show();
                }
                else
                {
                    Toast.MakeText(this, "Torch is OFF",
                                   ToastLength.Short).Show();
                }
            };

            // AutoComplete Sample

            autoComplete1 = FindViewById <AutoCompleteTextView>(Resource.Id.autoComplete1);
            Button       btn_Submit = FindViewById <Button>(Resource.Id.btn_Submit);
            var          names      = new string[] { "John", "Peter", "Jane", "Britney" };
            ArrayAdapter adapter    = new ArrayAdapter <string>(this,
                                                                Android.Resource.Layout.SimpleSpinnerItem, names);

            autoComplete1.Adapter = adapter;
            btn_Submit.Click     += ClickedBtnSubmit;


            // RatingBar Sample

            var ratingBar = FindViewById <RatingBar>(Resource.Id.ratingBar1);

            ratingBar.RatingBarChange += (o, e) =>
            {
                Toast.MakeText(this, "New Rating: " + ratingBar.Rating.ToString(), ToastLength.Short).Show();
            };

            // Alert Dialog Sample

            Button buttonAlert = FindViewById <Button>(Resource.Id.buttonAlert);

            buttonAlert.Click += delegate {
                AlertDialog.Builder alertDiag = new AlertDialog.Builder(this);
                alertDiag.SetTitle("Confirm delete");
                alertDiag.SetMessage("Once deleted the move cannot be undone");
                alertDiag.SetPositiveButton("Delete", (senderAlert, args) => {
                    Toast.MakeText(this, "Deleted", ToastLength.Short).Show();
                });
                alertDiag.SetNegativeButton("Cancel", (senderAlert, args) => {
                    alertDiag.Dispose();
                });
                Dialog diag = alertDiag.Create();
                diag.Show();
            };
        }
예제 #14
0
        /// <summary>
        /// Change Password
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void ResetPassword_Click(object sender, EventArgs e)
        {
            LayoutInflater inflater = LayoutInflater.From(this);
            View           view     = inflater.Inflate(Resource.Layout.dialog_reset_password, null);

            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);
            alertBuilder.SetView(view);

            var newPassword   = view.FindViewById <EditText>(Resource.Id.dialog_reset_pass);
            var passwordRpt   = view.FindViewById <EditText>(Resource.Id.dialog_reset_pass_rpt);
            var passwordError = view.FindViewById <TextView>(Resource.Id.dialog_reset_pass_error);

            alertBuilder.SetTitle("Reset Password")
            .SetPositiveButton("Submit", delegate
            {
                try
                {
                    var user = auth.CurrentUser.UpdatePassword(newPassword.Text);

                    Toast.MakeText(this, "Done!", ToastLength.Long).Show();

                    //signout
                }
                catch (Exception ex)
                {
                    Toast.MakeText(this, "An error occured. Sorry.", ToastLength.Long).Show();
                }
            })
            .SetNegativeButton("Cancel", delegate
            {
                alertBuilder.Dispose();
            });

            AlertDialog alertDialog = alertBuilder.Create();

            alertDialog.Show();

            var submit = alertDialog.GetButton((int)DialogButtonType.Positive);

            submit.Click += delegate
            {
                if (!passwordRpt.Text.Equals(newPassword.Text))
                {
                    passwordError.Text = "Passwords must match";
                }
                else
                {
                    //update current user
                    var user = auth.CurrentUser;
                    if (user != null)
                    {
                        user.UpdatePassword(newPassword.Text);

                        Toast.MakeText(this, "Done!", ToastLength.Long).Show();
                    }
                    else
                    {
                        Toast.MakeText(this, "You are not logged in!", ToastLength.Long).Show();
                    }

                    alertDialog.Dismiss();
                }
            };
        }
예제 #15
0
        public void StartMotionDna()
        {
            if (devKey.Equals("<ENTER YOUR DEV KEY HERE>"))
            {
                var alert = new AlertDialog.Builder(this);
                alert.SetMessage("Enter your Navisens Dev Key.").SetCancelable(false).SetNeutralButton("Ok", delegate
                {
                    alert.Dispose();
                    return;
                }).Show();
            }

            motionDnaApplication = new MotionDnaApplication(this);

            //    This functions starts up the SDK. You must pass in a valid developer's key in order for
            //    the SDK to function. IF the key has expired or there are other errors, you may receive
            //    those errors through the reportError() callback route.

            motionDnaApplication.RunMotionDna(devKey);

            //    Use our internal algorithm to automatically compute your location and heading by fusing
            //    inertial estimation with global location information. This is designed for outdoor use and
            //    will not compute a position when indoors. Solving location requires the user to be walking
            //    outdoors. Depending on the quality of the global location, this may only require as little
            //    as 10 meters of walking outdoors.

            motionDnaApplication.SetLocationNavisens();

            //   Set accuracy for GPS positioning, states :HIGH/LOW_ACCURACY/OFF, OFF consumes
            //   the least battery.

            motionDnaApplication.SetExternalPositioningState(MotionDna.ExternalPositioningState.LowAccuracy);

            //    Manually sets the global latitude, longitude, and heading. This enables receiving a
            //    latitude and longitude instead of cartesian coordinates. Use this if you have other
            //    sources of information (for example, user-defined address), and need readings more
            //    accurate than GPS can provide.
            //        motionDnaApplication.setLocationLatitudeLongitudeAndHeadingInDegrees(37.787582, -122.396627, 0);

            //    Set the power consumption mode to trade off accuracy of predictions for power saving.

            motionDnaApplication.SetPowerMode(MotionDna.PowerConsumptionMode.Performance);

            //    Connect to your own server and specify a room. Any other device connected to the same room
            //    and also under the same developer will receive any udp packets this device sends.

            motionDnaApplication.StartUDP();

            //    Allow our SDK to record data and use it to enhance our estimation system.
            //    Send this file to [email protected] if you have any issues with the estimation
            //    that you would like to have us analyze.

            motionDnaApplication.SetBinaryFileLoggingEnabled(true);

            //    Tell our SDK how often to provide estimation results. Note that there is a limit on how
            //    fast our SDK can provide results, but usually setting a slower update rate improves results.
            //    Setting the rate to 0ms will output estimation results at our maximum rate.

            motionDnaApplication.SetCallbackUpdateRateInMs(500);

            //    When setLocationNavisens is enabled and setBackpropagationEnabled is called, once Navisens
            //    has initialized you will not only get the current position, but also a set of latitude
            //    longitude coordinates which lead back to the start position (where the SDK/App was started).
            //    This is useful to determine which building and even where inside a building the
            //    person started, or where the person exited a vehicle (e.g. the vehicle parking spot or the
            //    location of a drop-off).
            motionDnaApplication.SetBackpropagationEnabled(true);

            //    If the user wants to see everything that happened before Navisens found an initial
            //    position, he can adjust the amount of the trajectory to see before the initial
            //    position was set automatically.
            motionDnaApplication.SetBackpropagationBufferSize(2000);

            //    Enables AR mode. AR mode publishes orientation quaternion at a higher rate.

            //        motionDnaApplication.setARModeEnabled(true);
        }