示例#1
0
        private void ShowMotorConfigurationDialog(int joystickId, int joystickAxis)
        {
            // Build and display the motor configuration dialog
            AlertDialog motorConfigurationDialog = null;

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogStyle);

            builder.SetSingleChoiceItems(GetMotorList(),
                                         GetRelatedJoystickConfiguration(joystickId).MotorIndexes[joystickAxis],
                                         delegate(object sender, DialogClickEventArgs args)
            {
                // When one motor was clicked we set it and display the next dialog
                SetMotorIndex(joystickId, args.Which, joystickAxis);

                // ReSharper disable once AccessToModifiedClosure
                motorConfigurationDialog?.Dismiss();


                // If configured the first joystick axis we have to configure the second.
                // This can be done better but it works :)
                if (joystickAxis == 0)
                {
                    ShowMotorConfigurationDialog(joystickId, ++joystickAxis);
                }
            });

            builder.SetPositiveButton(Resource.String.ControlInterfaceActivity_configureJoystickMotor1DialogPositive,
                                      delegate
            {
                // ReSharper disable once AccessToModifiedClosure
                motorConfigurationDialog?.Dismiss();

                // If configured the first joystick axis we have to configure the second.
                if (joystickAxis == 0)
                {
                    ShowMotorConfigurationDialog(joystickId, ++joystickAxis);
                }
            });

            if (joystickAxis == 0)
            {
                builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickMotor1DialogTitle);
            }
            else if (joystickAxis == 1)
            {
                builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickMotor2DialogTitle);
            }

            builder.SetCancelable(false);

            motorConfigurationDialog = builder.Create();

            motorConfigurationDialog.Show();
        }
示例#2
0
 private void ShowErrorMessage(string msg)
 {
     AlertDialog.Builder alert = new AlertDialog.Builder(this, Resource.Style.Dialog);
     alert.SetTitle(Resource.String.str_error).SetMessage(msg)
     .SetPositiveButton(Resource.String.btn_ok, (s, e) => { });
     alert.Show();
 }
示例#3
0
        /// <summary>
        /// ShowMessage
        /// </summary>
        /// <param name="message"></param>
        /// <param name="title"></param>
        /// <param name="firstButtonContent"></param>
        /// <param name="nextButtonContent"></param>
        /// <param name="lastButtonContent"></param>
        /// <returns></returns>
        public async Task <ButtonDialog> ShowMessage(string title, string message, string firstButtonContent, string nextButtonContent, string lastButtonContent)
        {
            var tcs     = new TaskCompletionSource <ButtonDialog>();
            var builder = new AlertDialog.Builder(CrossCurrentActivity.Current.Activity, Resource.Style.AppCompatAlertDialogStyle);

            builder.SetTitle(title)
            .SetMessage(message)
            .SetCancelable(false)
            .SetPositiveButton(firstButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Primary); })
            .SetNeutralButton(lastButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Close); })
            .SetNegativeButton(nextButtonContent, (s, args) => { tcs.TrySetResult(ButtonDialog.Secondary); });

            var alert = builder.Create();

            alert.Show();

            var btnPositive  = alert.GetButton((int)DialogButtonType.Positive);
            var btnNegative  = alert.GetButton((int)DialogButtonType.Negative);
            var btnNeutral   = alert.GetButton((int)DialogButtonType.Neutral);
            var layoutParams = (LinearLayout.LayoutParams)btnPositive.LayoutParameters;

            layoutParams.Gravity = GravityFlags.Center;

            btnPositive.LayoutParameters = layoutParams;
            btnNegative.LayoutParameters = layoutParams;
            btnNeutral.LayoutParameters  = layoutParams;

            return(await tcs.Task);
        }
示例#4
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();
        }
示例#5
0
        private void TxtWidth_FocusChange(object sender, View.FocusChangeEventArgs e)
        {
            var txt = (EditText)sender;

            if (txt.Text != string.Empty)
            {
                var resp = Validartxt(txt);

                if (resp == false)
                {
                    alert.Builder adb = new alert.Builder(this);

                    adb.SetTitle("Advertencia?");
                    adb.SetMessage("Verifique el datos ingresado " + txt.Text + " y corregir!!!");
                    adb.SetNeutralButton("Mantener Dato", (senderAlert, args) =>
                    {
                    });
                    adb.SetPositiveButton("Borrar Dato Ingresado", (senderAlert, args) =>
                    {
                        txt.Text = "";
                        txt.RequestFocus();
                    });

                    alert dialog = adb.Create();

                    dialog.Show();
                }
                else
                {
                    txt.Focusable = true;
                }
            }
        }
示例#6
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.play);

            //彈出視窗解說:
            AlertDialog.Builder alert_play = new AlertDialog.Builder(this);  // For initial tips dialog
            if (counter == 0)
            {
                alert_play.SetTitle("注意事項");
                alert_play.SetMessage("1. 請確認影片畫質是否正常且人臉完全包覆於合理範圍中,若不符合請\u201C返回操作\u201C重新測謊.\n" +
                                      "2. 確認無誤後,即可\u201C上傳檔案\u201C進行測謊分析.\n" +
                                      "3. 點選\u201C查看結果\u201C觀看測謊結果!!!");
                alert_play.SetIcon(Android.Resource.Drawable.IcDialogInfo);
                alert_play.SetPositiveButton(" ok", new EventHandler <DialogClickEventArgs>((sender, e) => { }));
                alert_play.Show();
                counter++;
            }

            // 跑馬燈
            TextView play_tv = FindViewById <TextView>(Resource.Id.playtextview);

            play_tv.Selected = true;

            FindViewById <Button>(Resource.Id.btn_back).Click += Back_Click;
            //FindViewById<Button>(Resource.Id.btn_upload).Click += Back_Upload;
            FindViewById <Button>(Resource.Id.btn_play).Click   += Back_Play;
            FindViewById <Button>(Resource.Id.btn_result).Click += Back_Result;
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            switch (id)
            {
            case Resource.Id.action_exit:
                timer.Stop();
                AlertDialog.Builder alert = new AlertDialog.Builder(this);

                alert.SetTitle("Confirm EXIT");

                alert.SetMessage("Do you want to Exit?");

                alert.SetPositiveButton("Yes", (senderAlert, args) => {
                    StartActivity(new Intent(Application.Context, typeof(ScoreviewActivity)));
                    Finish();
                });

                alert.SetNegativeButton("Cancel", (senderAlert, args) => {
                    timer.Start();
                });

                Dialog dialog = alert.Create();

                dialog.Show();
                break;

            default:
                break;
            }
            return(base.OnOptionsItemSelected(item));
        }
示例#8
0
        public override void OnBackPressed()
        {
            if (_isEdited)
            {
                var alert = new AlertDialog.Builder(this);
                alert.SetTitle("Avertisment");
                alert.SetMessage("Esti pe cale sa renunti la modificarile facute. Renuntati?");
                alert.SetPositiveButton("Da", (senderAlert, args) => {
                    base.OnBackPressed();
                });

                alert.SetNegativeButton("Nu", (senderAlert, args) => {
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            }
            else
            {
                //base.OnBackPressed();
                var intent = new Intent(this, typeof(MedicineBaseActivity));
                intent.AddFlags(ActivityFlags.ClearTop);
                intent.PutExtra("FromMedicine", true);
                StartActivity(intent);
            }
        }
示例#9
0
        /// <summary>
        /// Shows an alert dialog with two buttons.
        /// </summary>
        /// <param name="title"></param>
        /// <param name="message"></param>
        /// <param name="okButtonText"></param>
        /// <param name="cancelButtonText"></param>
        /// <param name="okCallback"></param>
        /// <param name="cancelCallback"></param>
        public void ShowPopup(string title, string message, string okButtonText, string cancelButtonText, Action okCallback,
                              Action cancelCallback, bool dismissable = false, Action dismissCallback = null)
        {
            var top = Mvx.Resolve <IMvxAndroidCurrentTopActivity>();

            if (top == null)
            {
                // may occur if in middle of transition
                return;
            }

            AlertDialog.Builder builder = new AlertDialog.Builder(top.Activity);
            builder.SetMessage(message);
            builder.SetTitle(title);
            builder.SetNegativeButton(cancelButtonText, (o, args) =>
            {
                cancelCallback?.Invoke();
            });
            builder.SetPositiveButton(okButtonText, (o, args) =>
            {
                okCallback?.Invoke();
            });
            builder.SetCancelable(dismissable);
            var dialog = builder.Create();

            // set the dismiss callback, note that this is not the same as tapping cancel
            dialog.CancelEvent += (sender, args) => dismissCallback?.Invoke();
            top.Activity.RunOnUiThread(() => { dialog.Show(); });
        }
示例#10
0
        public void downloadBook(object senderr, EventArgs ee)
        {
            gone(rlReadAaSet);
            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetTitle("缓存多少章?")
            .SetItems(new String[] { "后面五十章", "后面全部", "全部" }, (sender, e) =>
            {
                switch (e.Which)
                {
                case 0:
                    DownloadBookService.Post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, currentChapter + 50));
                    break;

                case 1:
                    DownloadBookService.Post(new DownloadQueue(bookId, mChapterList, currentChapter + 1, mChapterList.Count()));
                    break;

                case 2:
                    DownloadBookService.Post(new DownloadQueue(bookId, mChapterList, 1, mChapterList.Count()));
                    break;

                default:
                    break;
                }
            });
            builder.Show();
        }
示例#11
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Android.Resource.Id.Home:
                startBack();
                return(true);

            case Resource.Id.action_invisible:

                //Menu de contexto confirmacao
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle(GetString(Resource.String.confirmTitle));
                alert.SetMessage(GetString(Resource.String.confirmMSG));
                alert.SetPositiveButton(GetString(Resource.String.confirmOk), (senderAlert, args) =>
                {
                    appPreferences.clearPreferences();
                    SingOutApp();
                    startBackLogin();
                });

                alert.SetNegativeButton(GetString(Resource.String.confirmNOk), (senderAlert, args) =>
                {
                });

                Dialog dialog = alert.Create();
                dialog.Show();

                return(true);

            default:
                return(base.OnOptionsItemSelected(item));
            }
        }
示例#12
0
        protected override void OnStart()
        {
            base.OnStart();
            active = true;
            var connectivityManager = (ConnectivityManager)GetSystemService(ConnectivityService);
            var activeConnection    = connectivityManager.ActiveNetworkInfo;

            if ((activeConnection == null) || !activeConnection.IsConnected)
            {
                // brak połączenia z siecią
                AlertDialog.Builder alert = new AlertDialog.Builder(this);

                alert.SetTitle("Błąd:");
                alert.SetMessage("Brak połączenia z internetem!");
                alert.SetPositiveButton("Ok", (senderAlert, args) => {
                    //
                });
                alert.Create().Show();
            }
            else
            {
                if (viewSwitcher.CurrentView != progressLayout)
                {
                    viewSwitcher.ShowNext();
                }
                GetData();
            }
        }
示例#13
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.action_setsource:
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Last.fm username");
                var input = new EditText(this);
                alert.SetView(input);
                alert.SetNegativeButton("Cancel", (o, ea) => { });
                alert.SetPositiveButton("OK", async(o, ea) =>
                {
                    LastFM.SourceUser = input.Text;
                    await LastFM.Reload();
                    scrobblesView.SetAdapter(LastFM.ReythAdapter);
                });
                alert.Show();
                return(true);

            case Resource.Id.action_reload:
                RunOnUiThread(async() =>
                {
                    await LastFM.Reload();
                    scrobblesView.SetAdapter(LastFM.ReythAdapter);
                });
                return(true);
            }
            return(false);
        }
        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();
        }
示例#15
0
        private void ListView_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.SetTitle("Do you want to delete this payment?");

            alert.SetPositiveButton("Yes", (senderAlert, args) =>
            {
                friendsToPayment.Remove(friendsToPayment[e.Position]);
                var adapterPayemnt = new PaymentAddAdapter(this, friendsToPayment);

                listView.Adapter = adapterPayemnt;
                try
                {
                    editText.Text = friendsToPayment.Where(s => s.Item2 > 0).Sum(s => s.Item2).ToString();
                }
                catch (Exception)
                {
                    Toast.MakeText(this, "Sum to big!", ToastLength.Short).Show();
                }
                //apter = new FriendsCustomAdapter(this, users);
                //tData = FindViewById<ListView>(Resource.Id.listViewFriends);
                //tData.Adapter = adapter;
            });

            alert.SetNegativeButton("No", (senderAlert, args) => {
            });
            //run the alert in UI thread to display in the screen
            RunOnUiThread(() => {
                alert.Show();
            });
        }
        private async void SaveOnClick(object sender, EventArgs eventArgs)
        {
            if (RequestStoragePermission())
            {
                View                view     = (View)sender;
                EditText            editText = new EditText(this);
                AlertDialog.Builder builder  = new AlertDialog.Builder(this);
                var fileText = await Task.Run(() => ViewModel.ReadTextAsync());

                editText.Text = fileText;
                builder.SetTitle("Save Text");
                builder.SetView(editText);
                builder.SetPositiveButton("Save", (s, args) =>
                {
                    if (String.IsNullOrWhiteSpace(editText.Text))
                    {
                        Snackbar.Make(view, Resource.String.enter_input, Snackbar.LengthShort)
                        .SetAction("Action", (Android.Views.View.IOnClickListener)null).Show();
                        return;
                    }
                    else
                    {
                        _ = ViewModel.SaveTextAsync(editText.Text);
                        Snackbar.Make(view, Resource.String.data_saved, Snackbar.LengthShort)
                        .SetAction("Action", (Android.Views.View.IOnClickListener)null).Show();
                    }
                });
                builder.Show();
            }
        }
示例#17
0
        private void ShowModeConfigurationDialog(int joystickId)
        {
            // Build and display the mode configuration dialog
            AlertDialog modeConfigurationDialog = null;

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, Resource.Style.AlertDialogStyle);

            builder.SetSingleChoiceItems(Resource.Array.JoystickModes,
                                         (int)GetRelatedJoystickConfiguration(joystickId).JoystickMode,
                                         delegate(object sender, DialogClickEventArgs args)
            {
                ConfigureJoystickAxis((JoystickConfiguration.JoystickModes)args.Which, joystickId);

                // ReSharper disable once AccessToModifiedClosure
                modeConfigurationDialog?.Dismiss();
            });

            builder.SetPositiveButton(Resource.String.ControlInterfaceActivity_configureJoystickModeDialogPositive,
                                      delegate
            {
                // ReSharper disable once AccessToModifiedClosure
                modeConfigurationDialog?.Dismiss();
            });


            builder.SetTitle(Resource.String.ControlInterfaceActivity_configureJoystickModeDialogTitle);
            builder.SetCancelable(false);

            modeConfigurationDialog = builder.Create();

            modeConfigurationDialog.Show();
        }
        private void ShowPictureDialog()
        {
            var pictureDialog = new AlertDialog.Builder(this, Resource.Style.AppTheme_Dialog);

            pictureDialog.SetTitle("Incarcati o imagine");
            string[] pictureDialogItems =
            {
                "Alegeti din galerie",
                "Faceti una acum"
            };
            pictureDialog.SetItems(pictureDialogItems,
                                   delegate(object sender, DialogClickEventArgs args)
            {
                Contract.Requires(sender != null);
                switch (args.Which)
                {
                case 0:
                    ChoosePhotoFromGallary();
                    break;

                case 1:
                    TakePhotoFromCamera();
                    break;
                }
            });
            pictureDialog.Show();
        }
 void downloadWhatsAppFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     RunOnUiThread(() => {
         progressDialog.Dismiss();
         if (downloadedOK)
         {
             var installApk = new Intent(Intent.ActionView);
             installApk.SetDataAndType(Android.Net.Uri.Parse("file://" + fullLatestWhatsAppFilename), "application/vnd.android.package-archive");
             installApk.SetFlags(ActivityFlags.NewTask);
             try {
                 StartActivity(installApk);
                 AlertDialog deleteWhatsApp = new AlertDialog.Builder(this).Create();
                 deleteWhatsApp.SetTitle(Resources.GetString(Resource.String.delete));
                 deleteWhatsApp.SetMessage(Resources.GetString(Resource.String.delete_description));
                 deleteWhatsApp.SetButton((int)DialogButtonType.Positive, Resources.GetString(Resource.String.delete_button_delete), (object senderDelete, DialogClickEventArgs eDelete) => File.Delete(fullLatestWhatsAppFilename));
                 deleteWhatsApp.SetButton((int)DialogButtonType.Negative, Resources.GetString(Resource.String.delete_button_cancel), (object senderCancel, DialogClickEventArgs eCancel) => deleteWhatsApp.Dismiss());
                 deleteWhatsApp.SetCancelable(false);
                 deleteWhatsApp.Show();
             } catch (ActivityNotFoundException ex) {
                 var errorInstalled = new AlertDialog.Builder(this).Create();
                 errorInstalled.SetTitle(Resources.GetString(Resource.String.download_error));
                 errorInstalled.SetMessage(string.Format(Resources.GetString(Resource.String.download_error_description), "WhatsApp " + latestWhatsAppVersion));
                 errorInstalled.Show();
             }
             downloadedOK = false;
         }
         else
         {
             File.Delete(fullLatestWhatsAppFilename);
         }
     });
 }
 void downloadAppFileCompleted(object sender, AsyncCompletedEventArgs e)
 {
     RunOnUiThread(() => {
         progressDialog.Dismiss();
         if (downloadedOK)
         {
             var installApk = new Intent(Intent.ActionView);
             installApk.SetDataAndType(Android.Net.Uri.Parse("file://" + fullLatestAppFilename), "application/vnd.android.package-archive");
             installApk.SetFlags(ActivityFlags.NewTask);
             try {
                 StartActivity(installApk);
             } catch (ActivityNotFoundException ex) {
                 var errorInstalled = new AlertDialog.Builder(this).Create();
                 errorInstalled.SetTitle(Resources.GetString(Resource.String.download_error));
                 errorInstalled.SetMessage(string.Format(Resources.GetString(Resource.String.download_error_description), Resources.GetString(Resource.String.app_name) + " " + latestAppVersion));
                 errorInstalled.Show();
             }
             downloadedOK = false;
         }
         else
         {
             File.Delete(fullLatestAppFilename);
         }
     });
 }
示例#21
0
        void schedule_ScheduleCellTapped(object sender, CellTappedEventArgs args)
        {
            var appointment = args.ScheduleAppointment;

            if (appointment != null)
            {
                AlertDialog.Builder alert = new AlertDialog.Builder(this);
                alert.SetTitle("Confirm delete");
                alert.SetMessage(appointment.Subject);
                alert.SetPositiveButton("Delete", async(senderAlert, arg) =>
                {
                    await apiClient.DeleteWorkplaceOrderAsync((int)appointment.RecurrenceId);
                    Toast.MakeText(this, "Deleted!", ToastLength.Short).Show();
                    Orders.Remove(appointment);
                    schedule.ItemsSource = Orders;
                    SetContentView(schedule);
                });

                alert.SetNegativeButton("Cancel", (senderAlert, arg) =>
                {
                    Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show();
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            }
        }
示例#22
0
        private void MaxDownloadClick(object sender, Preference.PreferenceClickEventArgs e)
        {
            View pickerView = LayoutInflater.Inflate(Resource.Layout.NumberPicker, null);

            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
            builder.SetTitle(Resources.GetString(Resource.String.max_download_dialog));
            builder.SetView(pickerView);
            NumberPicker picker = (NumberPicker)pickerView;

            picker.MinValue = 1;
            picker.MaxValue = 10;
            picker.Value    = int.Parse(FindPreference("maxDownload").Summary);

            builder.SetPositiveButton(Resources.GetString(Resource.String.apply), (s, eventArg) =>
            {
                ISharedPreferences pref         = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                ISharedPreferencesEditor editor = pref.Edit();
                editor.PutInt("maxDownload", picker.Value);
                editor.Apply();

                Preference prefButton = FindPreference("maxDownload");
                prefButton.Summary    = pref.GetInt("maxDownload", 2).ToString();

                if (Downloader.instance != null && Downloader.queue.Count > 0)
                {
                    Downloader.instance.maxDownload = pref.GetInt("maxDownload", 4);
                }
            });
            builder.SetNegativeButton(Resources.GetString(Resource.String.cancel), (s, eventArg) => { });
            builder.Show();
        }
示例#23
0
 private void ShowRetryDialog()
 {
     AlertDialog.Builder builder = new AlertDialog.Builder(this);
     builder.SetCancelable(false);
     builder.SetTitle("메시지 분류에 실패했습니다.");
     builder.SetMessage("다시 시도하시겠습니까?");
     builder.SetPositiveButton("예", (senderAlert, args) =>
     {
         Categorize();
     });
     builder.SetNegativeButton("아니오", (senderAlert, args) =>
     {
         AlertDialog.Builder builder2 = new AlertDialog.Builder(this);
         builder2.SetTitle("메시지를 나중에 분류할 수 있습니다.");
         builder2.SetMessage("메시지 분류를 미루시겠습니까?");
         builder2.SetPositiveButton("예", (senderAlert2, args2) =>
         {
             MoveToNextScreen();
         });
         builder2.SetNegativeButton("아니오", (senderAlert2, args2) =>
         {
             RunOnUiThread(() => { _NextBtn.Clickable = true; });                            //버튼 누를 수 있게 풀어줘야 됨.
         });
         RunOnUiThread(() =>
         {
             Dialog dialog2 = builder2.Create();
             dialog2.Show();
         });
     });
     RunOnUiThread(() =>
     {
         Dialog dialog = builder.Create();
         dialog.Show();
     });
 }
示例#24
0
        //---------------------------------------------------------------------
        // 개인정보취급방침 다이얼로그

        private AlertDialog.Builder CreatePrivacyDialog()
        {
            string       privacyPolicyStr;
            AssetManager assets = this.Assets;

            using (StreamReader sr = new StreamReader(assets.Open("PrivacyPolicy.txt")))
            {
                privacyPolicyStr = sr.ReadToEnd();
            }

            AlertDialog.Builder builder = new AlertDialog.Builder(this);
            builder.SetCancelable(false);
            builder.SetTitle("개인정보취급방침에 동의하시겠습니까?");
            builder.SetMessage(privacyPolicyStr);
            builder.SetPositiveButton("예", (senderAlert, args) =>
            {
                MoveToNextScreen();
            });
            builder.SetNegativeButton("아니오", (senderAlert, args) =>
            {
                RunOnUiThread(() =>
                {
                    Toast.MakeText(this, "개인정보취급방침에 동의해주셔야 레뜨레를 사용하실 수 있습니다.", ToastLength.Short).Show();
                    _NextBtn.Clickable = true;                                                                              //버튼 누를 수 있게 풀어줘야 됨.
                });
            });
            return(builder);
        }
        private void ListViewClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            AlertDialog.Builder alert = new AlertDialog.Builder(this);

            alert.SetTitle("Do you want add to your friends?");

            alert.SetPositiveButton("Yes", async(senderAlert, args) =>
            {
                FriendItem item = new FriendItem {
                    FriendId = users[e.Position].Id, UserId = HomeActivity1.userItem.Id
                };
                await DatabaseManager.DefaultManager.SaveFriendItemAsync(item);
                users.Remove(users[e.Position]);
                adapter         = new FriendsCustomAdapter(this, users);
                lstData         = FindViewById <ListView>(Resource.Id.listViewFriends);
                lstData.Adapter = adapter;
            });

            alert.SetNegativeButton("No", (senderAlert, args) => {
            });
            //run the alert in UI thread to display in the screen
            RunOnUiThread(() => {
                alert.Show();
            });
        }
        private void SetDeleteMark()
        {
            AlertDialog.Builder quitDialog = new AlertDialog.Builder(this);
            quitDialog.SetTitle("Вы уверены?");
            quitDialog.SetPositiveButton("Да", (senderAlert, args) =>
            {
                var item = mAdapterDataList.GetItemAtPosition(mSelectedItemPosition);

                Dictionary <long, ElementData> mCommands = new Dictionary <long, ElementData>();
                mCommands.Add(0, new ElementData()
                {
                    Name = "delete", Data = "delete"
                });
                string output               = JsonConvert.SerializeObject(mCommands);
                DataSetWS dataSetWS         = new DataSetWS();
                dataSetWS.SetDataCompleted += DataSetWS_SetDataCompleted;
                dataSetWS.SetDataAsync(mRef, item.Ref, output, AppVariable.Variable.getSessionParametersJSON());
                mCommands.Remove(0);
            });
            quitDialog.SetNegativeButton("Нет", (senderAlert, args) =>
            {
            });
            Dialog dialog = quitDialog.Create();

            dialog.Show();
        }
示例#27
0
 /// <summary>
 /// Display an error dialog saying IA cannot find a playable move.
 /// </summary>
 private void ShowErrorDialog()
 {
     AlertDialog.Builder alert = new AlertDialog.Builder(this);
     alert.SetTitle("Error");
     alert.SetMessage("Application cannot find a playable move.");
     alert.SetNeutralButton("Go back", delegate { base.OnBackPressed(); });
     alert.Show();
 }
示例#28
0
            //##################################################################################

            public DialogCredentialsInput(Context context, EventHandler <DialogCredentialsInputEventArgs> OnLoginEntered)
            {
                _context = context;

                //Dialogcontent erstellen
                con = new ViewHolder();
                LayoutInflater i    = LayoutInflater.FromContext(context);
                View           view = i.Inflate(Resource.Layout.dialog_login, null, false);

                con.TEXT_USERNAME   = view.FindViewById <TextInputEditText>(Resource.Id.text_username);
                con.TEXT_PASSWORD   = view.FindViewById <TextInputEditText>(Resource.Id.text_password);
                con.LAYOUT_USERNAME = view.FindViewById <TextInputLayout>(Resource.Id.layout_username);
                con.LAYOUT_PASSWORD = view.FindViewById <TextInputLayout>(Resource.Id.layout_password);

                con.TEXT_USERNAME.Text = TBL.Username;
                con.TEXT_PASSWORD.Text = TBL.Password;

                //Dialog erstellen
                AlertDialog.Builder builder = new AlertDialog.Builder(context);
                builder.SetTitle(context.Resources.GetString(Resource.String.settings_dialog_cred_title));
                builder.SetMessage(context.Resources.GetString(Resource.String.settings_dialog_cred_msg));

                builder.SetNegativeButton(_context.Resources.GetString(Resource.String.dialog_cancel), (s, e) => { });
                builder.SetPositiveButton(_context.Resources.GetString(Resource.String.dialog_login), (s, e) => { });

                builder.SetView(view);
                con.dialog = builder.Show();

                con.dialog.GetButton((int)DialogButtonType.Positive).Click += (s, e) =>
                {
                    string user = con.TEXT_USERNAME.Text.ToLower();
                    string pass = con.TEXT_PASSWORD.Text;

                    bool valid = true;
                    if (string.IsNullOrWhiteSpace(user) || !user.EndsWith("malteser.org"))
                    {
                        valid = false;
                        con.LAYOUT_USERNAME.Error = context.Resources.GetString(Resource.String.settings_dialog_cred_error_email);
                    }
                    if (string.IsNullOrWhiteSpace(pass))
                    {
                        valid = false;
                        con.LAYOUT_PASSWORD.Error = context.Resources.GetString(Resource.String.settings_dialog_cred_error_pass);
                    }
                    if (valid)
                    {
                        con.LAYOUT_USERNAME.Error = string.Empty;
                        con.LAYOUT_PASSWORD.Error = string.Empty;
                    }
                    else
                    {
                        return;
                    }

                    OnLoginEntered?.Invoke(this, new DialogCredentialsInputEventArgs(con.TEXT_USERNAME.Text, con.TEXT_PASSWORD.Text));
                    con.dialog.Dismiss();
                };
            }
示例#29
0
 private void OpenRemarksButton_Click(object sender, EventArgs e)
 {
     _builder = new AlertDialog.Builder(this);
     _builder
     .SetTitle(Resource.String.aboutme_remark_title)
     .SetMessage(Resource.String.aboutme_remark_text)
     .SetNeutralButton(Resource.String.aboutme_remark_ok, delegate { });
     _builder.Create().Show();
 }
示例#30
0
        void ShowCopyright()
        {
            AlertDialog.Builder dialogBuilder = new AlertDialog.Builder(this);
            dialogBuilder
            .SetTitle(GetString(Resource.String.cnhspotlight_copyright_title))
            .SetMessage(GetString(Resource.String.cnhspotlight_copyright_content))
            .SetPositiveButton("Ok", (o, e) => { });

            dialogBuilder.Create().Show();
        }
		private void InitializeRecyclerView () {
			RecyclerView recyclerView = FindViewById<RecyclerView> (Resource.Id.HomeLayoutRecyclerView);
			TodoAdapter adapter = new TodoAdapter (Todos);
			recyclerView.SetAdapter (adapter);

			adapter.ItemClickEvent += (object sender, int position) => {
				var builder = new AlertDialog.Builder(this);
				builder.SetTitle(Todos[position].Name)
					.SetMessage(Todos[position].Description)
					.SetPositiveButton("Got it", delegate {});
				builder.Create().Show();
			};

			recyclerView.SetLayoutManager (new LinearLayoutManager(this, LinearLayoutManager.Vertical, false));
		}
		protected override void OnCreate (Bundle savedInstanceState)
		{
			base.OnCreate (savedInstanceState);
			SetContentView (Resource.Layout.Home);

			InitializeToolbar ();
			Todos = TodoFactory.GetTodos ();
			InitializeRecyclerView ();

			FloatingActionButton fab = FindViewById<FloatingActionButton> (Resource.Id.fab);
			fab.Click += (object sender, EventArgs e) => {
				var builder = new AlertDialog.Builder(this);
				builder.SetTitle("Notification")
					.SetMessage("You clicked the Action Button!")
					.SetPositiveButton("OK", delegate {});
				builder.Create().Show();
			};
		}
		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			view = inflater.Inflate(Resource.Layout.file_list_fragment, container, false);

			var refresher = view.FindViewById<SwipeRefreshLayout>(Resource.Id.srl);
			if (refresher != null) {
				refresher.Refresh += delegate
				{
					RefreshFilesList(DirPath);
					refresher.Refreshing = false;
				};
			}

			listView = view.FindViewById<ListView>(Resource.Id.listView);
			listView.Adapter = adapter;
			listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
			{
				var fileSystemInfo = adapter.GetItem(e.Position);
				if (e.Position == 0) {
					RefreshFilesList(Path.GetDirectoryName(fileSystemInfo.FullName));
				} else if (fileSystemInfo.IsDirectory()) {
					RefreshFilesList(fileSystemInfo.FullName);
				} else {
					Pref.TextViewDialog(Context, fileSystemInfo.FullName);
				}
			};
			listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
			{
				if (e.Position == 0)
					return;

				var fileSystemInfo = adapter.GetItem(e.Position);
				var actionName = fileSystemInfo.IsDirectory() ? "폴더 삭제" : "파일 삭제";
				var fileType = fileSystemInfo.IsDirectory() ? "이 폴더를 " : "이 파일을 ";
				var msg = fileType + "완전히 삭제 하시겠습니까?\n\n" + fileSystemInfo.Name + "\n\n수정한 날짜: " + fileSystemInfo.LastWriteTime.ToString();

				var builder = new AlertDialog.Builder(Context);
				builder.SetTitle(actionName)
					   .SetMessage(msg)
					   .SetNegativeButton("취소", delegate
					   {
						   RefreshFilesList(DirPath);
						   Show("삭제가 취소 되었습니다");
					   })
					   .SetPositiveButton("삭제", delegate
						{
							try {
								Directory.Delete(fileSystemInfo.FullName, true);
								RefreshFilesList(DirPath);
							} catch {
								Show("삭제할 수 없습니다");
							}
						});
				builder.Create().Show();
			};

			return view;
		}
示例#34
0
        /// <summary>
        /// Handles the lesson fragment's lesson finished event
        /// </summary>
        /// <param name="sender">sender.</param>
        /// <param name="e">event args.</param>
        void LessonFragment_LessonFinished(object sender, EventArgs e)
        {
            //Toast.MakeText(this, "Lesson finished!", ToastLength.Short).Show();

            var builder = new AlertDialog.Builder(this);
            builder.SetTitle(Resource.String.lesson_finished);
            builder.SetMessage(Resource.String.lesson_finished_message);
            builder.SetCancelable(false);
            builder.SetPositiveButton(Android.Resource.String.Ok, (s, args) => NextLesson());
            builder.Show();
        }
示例#35
0
 /// <summary>
 /// Switches to the next lesson if available
 /// </summary>
 private void NextLesson()
 {
     var nextLesson = DataHolder.Current.CurrentModule.GetNextLesson(DataHolder.Current.CurrentLesson);
     if (nextLesson != null)
     {
         DataHolder.Current.CurrentLesson = nextLesson;
         DataHolder.Current.CurrentIteration = nextLesson.Iterations.First();
         InitLesson();
     }
     else
     {
         var builder = new AlertDialog.Builder(this);
         builder.SetTitle(Resource.String.module_finished);
         builder.SetMessage(Resource.String.module_finished_message);
         builder.SetCancelable(false);
         builder.SetPositiveButton(Android.Resource.String.Ok, (s, args) => Finish());
         builder.Show();
     }
 }
示例#36
0
        private void ShowDialog(ListItemAdapter adapter, int itemPosition, string dialogTitle, bool isPayment, bool isHistory)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity, Resource.Style.AlertDialogStyle);
            var debtItem = adapter.Items[itemPosition];
            builder.SetTitle(dialogTitle);

            View dialogView;

            if (isPayment)
            {
                dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.PaymentDialog, null);
                builder.SetView(dialogView);
            }
            else
            {
                if (isHistory)
                {
                    dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.HistoryDialog, null);
                    builder.SetView(dialogView);

                    dialogView.FindViewById<TextView>(Resource.Id.dialogItemDate).Text = debtItem.StringValue;
                }
                else
                {
                    dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.DebtDialog, null);
                    builder.SetView(dialogView);
                }

                List<string> tempList = debtItem.FullDescription.Split('-').ToList();
                tempList.RemoveAt(0);
                if (tempList.Count != 0) // check of er producten zijn toegevoegd
                {
                    tempList.RemoveAt(tempList.Count - 1);
                }

                List<ListItem> productList = new List<ListItem>();
                for (int i = 0; i < tempList.Count; i += 2)
                {
                    productList.Add(new ListItem(tempList[i], double.Parse(tempList[i + 1]) / 100));
                }

                ListItemAdapter dialogAdapter = new ListItemAdapter(ListItem.DialogItem, productList);
                RecyclerView dialogRecyclerView = dialogView.FindViewById<RecyclerView>(Resource.Id.dialogrecyclerview);
                dialogRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity));
                dialogRecyclerView.SetAdapter(dialogAdapter);

                dialogView.FindViewById<TextView>(Resource.Id.dialogItemDescription).Text = debtItem.Description;
            }

            dialogView.FindViewById<TextView>(Resource.Id.dialogItemName).Text = debtItem.Name;
            dialogView.FindViewById<TextView>(Resource.Id.dialogItemValue).Text = debtItem.Value.ToString("N");
            dialogView.FindViewById<ImageView>(Resource.Id.dialogItemImage).SetImageResource(debtItem.ImageId);

            builder.SetCancelable(true);
            builder.Show();
        }
示例#37
0
        private void ShowDialog(ListItemAdapter adapter, int itemPosition, string dialogTitle, bool isPendingDialog, bool isPayment, bool isHistory)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this.Activity, Resource.Style.AlertDialogStyle);
            var debtItem = adapter.Items[itemPosition];
            builder.SetTitle(dialogTitle);
            if (isPendingDialog)
            {
                builder.SetPositiveButton("Accept", (senderAlert, e) =>
                {
                    if (dialogTitle.ToLower().Contains("debt"))
                    {
                        DatabaseInterface.AcceptDebt(debtItem.Id, _persoon.Id, _persoon.Password);
                        Toast.MakeText(this.Activity, "Debt accepted: " + debtItem.Description, ToastLength.Short).Show();
                        SwipeRefreshLayout.Refreshing = true;
                        this.Refresh();
                    }
                    else if (dialogTitle.ToLower().Contains("payment"))
                    {
                        string[] user = debtItem.Name.Split(' ');
                        foreach(int debt in _persoon.KrijgPaymentsVanGebruiker(user[1]))
                        DatabaseInterface.AcceptPayment(debt, _persoon.Id, _persoon.Password);
                        Toast.MakeText(this.Activity, "Payment accepted from: " + debtItem.Name, ToastLength.Short).Show();
                        SwipeRefreshLayout.Refreshing = true;
                        this.Refresh();
                    }
                    CreateEnvironments();
                });
                builder.SetNegativeButton("Decline", (s, e) =>
                {
                    if (dialogTitle.ToLower().Contains("debt"))
                    {
                        DatabaseInterface.DeclineDebt(debtItem.Id, _persoon.Id, _persoon.Password);
                        Toast.MakeText(this.Activity, "Debt declined: " + debtItem.Description, ToastLength.Short).Show();
                            Gegevens.GetServerData(_persoon.Id, _persoon.Password);
                            ((Payscherm)this.Activity).Restart();
                    }
                    else if (dialogTitle.ToLower().Contains("payment"))
                    {
                        string[] user = debtItem.Name.Split(' ');
                        foreach(int debt in _persoon.KrijgPaymentsVanGebruiker(user[1]))
                            DatabaseInterface.DeclinePayment(debt, _persoon.Id, _persoon.Password);
                        Toast.MakeText(this.Activity, "Payment declined from: " + debtItem.Name, ToastLength.Short).Show();
                            Gegevens.GetServerData(_persoon.Id, _persoon.Password);
                            ((Payscherm)this.Activity).Restart();
                    }
                    CreateEnvironments();
                });
                builder.SetNeutralButton("Cancel", (s, e) =>
                {
                    // dialog cancelt automatisch
                });
            }

            View dialogView;

            if (isPayment)
            {
                dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.PaymentDialog, null);
                builder.SetView(dialogView);
            }
            else
            {
                if (isHistory)
                {
                    dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.HistoryDialog, null);
                    builder.SetView(dialogView);

                    dialogView.FindViewById<TextView>(Resource.Id.dialogItemDate).Text = debtItem.StringValue;
                }
                else
                {
                    dialogView = this.Activity.LayoutInflater.Inflate(Resource.Layout.DebtDialog, null);
                    builder.SetView(dialogView);
                }

                List<string> tempList = debtItem.FullDescription.Split('-').ToList();
                tempList.RemoveAt(0);
                if (tempList.Count != 0) // check of er producten zijn toegevoegd
                {
                    tempList.RemoveAt(tempList.Count - 1);
                }

                // maak producten aan op basis van een stringlist
                List<ListItem> productList = new List<ListItem>();
                for(int i = 0; i < tempList.Count; i += 2)
                {
                    productList.Add(new ListItem(tempList[i], double.Parse(tempList[i+1]) / 100));
                }

                ListItemAdapter dialogAdapter = new ListItemAdapter(ListItem.DialogItem, productList);
                RecyclerView dialogRecyclerView = dialogView.FindViewById<RecyclerView>(Resource.Id.dialogrecyclerview);
                dialogRecyclerView.SetLayoutManager(new LinearLayoutManager(this.Activity));
                dialogRecyclerView.SetAdapter(dialogAdapter);

                dialogView.FindViewById<TextView>(Resource.Id.dialogItemDescription).Text = debtItem.Description;
            }

            dialogView.FindViewById<TextView>(Resource.Id.dialogItemName).Text = debtItem.Name;
            dialogView.FindViewById<TextView>(Resource.Id.dialogItemValue).Text = debtItem.Value.ToString("N");
            dialogView.FindViewById<ImageView>(Resource.Id.dialogItemImage).SetImageResource(debtItem.ImageId);

            builder.SetCancelable(true);
            builder.Show();
        }
示例#38
0
        private void Alert(string message)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.AlertDialogStyle);

            builder.SetTitle("Error");
            builder.SetMessage(message);
            builder.SetPositiveButton("OK", (senderAlert, e) => { });
            builder.Show();
        }
示例#39
0
        void OnItemClick(object sender, ListItemEventArgs args)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.AlertDialogStyle);
            View dialogView = LayoutInflater.Inflate(Resource.Layout.NumberAlertItem, null);
            EditText Amount = dialogView.FindViewById<EditText> (Resource.Id.EditAmount);
            Amount.FocusChange += delegate { if(Amount.HasFocus) Amount.Text = ""; };

            var tempItem = _adapter.Items[args.Position];
            builder.SetTitle("Enter the amount of your payment");
            builder.SetPositiveButton("Send", (senderAlert, e) =>
                {
                    Aflossen(tempItem.Name, System.Convert.ToDouble(Amount.Text));
                });
            builder.SetNeutralButton("Cancel", (senderAlert, e) =>
                {
                    // yay cancel
                });

            builder.SetView(dialogView);
            builder.SetCancelable(true);
            builder.Show();
        }
		void downloadAppFileCompleted (object sender, AsyncCompletedEventArgs e) {
			RunOnUiThread (() => {
				progressDialog.Dismiss ();
				if (downloadedOK) {
					var installApk = new Intent(Intent.ActionView);
					installApk.SetDataAndType(Android.Net.Uri.Parse("file://" + fullLatestAppFilename), "application/vnd.android.package-archive");
					installApk.SetFlags(ActivityFlags.NewTask);
					try {
						StartActivity(installApk);
					} catch (ActivityNotFoundException ex) {
						var errorInstalled = new AlertDialog.Builder (this).Create ();
						errorInstalled.SetTitle (Resources.GetString(Resource.String.download_error));
						errorInstalled.SetMessage (string.Format(Resources.GetString(Resource.String.download_error_description), Resources.GetString(Resource.String.app_name) + " " + latestAppVersion));
						errorInstalled.Show ();	
					}
					downloadedOK = false;
				} else {
					File.Delete(fullLatestAppFilename);
				}
			});
		}
示例#41
0
        private void ReasonAlert()
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this, Resource.Style.AlertDialogStyle);
            View dialogView = LayoutInflater.Inflate(Resource.Layout.AlertItem, null);
            EditText redenedit = dialogView.FindViewById<EditText> (Resource.Id.EditAmount);

            redenedit.FocusChange += delegate { if(redenedit.HasFocus) redenedit.Text = ""; };

            builder.SetTitle("Enter the occasion of your debt");
            builder.SetPositiveButton("Confirm", (senderAlert, e) =>
                {
                    CreateDebts(redenedit.Text);
                });
            builder.SetNeutralButton("Cancel", (senderAlert, e) =>
                {
                    //cancelt de dialog
                });

            builder.SetView(dialogView);
            builder.SetCancelable(true);
            builder.Show ();
        }
		void downloadWhatsAppFileCompleted (object sender, AsyncCompletedEventArgs e) {
			RunOnUiThread (() => {
				progressDialog.Dismiss ();
				if (downloadedOK) {
					var installApk = new Intent(Intent.ActionView);
					installApk.SetDataAndType(Android.Net.Uri.Parse("file://" + fullLatestWhatsAppFilename), "application/vnd.android.package-archive");
					installApk.SetFlags(ActivityFlags.NewTask);
					try {
						StartActivity(installApk);
						AlertDialog deleteWhatsApp = new AlertDialog.Builder (this).Create ();
						deleteWhatsApp.SetTitle (Resources.GetString(Resource.String.delete));
						deleteWhatsApp.SetMessage (Resources.GetString(Resource.String.delete_description));
						deleteWhatsApp.SetButton ((int)DialogButtonType.Positive, Resources.GetString(Resource.String.delete_button_delete), (object senderDelete, DialogClickEventArgs eDelete) => File.Delete(fullLatestWhatsAppFilename));
						deleteWhatsApp.SetButton ((int)DialogButtonType.Negative, Resources.GetString(Resource.String.delete_button_cancel), (object senderCancel, DialogClickEventArgs eCancel) => deleteWhatsApp.Dismiss ());
						deleteWhatsApp.SetCancelable (false);
						deleteWhatsApp.Show ();
					} catch (ActivityNotFoundException ex) {
						var errorInstalled = new AlertDialog.Builder (this).Create ();
						errorInstalled.SetTitle (Resources.GetString(Resource.String.download_error));
						errorInstalled.SetMessage (string.Format(Resources.GetString(Resource.String.download_error_description), "WhatsApp " + latestWhatsAppVersion));
						errorInstalled.Show ();	
					}
					downloadedOK = false;
				} else {
					File.Delete(fullLatestWhatsAppFilename);
				}
			});
		}
		// Retrieve latest version of Beta Updater
		public async Task GetLatestAppVersion (string pageUrl) {
			var getVersion = new WebClient();
			string htmlAndroid = getVersion.DownloadString (new Uri(pageUrl));

			// Get WhatsApp latest version
			string[] split = htmlAndroid.Split (new char[] { '>' });
			int i = 0;
			while (i < split.Length) {
				if (split.GetValue (i).ToString ().StartsWith ("v")) {
					split = split.GetValue (i).ToString ().Split (new char[] { 'v', '<' });
					latestAppVersion = split.GetValue (1).ToString ().Trim ();
					break;
				}
				i++;
			}

			installedAppVersion = PackageManager.GetPackageInfo ("com.javiersantos.whatsappbetaupdater", 0).VersionName.Trim ();

			if (CompareVersionReceiver.VersionCompare (installedAppVersion, latestAppVersion) < 0) {
				appApk = appApk + "v" + latestAppVersion + "/com.javiersantos.whatsappbetaupdater.apk";

				AlertDialog appUpdateDialog = new AlertDialog.Builder (this).Create ();
				appUpdateDialog.SetTitle (string.Format(Resources.GetString(Resource.String.app_update), latestAppVersion));
				appUpdateDialog.SetMessage (string.Format(Resources.GetString(Resource.String.app_update_description), Resources.GetString(Resource.String.app_name)));
				appUpdateDialog.SetButton ((int)DialogButtonType.Positive, Resources.GetString (Resource.String.update_button), (object senderUpdateAppOK, DialogClickEventArgs eUpdateAppOK) => {
					SetDownloadDialog ();
					var webClient = new WebClient ();
					webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler (downloadProgressChanged);
					webClient.DownloadFileCompleted += new AsyncCompletedEventHandler (downloadAppFileCompleted);
					webClient.DownloadFileAsync (new Uri (appApk), fullLatestAppFilename);
					progressDialog.SetTitle (string.Format(Resources.GetString(Resource.String.downloading), Resources.GetString(Resource.String.app_name) + " " + latestAppVersion + "..."));
					progressDialog.SetButton (Resources.GetString(Resource.String.cancel_button), (object senderCancel, DialogClickEventArgs eCancel) => {webClient.CancelAsync (); progressDialog.Dismiss ();});
					progressDialog.Show ();
				});
				appUpdateDialog.SetButton ((int)DialogButtonType.Negative, Resources.GetString(Resource.String.cancel_button), (object senderUpdateAppCancel, DialogClickEventArgs eUpdateAppCancel) => appUpdateDialog.Dismiss ());
				appUpdateDialog.SetButton ((int)DialogButtonType.Neutral, Resources.GetString(Resource.String.never_button), (object senderUpdateAppNever, DialogClickEventArgs eUpdateAppNever) => {prefs.Edit().PutBoolean("prefShowAppUpdates", false).Commit(); appUpdateDialog.Dismiss (); });
				appUpdateDialog.SetCancelable (false);
				appUpdateDialog.Show ();
			}
		}
		// Retrieve latest version of WhatsApp
		public async Task GetLatestWhatsAppVersion (string pageUrl) {
			var getVersion = new WebClient();
			string htmlAndroid = getVersion.DownloadString (new Uri(pageUrl));

			// Get WhatsApp latest version
			string[] split = htmlAndroid.Split (new char[] { '>' });
			int i = 0;
			while (i < split.Length) {
				if (split.GetValue (i).ToString ().StartsWith ("Version")) {
					split = split.GetValue (i).ToString ().Split (new char[] { ' ', '<' });
					latestWhatsAppVersion = split.GetValue (1).ToString ().Trim ();
					break;
				}
				i++;
			}

			// Display WhatsApp installed and latest version
			TextView whatsapp_installed_version = FindViewById<TextView> (Resource.Id.whatsapp_installed_version);
			TextView whatsapp_latest_version = FindViewById<TextView> (Resource.Id.whatsapp_latest_version);

			installedWhatsAppVersion = PackageManager.GetPackageInfo ("com.whatsapp", 0).VersionName.Trim ();

			whatsapp_installed_version.Text = installedWhatsAppVersion;
			whatsapp_latest_version.Text = latestWhatsAppVersion;

			fullLatestWhatsAppFilename = filename + "WhatsApp_" + latestWhatsAppVersion + ".apk";

			// Load Floating Button
			var fab = FindViewById<FloatingActionButton> (Resource.Id.fab);

			// Compare installed and latest WhatsApp version
			if (CompareVersionReceiver.VersionCompare(installedWhatsAppVersion, latestWhatsAppVersion) < 0) { // There is a new version
				fab.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.ic_download));
				// Preference: Autodownload
				if (prefAutoDownload) {
					SetDownloadDialog ();
					var webClient = new WebClient ();
					webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler (downloadProgressChanged);
					webClient.DownloadFileCompleted += new AsyncCompletedEventHandler (downloadWhatsAppFileCompleted);
					webClient.DownloadFileAsync (new Uri (whatsAppApk), fullLatestWhatsAppFilename);
					progressDialog.SetTitle (string.Format(Resources.GetString(Resource.String.downloading), "WhatsApp " + latestWhatsAppVersion + "..."));
					progressDialog.SetButton (Resources.GetString(Resource.String.cancel_button), (object senderCancel, DialogClickEventArgs eCancel) => {webClient.CancelAsync (); progressDialog.Dismiss ();});
					progressDialog.Show ();
				} else {
					fab.Click += delegate {
						SetDownloadDialog ();
						var webClient = new WebClient ();
						webClient.DownloadProgressChanged += new DownloadProgressChangedEventHandler (downloadProgressChanged);
						webClient.DownloadFileCompleted += new AsyncCompletedEventHandler (downloadWhatsAppFileCompleted);
						webClient.DownloadFileAsync (new Uri (whatsAppApk), fullLatestWhatsAppFilename);
						progressDialog.SetTitle (string.Format(Resources.GetString(Resource.String.downloading), "WhatsApp " + latestWhatsAppVersion + "..."));
						progressDialog.SetButton (Resources.GetString(Resource.String.cancel_button), (object senderCancel, DialogClickEventArgs eCancel) => {webClient.CancelAsync (); progressDialog.Dismiss ();});
						progressDialog.Show ();
					};
				}
			// There is not a new version
			} else {
				fab.SetImageDrawable(Resources.GetDrawable(Resource.Drawable.ic_menu_about));
				fab.Click += delegate {
					AlertDialog errorInstalled = new AlertDialog.Builder (this).Create ();
					errorInstalled.SetTitle (Resources.GetString(Resource.String.latest_installed));
					errorInstalled.SetMessage (string.Format(Resources.GetString(Resource.String.latest_installed_description), "WhatsApp " + installedWhatsAppVersion));
					errorInstalled.SetButton ((int)DialogButtonType.Positive, Resources.GetString(Resource.String.ok), (object senderClose, DialogClickEventArgs eClose) => errorInstalled.Dismiss ());
					errorInstalled.Show ();
				};
			}
		}
        // Warns user that they will delete this booking and removes the booking if user presses okay
        private void CancelBooking()
        {
            AlertDialog.Builder cancelAlert = new AlertDialog.Builder(this);

            cancelAlert.SetTitle(GetString(Resource.String.cancelBooking));
            cancelAlert.SetMessage(GetString(Resource.String.areYouSureCancel));
            cancelAlert.SetPositiveButton("YES", delegate
            {

                if(_Booking.GetType() == typeof(SessionBooking))
                {
                    SessionController sessionController = new SessionController();

                    if (!sessionController.CancelSession(_Booking.ID()))
                    {
                        //show error, stay on page
                    }

                    else
                    {
                        //show dialog saying canceled
                        var SuccesDialog = new AlertDialog.Builder(this);
                        SuccesDialog.SetMessage("Booking has been Canceled!");
                        SuccesDialog.SetNeutralButton("OK", delegate { Finish(); });
                        SuccesDialog.Show();

                        if (bookingType.Equals("Session"))
                            Server.sessionBookingsAltered = true;
                        else
                            Server.workshopBookingsAltered = true;
                    }
                }

                else if (_Booking.GetType() == typeof(WorkshopBooking))
                {
                    // Code to cancel booking.
                    WorkshopController workshopController = new WorkshopController();

                    if (!workshopController.CancelBooking(_Booking.ID()))
                    {
                        //show error, stay on page;
                    }

                    else
                    {
                        //show dialog saying cancled
                        var SuccesDialog = new AlertDialog.Builder(this);
                        SuccesDialog.SetMessage("Booking has been Canceled!");
                        SuccesDialog.SetNeutralButton("OK", delegate { Finish(); });
                        SuccesDialog.Show();

                        if (bookingType.Equals("Session"))
                            Server.sessionBookingsAltered = true;
                        else
                            Server.workshopBookingsAltered = true;
                    }

                }

            });
            cancelAlert.SetNegativeButton("NO", delegate { });
            cancelAlert.Show();
        }
示例#46
0
 public override Dialog OnCreateDialog(Bundle savedInstanceState)
 {
     var adb = new AlertDialog.Builder(Activity);
     adb.SetTitle(Title).SetMessage(Message).SetPositiveButton(Resource.String.ok, delegate{meListener.OnDialogPositiveClick();});
     return adb.Create();
 }