Example #1
0
        }                                               // caller should set so can use to dismiss

        public override Dialog OnCreateDialog(Bundle savedInstanceState)
        {
            OnCreate(savedInstanceState);

            // equivalent of an Activity's SetContentView
            var builder    = new AlertDialog.Builder(Activity);
            var inflator   = Activity.LayoutInflater;
            var dialogView = inflator.Inflate(Resource.Layout.LoginLayout, null);

            if (dialogView == null)
            {
                return(null);
            }

            var serverAddress = dialogView.FindViewById <EditText>(Resource.Id.serverIPEntry);
            var username      = dialogView.FindViewById <EditText>(Resource.Id.usernameEntry);
            var password      = dialogView.FindViewById <EditText>(Resource.Id.passwordEntry);
            var s             = DrawXSettingsManager.Settings;

            serverAddress.Text = s.ServerIP;
            username.Text      = s.Username;
            password.Text      = s.Password;

            builder.SetView(dialogView);
            builder.SetPositiveButton("Login", (sender, e) =>
            {
                bool changedServer = DrawXSettingsManager.UpdateCredentials(serverAddress.Text, username.Text, password.Text);
                ((AlertDialog)sender).Dismiss();
                OnCloseLogin(changedServer);
            });
            builder.SetNegativeButton("Cancel", (sender, e) =>
            {
                ((AlertDialog)sender).Dismiss();
            });
            var dialog = builder.Create();

            // you can only cancel logging in if already logged in, otherwise it is meaningless
            if (DrawXSettingsManager.LoggedInUser == null)
            {
                dialog.Show();  // instantiates so buttons can be accessed
                var negativeButton = dialog.GetButton((int)DialogButtonType.Negative);
                negativeButton.Enabled = false;
            }
            return(dialog);
        }
Example #2
0
        private void DoLogin()
        {
            bool changedServer = DrawXSettingsManager.UpdateCredentials(ServerEntry.Text, UsernameEntry.Text, PasswordEntry.Text);

            OnCloseLogin(changedServer);
        }