private void BtnApply_Click(object sender, EventArgs e)
        {
            lvEmptySeat.Adapter = new SeatReportAdapter(this, new List <SeatReport>());

            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
            Android.App.AlertDialog         alert  = dialog.Create();

            if (tvDate.Text == "Select Date")
            {
                alert.SetTitle("Message");
                alert.SetMessage("Please choose date before apply");
                alert.SetButton("OK", (c, ev) =>
                {
                });
                alert.Show();
                return;
            }

            if (DateTime.Parse(tvDate.Text).Date >= new DateTime(2019, 4, 1))
            {
                alert.SetTitle("Message");
                alert.SetMessage("No data");
                alert.SetButton("OK", (c, ev) =>
                {
                });
                alert.Show();
                return;
            }

            LoadEmptySeat();
        }
Beispiel #2
0
        async Task GetPermissionsAsync()
        {
            const string permission = Manifest.Permission.AccessFineLocation;

            if (CheckSelfPermission(permission) == (int)Android.Content.PM.Permission.Granted)
            {
                //TODO change the message to show the permissions name
                return;
            }
            if (ShouldShowRequestPermissionRationale(permission))
            {
                //set alert for executing the task
                Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
                alert.SetTitle("Permissions Needed");
                alert.SetMessage("The application need SMS permissions to continue");
                alert.SetPositiveButton("Request Permissions", (senderAlert, args) =>
                {
                    RequestPermissions(PermissionsGroupLocation, RequestLocationId);
                });
                alert.SetNegativeButton("Cancel", (senderAlert, args) =>
                {
                    Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show();
                });
                Dialog dialog = alert.Create();
                dialog.Show();
                return;
            }
            RequestPermissions(PermissionsGroupLocation, RequestLocationId);
        }
Beispiel #3
0
        private async void MakeLockRollete(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.LockRollete(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();
                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetTitle("Опустить роллету");
                    alert1.SetMessage(o_data.Message);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();

                    btn_gate.Text    = "Поднять";
                    BoxTextGate.Text = "Закрыта";

                    FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    BoxActivity         content2     = new BoxActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2);
                    transaction1.Commit();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
        private async Task UpdateVideos()
        {
            var indicator = new ProgressBar(this);

            try
            {
                indicator.Activated = true;
                var videos = new ObservableCollection <YouTubeVideo>((await YouTubeDataCollection.LoadVideosAsync("Xamarin Android", "relevance", null, 50)).Item2);
                _dataCollection = new C1DataCollection <YouTubeVideo>(videos).AsPlain();
                await _dataCollection.GroupAsync("ChannelTitle");

                RecyclerView.SetLayoutManager(new LinearLayoutManager(this));
                RecyclerView.SetAdapter(new YouTubeAdapter(_dataCollection));
            }
            catch
            {
                var builder = new Android.App.AlertDialog.Builder(this);
                builder.SetMessage(Resources.GetString(Resource.String.InternetConnectionError));
                var alert = builder.Create();
                alert.Show();
            }
            finally
            {
                indicator.Activated = false;
            }
        }
Beispiel #5
0
        private async void MakeFold(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.FoldContainer(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();
                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetTitle("Сложить контейнер");
                    alert1.SetMessage(o_data.ResponseData.Message);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();

                    btn_fold.Text    = "Разложить";
                    BoxTextFold.Text = "Сложен";

                    FragmentTransaction transaction1 = this.FragmentManager.BeginTransaction();
                    BoxActivity         content2     = new BoxActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2);
                    transaction1.Commit();
                }
            }
        }
Beispiel #6
0
        private async void Attach(AlertDialog.Builder alert)
        {
            using (var client = ClientHelper.GetClient(CrossSettings.Current.GetValueOrDefault("token", "")))
            {
                BoxService.InitializeClient(client);
                var o_data = new ServiceResponseObject <SuccessResponse>();
                o_data = await BoxService.Attach(StaticBox.id);

                if (o_data.Status == HttpStatusCode.OK)
                {
                    alert.Dispose();
                    Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(Activity);
                    alert1.SetTitle("Прикрепить контейнер");
                    alert1.SetMessage(o_data.ResponseData.Message);
                    alert1.SetPositiveButton("Закрыть", (senderAlert1, args1) =>
                    {
                    });
                    Dialog dialog1 = alert1.Create();
                    dialog1.Show();

                    FragmentTransaction   transaction1 = this.FragmentManager.BeginTransaction();
                    MainBoxStatusActivity content2     = new MainBoxStatusActivity();
                    transaction1.Replace(Resource.Id.frameDriverlayout, content2).AddToBackStack(null).Commit();
                }
                else
                {
                    Toast.MakeText(Activity, o_data.Message, ToastLength.Long).Show();
                }
            }
        }
Beispiel #7
0
 public void ShowConfirmDelete(string alerTitle, string alertMessage, string id)
 {
     Android.App.AlertDialog.Builder showDialog = new Android.App.AlertDialog.Builder(this);
     Android.App.AlertDialog         Alert      = showDialog.Create();
     Alert.SetTitle(alerTitle);
     Alert.SetMessage(alertMessage);
     Alert.SetButton("YES", delegate
     {
         try
         {
             string URL = "https://download-tracker.herokuapp.com/series/" + id;
             DeleteSeries(URL);
         }
         catch (Exception e)
         {
             Console.WriteLine(e.Message);
         }
     });
     Alert.SetButton2("NO", delegate
     {
         Alert.Dismiss();
         Alert.Dispose();
         return;
     });
     Alert.Show();
 }
Beispiel #8
0
        public async void AlertDialogVideoReward()
        {
            source = new CancellationTokenSource();

            layoutInflaterVideo     = LayoutInflater.From(this);
            mviewVideo              = layoutInflaterVideo.Inflate(Resource.Layout._alertDialogRewardVideo, null);
            alertDialogBuilderVideo = new Android.App.AlertDialog.Builder(this);
            alertDialogBuilderVideo.SetView(mviewVideo);
            alertDialogAndroidVideo = alertDialogBuilderVideo.Create();
            alertDialogAndroidVideo.Show();
            alertDialogAndroidVideo.SetCanceledOnTouchOutside(false);
            alertDialogAndroidVideo.SetCancelable(false);
            alertDialogAndroidVideo.Window.SetBackgroundDrawableResource(Resource.Color.mtrl_btn_transparent_bg_color);
            _RewardButtonYes        = mviewVideo.FindViewById <ImageButton>(Resource.Id.RewardButtonYes);
            _RewardButtonYes.Click += _RewardButtonYes_Click;

            ProgressBarVideoAd     = mviewVideo.FindViewById <ProgressBar>(Resource.Id.progressBarVideoAd);
            ProgressBarVideoAd.Max = 100;
            DoProgressBar();

            try
            {
                //ProgressBarVideoAd.IncrementProgressBy(10);
                await Task.Delay(5200, source.Token);

                TimerElapsed();
            }
            catch (TaskCanceledException)
            {
                return;
            }
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            if (item.ItemId == Resource.Id.filter)
            {
                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("Aviso");
                alert.SetMessage("¿Seguro que desea eliminar los filtros aplicados?");
                alert.SetButton("Si", (c, ev) =>
                {
                    Intent data = new Intent();

                    data.PutExtra(FILTER_RESULT, JsonConvert.SerializeObject(null));

                    SetResult(Result.Ok, data);
                    Finish();
                });

                alert.SetButton2("Cancelar", (c, ev) => { });

                alert.Show();
                return(true);
            }
            return(base.OnOptionsItemSelected(item));
        }
Beispiel #10
0
        public static void ShowExt(this Android.App.AlertDialog.Builder builder)
        {
            var dialog = builder.Create();

            dialog.Window.SetSoftInputMode(SoftInput.StateVisible);
            dialog.Show();
        }
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            switch (item.ItemId)
            {
            case Resource.Id.registrar:

                if (ManagerRepuestos.getRepuestos().Count() > 0)
                {
                    Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this.Activity);
                    alert.SetTitle("¿Estas seguro de registrar la lista?");
                    alert.SetMessage("Si la registras esos datos no podrán ser modificados");
                    alert.SetPositiveButton("SÍ", (s, e) =>
                    {
                        RegistrarSalida();
                    });
                    alert.SetNegativeButton("NO", (s, e) =>
                    {
                    });

                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
                else
                {
                    Toast.MakeText(this.Activity, "No hay repuestos para registrar!!!", ToastLength.Short).Show();
                }
                break;

            default:
                this.Activity.Finish();

                break;
            }
            return(base.OnOptionsItemSelected(item));
        }
Beispiel #12
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.action_logout)
            {
                //注销登录
                Context context = this;
                Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(context);
                builder.SetTitle("提示");
                builder.SetMessage("确认要注销登录吗?");
                builder.SetCancelable(true);
                builder.SetPositiveButton("确认", delegate
                {
                    Intent intent = new Intent(this, typeof(LoginActivity));
                    StartActivity(intent); //返回登录界面
                    this.Finish();         //主界面结束
                });
                builder.SetNegativeButton("取消", delegate
                {
                    //Toast.MakeText(this, "点击了取消", ToastLength.Short).Show();
                });
                Android.App.AlertDialog dialog = builder.Create();
                dialog.Show();
                return(true);
            }

            return(base.OnOptionsItemSelected(item));
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.activity_main);



            myUsername = FindViewById <EditText>(Resource.Id.UserName);
            myPassword = FindViewById <EditText>(Resource.Id.Password);
            myLogin    = FindViewById <Button>(Resource.Id.Login1);
            myRegister = FindViewById <Button>(Resource.Id.Register);


            Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
            Dialog dialog = alert.Create();

            CreateDB();

            myLogin.Click += MybutonClick;

            myLogin.Click += ButtonClick;



            myAlert = new Android.App.AlertDialog.Builder(this);


            myRegister.Click += delegate
            {
                Intent registerPage = new Intent(this, typeof(Register));

                StartActivity(registerPage);
            };
        }
Beispiel #14
0
        private void LogOut()
        {
            DataService.RepositoryController.Init();
            ConnectionController.GetInstance().DisconnectSockets();

            var locale = Localization.Lang as IAlert;

            Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);

            alert.SetMessage(locale.BadToken);

            alert.SetPositiveButton(locale.OK, (senderAlert, args) =>
            {
                FinishAffinity();
                Intent intent = new Intent(ApplicationContext, typeof(AuthActivity));
                intent.AddFlags(ActivityFlags.ClearTop);
                StartActivity(intent);
            });

            Dialog dialog = alert.Create();

            if (!IsFinishing)
            {
                RunOnUiThread(() =>
                {
                    dialog.Show();
                });
            }
        }
 //Overrides back button settings
 public override void OnBackPressed()
 {
     //If results are showing, Go to opening page
     if (searchFragmentActivity != null)
     {
         //Home method executed
         Home();
     }
     //Exit app
     else
     { //Dialog Box Creation
         string TITLE = "Exit App?", MESSAGE = "Are you sure you want to leave?";
         Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
         alert.SetTitle(TITLE);
         alert.SetMessage(MESSAGE);
         alert.SetPositiveButton("Yes", (senderAlert, args) =>
         {
             Finish();
             Toast.MakeText(this, "Don't forget to rate this app if you haven't already", ToastLength.Short).Show(); alert.Dispose();
         });
         alert.SetNegativeButton("No", (senderAlert, args) => { alert.Dispose(); });
         Dialog dialog = alert.Create();
         dialog.Show();
     }
 }
Beispiel #16
0
        private void myButtonClick(object sender, EventArgs e)
        {
            var vName     = email.Text;
            var vPassword = password.Text;

            myAlert = new Android.App.AlertDialog.Builder(this);


            if (vName == " " || vName.Equals(""))
            {
                errorMessageDialog("username");
            }
            else if (vPassword == " " || vPassword.Equals(""))
            {
                errorMessageDialog("password");
            }
            else
            {
                if (vPassword == "mobile" && vName == "mobile")
                {
                    i = new Intent(this, typeof(calc));
                    StartActivity(i);
                }
                else
                {
                    myAlert.SetTitle("Error!!!");
                    myAlert.SetMessage("Invalid Username or password");
                    myAlert.SetPositiveButton("OK", OkAction);
                    Dialog myDialog = myAlert.Create();
                    myDialog.Show();
                }
            }
        }
Beispiel #17
0
        private void SetPhoto()
        {
            LayoutInflater layoutInflater = LayoutInflater.From(context);
            View           view           = layoutInflater.Inflate(Resource.Layout.modal_photo, null);
            var            img_get_photo  = view.FindViewById <ImageView>(Resource.Id.img_get_photo);

            var src = Android.Net.Uri.Parse(URL + StaticOrder.File_Name);

            img_get_photo.SetImageURI(src);
            Bitmap imageBitmap = HomeService.GetImageBitmapFromUrl(URL + StaticOrder.File_Name);

            img_get_photo.SetImageBitmap(imageBitmap);
            Android.App.AlertDialog.Builder alert1 = new Android.App.AlertDialog.Builder(context);
            alert1.SetView(view);

            alert1.SetCancelable(false);
            alert1.SetPositiveButton("Скачать", (senderAlert1, args1) =>
            {
                SaveImage(imageBitmap);
            });
            alert1.SetNegativeButton("Закрыть", (senderAlert1, args1) =>
            {
            });
            Dialog dialog1 = alert1.Create();

            dialog1.Show();
        }
Beispiel #18
0
        private void ItemSearch_clicked(object sender, AdapterView.ItemClickEventArgs e, Activity currentActivity)
        {
            try
            {
                androidGridView.ItemClick -= (sndr, argus) => ItemSearch_clicked(sndr, argus, currentActivity);

                AddEditPlotFragment obj = new AddEditPlotFragment();
                Bundle utilBundle       = new Bundle();
                utilBundle.PutString("siteparam", farmid);
                utilBundle.PutString("siteparam0", gridViewCodeString[e.Position]);
                obj.Arguments = utilBundle;
                Android.Support.V4.App.FragmentTransaction tx = FragmentManager.BeginTransaction();
                tx.Replace(Resource.Id.m_main, obj, Constants.addeditplot);
                tx.Commit();
            }
            catch (Exception ex)
            {
                currentActivity.RunOnUiThread(() =>
                {
                    Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(currentActivity);
                    alertDiag.SetTitle(Resource.String.DialogHeaderError);
                    alertDiag.SetMessage(ex.Message);
                    alertDiag.SetIcon(Resource.Drawable.alert);
                    alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
                    {
                        androidGridView.ItemClick += (sndr, argus) => ItemSearch_clicked(sndr, argus, currentActivity);
                    });
                    Dialog diag = alertDiag.Create();
                    diag.Show();
                    diag.SetCanceledOnTouchOutside(false);
                });
            }
        }
Beispiel #19
0
        private async void LoadScreen()
        {
            try
            {
                using (var client = new HttpClient())
                {
                    var bytes = await client.GetByteArrayAsync("https://i.imgur.com/8q8Z0yM.gif");

                    gifImageView.SetBytes(bytes);
                    gifImageView.StartAnimation();
                }
                await Task.Delay(5000);

                Load();
            }
            catch (Exception ex)
            {
                Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
                alert.SetCancelable(false);
                alert.SetTitle("AlarmTrip");
                alert.SetMessage("Brak połączenia z internetem!\nDo prawidłowego działania aplikacji niezbędne jest połączenie z interentem.");
                alert.SetPositiveButton("Ok", (senderAlert, args) => {
                    Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
                });
                Dialog dialog = alert.Create();
                dialog.Show();
                Log.Info(tag, "Error: " + ex.ToString());
            }
        }
Beispiel #20
0
        void Mylist_ItemClick(object sender, AdapterView.ItemClickEventArgs e)
        {
            Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this.Activity);
            Android.App.AlertDialog         alert  = dialog.Create();

            alert.SetTitle("Remove Reservation");
            alert.SetMessage("Are you sure you want to remove this reservation?");
            alert.SetButton("Yes", (c, ev) =>
            {
                var firebase = new FirebaseClient(FBURL);

                firebase
                .Child("reservations")
                .Child(auth.CurrentUser.Uid)
                .Child(listReservations[e.Position].account_uid)
                .DeleteAsync();

                listReservations.Remove(listReservations[e.Position]);
                CustomReservationListAdapter adapter = new CustomReservationListAdapter(this, listReservations);

                mylist.Adapter = adapter;

                Toast.MakeText(this.Activity, "Reservation has been removed", ToastLength.Short).Show();
            });
            alert.SetButton2("No", (c, ev) =>
            {
            });
            alert.Show();
        }
Beispiel #21
0
 public void setAlert(string message)
 {
     Android.App.AlertDialog.Builder alert       = new Android.App.AlertDialog.Builder(this);
     Android.App.AlertDialog         alertDialog = alert.Create();
     alertDialog.SetTitle(message);
     alertDialog.Show();
 }
Beispiel #22
0
        private void PromptMacros()
        {
            var builderSingle = new Android.App.AlertDialog.Builder(this);

            builderSingle.SetTitle("Select Macro");

            var negative = new EventHandler <DialogClickEventArgs>(
                (s, args) =>
            {
            });

            var positive = new EventHandler <DialogClickEventArgs>(
                async(s, args) =>
            {
                if (_macrosValues != null && _macrosValues.Count > args.Which)
                {
                    var value       = _macrosValues[args.Which];
                    var currentHtml = await _editorWebView.GetHTML();
                    _editorWebView.SetHTML(currentHtml + value + "<br/>");
                }
            });

            builderSingle.SetItems(_macros.ToArray(), positive);
            builderSingle.SetNegativeButton("Cancel", negative);

            var adialog = builderSingle.Create();

            adialog.Show();
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            RequestWindowFeature(WindowFeatures.NoTitle);
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Rating);

            // Create your application here
            RatingBar   ratingBar  = FindViewById <RatingBar>(Resource.Id.ratingBar);
            var         btn_submit = FindViewById <Button>(Resource.Id.btn_submit);
            ImageButton img_Back   = FindViewById <ImageButton>(Resource.Id.imageButton_Back);

            img_Back.Click   += Img_Back_Click;
            btn_submit.Click += (s, e) =>
            {
                Android.App.AlertDialog.Builder dialog = new Android.App.AlertDialog.Builder(this);
                Android.App.AlertDialog         alert  = dialog.Create();
                alert.SetTitle("Rating Garage");
                alert.SetMessage("Thanks a lot for your feedback!");
                alert.SetButton("Back", (c, ev) =>
                {
                    StartActivity(typeof(MainPage));
                });
                alert.Show();
            };
        }
Beispiel #24
0
        //when timeline button clicked
        //to show alert dialog by confirm posting to timeline
        private void BtnTimeline_Click(object sender, EventArgs e)
        {
            AlertDialog.Builder alertDialog = new Android.App.AlertDialog.Builder(this);
            alertDialog.SetTitle("Confirm posting to timeline");
            alertDialog.SetMessage(dialogEditText.Text);
            alertDialog.SetPositiveButton("Yes", (senderAlert, args) =>
            {
                string dbPath = System.IO.Path.Combine(System.Environment.GetFolderPath(System.Environment.SpecialFolder.Personal), "message.db");
                var db        = new SQLiteConnection(dbPath);
                var data      = db.CreateTable <Message>();

                Message m = new Message()
                {
                    TextMessage = dialogEditText.Text,
                    DateTime    = DateTime.Now.ToShortDateString(),
                };

                int id = databaseManager.insertMessage(m);
                Toast.MakeText(this, "Uploaded!", ToastLength.Short).Show();
                dialogEditText.Text = "";
                RefreshPage();
                y = 0;
            });
            alertDialog.SetNegativeButton("No", (senderAlert, args) => { Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show(); });
            Dialog dialog = alertDialog.Create();

            alertDialog.Show();
        }
Beispiel #25
0
        public bool ShowAlertConfirmation(string message)
        {
            bool result = false;

            Activity.RunOnUiThread(() =>
            {
                var alert = new Android.App.AlertDialog.Builder(Activity);
                alert.SetMessage(message);
                alert.SetPositiveButton("Delete", (senderAlert, args) => { result = true; });
                alert.SetNegativeButton("Cancel", (senderAlert, args) => { result = false; });

                Dialog dialog     = alert.Create();
                dialog.ShowEvent += (s, e) =>
                {
                    result = true;
                };

                dialog.CancelEvent += (s, e) =>
                {
                    result = false;
                };
                dialog.Show();
            });
            return(result);
        }
Beispiel #26
0
        /// <summary>
        /// Override the on request permission method to handle the results
        /// </summary>
        /// <param name="requestCode"></param>
        /// <param name="permissions"></param>
        /// <param name="grantResults"></param>
        public override void OnRequestPermissionsResult(int requestCode, string[] permissions, [GeneratedEnum] Permission[] grantResults)
        {
            base.OnRequestPermissionsResult(requestCode, permissions, grantResults);


            switch (requestCode)
            {
            //if the request code is 100
            case 100:
                //for each result
                foreach (int i in grantResults)
                {
                    //check if granted, if not alert the user with a dialog.
                    if (i != (int)Permission.Granted)
                    {
                        Android.App.AlertDialog.Builder permDialog = new Android.App.AlertDialog.Builder(this);
                        permDialog.SetCancelable(false);
                        permDialog.SetMessage("This application requires permissions to be allowed before running. " +
                                              "Please re-open the application and select allow.\n" +
                                              "If you have previously selected 'Don't Ask Again' you need to go into Settings and accept the permissions manually");
                        permDialog.SetTitle("Permissions not set");

                        //do not allow the user to quit the message and when they hit ok close the app.
                        permDialog.SetPositiveButton("Ok", new EventHandler <DialogClickEventArgs>((s, args) => Finish()));
                        permDialog.Create();
                        permDialog.Show();
                    }
                }
                break;
            }
        }
 public void RedirectToDayView(DateTime currentDate)
 {
     try
     {
         Bundle utilBundle = new Bundle();
         utilBundle.PutString("siteparamdate", currentDate.ToString("dd-MM-yyyy"));
         ActivityByDateFragment objFragment = new ActivityByDateFragment();
         objFragment.Arguments = utilBundle;
         Android.Support.V4.App.FragmentTransaction tx = mCurrentFragment.FragmentManager.BeginTransaction();
         tx.Replace(Resource.Id.m_main, objFragment, Constants.addactivitybydate);
         tx.Commit();
     }
     catch (Exception ex)
     {
         this.Activity.RunOnUiThread(() =>
         {
             Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this.Activity);
             alertDiag.SetTitle(Resource.String.DialogHeaderError);
             alertDiag.SetMessage(ex.Message);
             alertDiag.SetIcon(Resource.Drawable.alert);
             alertDiag.SetPositiveButton(Resource.String.DialogButtonOk, (senderAlert, args) =>
             {
             });
             Dialog diag = alertDiag.Create();
             diag.Show();
             diag.SetCanceledOnTouchOutside(false);
         });
     }
 }
Beispiel #28
0
        /// <summary>
        /// <description>Upload User Profile Picture</description>
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void onImgProfileClick(object sender, EventArgs e)
        {
            try
            {
                string[] items = { "Take Photo", "Choose from Library", "Cancel" };
                Android.App.AlertDialog.Builder alertDiag = new Android.App.AlertDialog.Builder(this);
                alertDiag.SetTitle("Add Photo");
                alertDiag.SetItems(items, (d, args) =>
                {
                    //Take photo
                    if (args.Which == 0)
                    {
                        TakePhoto();
                    }

                    else if (args.Which == 1)
                    {
                        UploadPhoto();
                    }
                    else
                    {
                        alertDiag.Dispose();
                    }
                });
                Dialog diag = alertDiag.Create();
                alertDiag.Show();
            }
            catch (Exception ex)
            {
                Toast.MakeText(this, GetString(Resource.String.somthing_wrong), ToastLength.Short).Show();
            }
        }
Beispiel #29
0
        public Task <bool> ShowAlertConfirmation(string message, string buttonYesTitle = "Yes", string buttonNoTitle = "No")
        {
            var tcs = new TaskCompletionSource <bool>();

            Activity.RunOnUiThread(() =>
            {
                var alert = new Android.App.AlertDialog.Builder(Activity);
                alert.SetMessage(message);
                alert.SetPositiveButton(buttonYesTitle, (senderAlert, args) =>
                {
                    tcs.SetResult(true);
                });
                alert.SetNegativeButton(buttonNoTitle, (senderAlert, args) =>
                {
                    tcs.SetResult(false);
                });
                alert.SetOnCancelListener(new OnCancelListener(() =>
                {
                    tcs.SetResult(false);
                }));
                Dialog dialog = alert.Create();

                dialog.Show();
            });

            return(tcs.Task);
        }
Beispiel #30
0
        private void exitCadastro()
        {
            if (this.nome.Text != "" || this.login.Text != "" || this.senha.Text != "")
            {
                //set alert for executing the task
                Android.App.AlertDialog.Builder alert = new Android.App.AlertDialog.Builder(this);
                alert.SetTitle("Voltar");
                alert.SetMessage("Se você voltar, perderá os dados do cadastro, tem certeza?");
                alert.SetPositiveButton("Sim", (senderAlert, args) => {
                    var NxtAct = new Intent(this, typeof(MainActivity));
                    StartActivity(NxtAct);
                });
                alert.SetNegativeButton("Não", (senderAlert, args) => {
                    return;
                });

                Dialog dialog = alert.Create();
                dialog.Show();
            }
            else
            {
                var NxtAct = new Intent(this, typeof(MainActivity));
                StartActivity(NxtAct);
            }
        }
Beispiel #31
0
 public override void OnBackPressed()
 {
     var builder = new Android.App.AlertDialog.Builder(this);
     builder.SetTitle ("Exit.");
     builder.SetIcon (Android.Resource.Drawable.IcDialogAlert);
     builder.SetMessage("Exit App?");
     builder.SetPositiveButton("OK", (s, e) =>
         {
             System.Environment.Exit(0);
         });
     builder.SetNegativeButton("Cancel", (s, e) => { });
     builder.Create().Show();
 }
Beispiel #32
0
		//closeActivity is for finish() activity
		public static void dialogErrorInternet(Activity context,int errorType,int close){

			context.RunOnUiThread (() => {
				string errorMsg = "";
				if(errorType == errorInternet){
					errorMsg = "Ralat. Sila semak sambungan internet anda.";
				}else if(errorType == errorServer){
					errorMsg = "Ralat. Server Pi1M dalam proses penyelenggaraan .";
				}

				Android.App.AlertDialog alertDialog;
				Android.App.AlertDialog.Builder alertDialogBuilder = new Android.App.AlertDialog.Builder (context);

				alertDialogBuilder
					.SetTitle ("Masalah")
					.SetMessage (string.Format (errorMsg))
					.SetCancelable (false)
					.SetPositiveButton ("OK", delegate {
						if(close==closeActivity){
							context.Finish ();
						}
					});
				alertDialog = alertDialogBuilder.Create ();
				alertDialog.Show ();
			});
		}
		void ListView_OnItemLongClick (object sender, AdapterView.ItemLongClickEventArgs e)
		{
			LocalBox clickedItem = foundLocalBoxes [e.Position];

			LayoutInflater inflater = (LayoutInflater)Activity.GetSystemService (Context.LayoutInflaterService); 
			View popupView;
			popupView = inflater.Inflate (Resource.Layout.custom_popup_root, null);

			PopupWindow popupWindow = new PopupWindow (popupView, e.View.Width, e.View.Height);

			//Hide popup window when clicking outside its view
			popupWindow.Focusable = true;
			popupWindow.Update ();
			popupWindow.SetBackgroundDrawable(new BitmapDrawable());

			popupWindow.ShowAsDropDown (e.View, 0, - e.View.Height);

			ImageButton buttonDelete = (ImageButton) popupView.FindViewById(Resource.Id.button_popup_root_delete);

			buttonDelete.Click += delegate {
				popupWindow.Dismiss();

				var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity);
				alertDialogConfirmDelete.SetTitle("Waarschuwing");
				alertDialogConfirmDelete.SetMessage("Weet u zeker dat u deze Pleiobox wilt verwijderen? \nDeze actie is niet terug te draaien.");

				alertDialogConfirmDelete.SetPositiveButton ("Verwijderen", async delegate { 
					try{
						DataLayer.Instance.DeleteLocalBox(clickedItem.Id);
						ResetUIToBeginState(true);
						UpdateLocalBoxes();

						List<LocalBox> registeredLocalBoxes = await DataLayer.Instance.GetLocalBoxes ();
						if (registeredLocalBoxes.Count == 0) {
							HomeActivity homeActivity = (HomeActivity)Activity;
							homeActivity.ShowLoginDialog();
						}
						//Reset logo
						//imageViewLogo.SetImageResource (Resource.Drawable.beeldmerk_belastingdienst);
					}catch (Exception ex){
						Insights.Report(ex);
						Toast.MakeText (Android.App.Application.Context, "Het verwijderen van de Pleiobox is mislukt", ToastLength.Short).Show ();
					}
				});
				alertDialogConfirmDelete.SetNegativeButton ("Annuleren", delegate { 
					alertDialogConfirmDelete.Dispose();
				});
				alertDialogConfirmDelete.Create ().Show ();
			};
		}
 public override void OnBackPressed()
 {
     var builder = new Android.App.AlertDialog.Builder(this);
     builder.SetTitle ("Exit.");
     builder.SetIcon (Android.Resource.Drawable.IcDialogAlert);
     builder.SetMessage("Exit App?");
     builder.SetPositiveButton("OK", (s, e) =>
         {
             mSharedPreferences = this.GetSharedPreferences ("CheckInPrefs", FileCreationMode.Private);
             ISharedPreferencesEditor editor = mSharedPreferences.Edit ();
             editor.Remove ("SessionKey");
             editor.Commit ();
             if (!(geofenceRequestIntent == null)) {
                 geofenceRequestIntent.Cancel ();
             }
             Finish();
             Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
             //System.Environment.Exit(0);
         });
     builder.SetNegativeButton("Cancel", (s, e) => { });
     builder.Create().Show();
 }
        private void DialogToShowAccountsOnDevice ()
		{
			var am = AccountManager.Get (this);
			// "this" references the current Context
			var accounts = am.GetAccountsByType ("com.google");
			var miaAlert = new Android.App.AlertDialog.Builder (this);
			if (accounts != null && accounts.Length > 0) {
				miaAlert.SetTitle ("i found an account name! and total # = " + accounts.Length);
				miaAlert.SetMessage (accounts [0].Name);
			} else {
				miaAlert.SetTitle ("No Account Found");
				miaAlert.SetMessage ("None");
			}
			var alert = miaAlert.Create ();
			alert.Show ();
		}
        public override void DisplayMessage(MessageDisplayParams messageParams)
        {
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(this.context);
            builder.SetTitle(messageParams.Title);
            builder.SetMessage(messageParams.Message);

            if (messageParams.PositiveAction != null)
            {
                builder.SetPositiveButton(messageParams.PositiveLabel ?? DefaultPositiveLabel, (s, e) =>
                    {
                        messageParams.PositiveAction();
                    });
            }

            if (messageParams.NegativeAction != null)
            {
                builder.SetNegativeButton(messageParams.NegativeLabel ?? DefaultNegativeLabel, (s, e) =>
                    {
                        messageParams.NegativeAction();
                    });
            }

            if (messageParams.NeutralAction != null)
            {
                builder.SetNeutralButton(messageParams.NeutralLabel ?? string.Empty, (s, e) =>
                    {
                        messageParams.NeutralAction();
                    });
            }

            var dialog = builder.Create();
            dialog.DismissEvent += (sender, e) => {
                this.messages.Remove(messageParams);
            };

            this.messages.Add(messageParams);
            this.dialogs.Add(dialog);

            dialog.Show();
        }
		protected override void OnCreate(Bundle savedInstanceState)
		{
			base.OnCreate(savedInstanceState);

			SetContentView(Resource.Layout.TaskDetail);

			var toolbar = FindViewById<Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
			this.SetSupportActionBar(toolbar);

			var isEdit = false;
			if (Intent.HasExtra(Constants.Extras.Task))
			{
				isEdit = true;
				this.task = JsonConvert.DeserializeObject<MobileTask>(Intent.GetStringExtra(Constants.Extras.Task));
			}
			else
			{
				this.task = new MobileTask();
			}

			this.description = this.FindViewById<EditText>(Resource.Id.description);
			this.description.Text = this.task.Description;

			this.date = this.FindViewById<TextView>(Resource.Id.date);
			this.date.Text = this.task.DateDue != null ? this.task.DateDue.Value.ToString("ddd, M/d/yy h:mm tt") : null;

			this.changeDate = this.FindViewById<Button>(Resource.Id.changeDate);
			this.changeDate.Click += (sender, args) =>
			{
				var calendar = Calendar.GetInstance(Java.Util.TimeZone.Default);
				var date = DateTime.Now;
				if (this.task.DateDue != null)
				{
					calendar.Time = new Date(this.task.DateDue.Value.Millisecond);
					date = this.task.DateDue.Value;
				}

				var picker = new DatePickerDialog(this, this, date.Year, date.Month - 1, date.Day);
				picker.Show();
			};

			this.specifyDateDue = this.FindViewById<CheckBox>(Resource.Id.specifyDateDue);
			this.specifyDateDue.CheckedChange += (sender, args) =>
			{
				if (args.IsChecked)
				{
					this.date.Visibility = ViewStates.Visible;
					this.changeDate.Visibility = ViewStates.Visible;
				}
				else
				{
					this.date.Visibility = ViewStates.Gone;
					this.changeDate.Visibility = ViewStates.Gone;
					this.task.DateDue = null;
				}
			};
			this.specifyDateDue.Checked = this.task.DateDue != null;

			this.completed = this.FindViewById<CheckBox>(Resource.Id.completed);
			this.completed.Checked = this.task.IsCompleted;

			var saveButton = this.FindViewById<Button>(Resource.Id.save);
			saveButton.Click += async delegate
			{
				this.task.Description = description.Text;
				this.task.IsCompleted = completed.Checked;

				await MobileService.Instance.UpsertTaskAsync(this.task);
				this.Finish();
			};

			var deleteButton = this.FindViewById<Button>(Resource.Id.delete);
			if (isEdit)
			{
				deleteButton.Click += delegate
				{
					var builder = new Android.App.AlertDialog.Builder(this)
					.SetTitle("Are you sure?")
					.SetMessage("Delete '" + task.Description + "'?")
					.SetPositiveButton(Resource.String.Yes, async (sender, args) =>
					{
						await MobileService.Instance.DeleteTaskAsync(task.Id);
						this.Finish();
					})
					.SetNegativeButton(Resource.String.No, (sender, args) => { /* Do nothing */ });

					builder.Create().Show();
				};
			}
			else
			{
				deleteButton.Visibility = ViewStates.Gone;
			}
		}
Beispiel #38
0
		protected override void OnTapped()
		{
			base.OnTapped();

			#if __IOS__

			App.Navigation.Navigation.PushAsync(new SelectionPage(this, text.Text, Items, Key, DefaultValue));

			#endif

			#if __ANDROID__

			var builder = new Android.App.AlertDialog.Builder(Forms.Context);

			int checkedItem;

			if (Values == null)
			{
				checkedItem = Settings.Current.GetValueOrDefault<int>(Key, DefaultValue);
			}
			else
			{
				checkedItem = Array.IndexOf(Values, Settings.Current.GetValueOrDefault<string>(Key, Values[DefaultValue]));
				checkedItem = checkedItem < 0 ? 0 : checkedItem;
			}

			builder.SetTitle(text.Text);
			builder.SetSingleChoiceItems(Items, checkedItem, (sender, args) => { 
				if (Values == null)
				{
					Settings.Current.AddOrUpdateValue<int>(Key, args.Which);
				}
				else
				{
					Settings.Current.AddOrUpdateValue<string>(Key, Values[args.Which]);
				}
				Update(); 
			});

			var dialog = builder.Create();

			dialog.SetButton(Catalog.GetString("Ok"), (s, e) => { dialog.Dismiss(); });

			dialog.Show();

			#endif
		}
		private void DeleteFolderOrFile (string path)
		{
			popupWindow.Dismiss ();

			var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity);
			alertDialogConfirmDelete.SetTitle("Waarschuwing");
			alertDialogConfirmDelete.SetMessage("Bent u zeker van deze verwijder actie? \nDeze actie is niet terug te draaien.");

			alertDialogConfirmDelete.SetPositiveButton ("Verwijderen", async delegate { 
				try {
					parentActivity.ShowProgressDialog ("Verwijderen... Een ogenblik geduld a.u.b.");

					bool deleteSucceed = await DataLayer.Instance.DeleteFileOrFolder (path);

					parentActivity.HideProgressDialog ();

					if (!deleteSucceed) {
						Toast.MakeText (Android.App.Application.Context, "Verwijderen mislukt - druk op ververs en probeer het a.u.b. opnieuw", ToastLength.Long).Show ();
					} else {
						Toast.MakeText (Android.App.Application.Context, "Verwijderen succesvol", ToastLength.Short).Show ();

						//Refresh listview
						RefreshData ();
					}
				} catch (Exception ex){
					Insights.Report(ex);
					parentActivity.HideProgressDialog (); 
					Toast.MakeText (Android.App.Application.Context, "Verwijderen mislukt - druk op ververs en probeer het a.u.b. opnieuw", ToastLength.Long).Show ();
				}
			});
			alertDialogConfirmDelete.SetNegativeButton ("Annuleren", delegate { 
				alertDialogConfirmDelete.Dispose();
			});
			alertDialogConfirmDelete.Create ().Show ();
		}
Beispiel #40
0
        /// <summary>
        /// Begins an asynchronous operation showing a dialog.
        /// </summary>
        /// <returns>An object that represents the asynchronous operation.
        /// For more on the async pattern, see Asynchronous programming in the Windows Runtime.</returns>
        /// <remarks>In some cases, such as when the dialog is closed by the system out of your control, your result can be an empty command.
        /// Returns either the command selected which destroyed the dialog, or an empty command.
        /// For example, a dialog hosted in a charms window will return an empty command if the charms window has been dismissed.</remarks>
        public Task<IUICommand> ShowAsync()
        {
            if (Commands.Count > MaxCommands)
            {
                throw new InvalidOperationException();
            }

#if __ANDROID__
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);
            Android.App.AlertDialog dialog = builder.Create();
            dialog.SetTitle(Title);
            dialog.SetMessage(Content);
            if (Commands.Count == 0)
            {
                dialog.SetButton(-1, Resources.System.GetString(Android.Resource.String.Cancel), new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    dialog.SetButton(-1 - i, Commands[i].Label, new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
                }
            }
            dialog.Show();

            return Task.Run<IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            });

#elif __IOS__ || __TVOS__
            uac = UIAlertController.Create(Title, Content, UIAlertControllerStyle.Alert);
            if (Commands.Count == 0)
            {
                uac.AddAction(UIAlertAction.Create("Close", UIAlertActionStyle.Cancel | UIAlertActionStyle.Default, ActionClicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    UIAlertAction action = UIAlertAction.Create(Commands[i].Label, CancelCommandIndex == i ? UIAlertActionStyle.Cancel : UIAlertActionStyle.Default, ActionClicked);
                    uac.AddAction(action);
                }
            }
            UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
            while (currentController.PresentedViewController != null)
                currentController = currentController.PresentedViewController;
            
            currentController.PresentViewController(uac, true, null);

            return Task.Run<IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            });

#elif __MAC__
            NSAlert alert = new NSAlert();
            alert.AlertStyle = NSAlertStyle.Informational;
            alert.InformativeText = Content;
            alert.MessageText = Title;

            foreach(IUICommand command in Commands)
            {
                var button = alert.AddButton(command.Label);
            }

            alert.BeginSheetForResponse(NSApplication.SharedApplication.MainWindow, NSAlert_onEnded);

            return Task.Run<IUICommand>(() =>
            {
                _handle.WaitOne();
                return _selectedCommand;
            });

#elif WINDOWS_PHONE
            List<string> buttons = new List<string>();
            foreach(IUICommand uic in this.Commands)
            {
                buttons.Add(uic.Label);
            }

            if (buttons.Count == 0)
            {
                buttons.Add("Close");
            }

            MessageDialogAsyncOperation asyncOperation = new MessageDialogAsyncOperation(this);

            string contentText = Content;

            // trim message body to 255 chars
            if (contentText.Length > 255)
            {
                contentText = contentText.Substring(0, 255);
            }
            
            while(Microsoft.Xna.Framework.GamerServices.Guide.IsVisible)
            {
                Thread.Sleep(250);
            }

            Microsoft.Xna.Framework.GamerServices.Guide.BeginShowMessageBox(
                        string.IsNullOrEmpty(Title) ? " " : Title,
                        contentText,
                        buttons,
                        (int)DefaultCommandIndex, // can choose which button has the focus
                        Microsoft.Xna.Framework.GamerServices.MessageBoxIcon.None, // can play sounds
                        result =>
                        {
                            int? returned = Microsoft.Xna.Framework.GamerServices.Guide.EndShowMessageBox(result);
                            
                            // process and fire the required handler
                            if (returned.HasValue)
                            {
                                if (Commands.Count > returned.Value)
                                {
                                    IUICommand theCommand = Commands[returned.Value];
                                    asyncOperation.SetResults(theCommand);
                                    if (theCommand.Invoked != null)
                                    {
                                        theCommand.Invoked(theCommand);
                                    }
                                }
                                else
                                {
                                    asyncOperation.SetResults(null);
                                }
                            }
                            else
                            {
                                asyncOperation.SetResults(null);
                            }
                        }, null);

            return asyncOperation.AsTask<IUICommand>();
#elif WINDOWS_UWP
            if (Commands.Count < 3 && Windows.Foundation.Metadata.ApiInformation.IsApiContractPresent("Windows.UI.ApplicationSettings.ApplicationsSettingsContract", 1))
            {
                Windows.UI.Xaml.Controls.ContentDialog cd = new Windows.UI.Xaml.Controls.ContentDialog();
                cd.Title = Title;
                cd.Content = Content;
                if(Commands.Count == 0)
                {
                    cd.PrimaryButtonText = "Close";
                }
                else
                {
                    cd.PrimaryButtonText = Commands[0].Label;
                    cd.PrimaryButtonClick += Cd_PrimaryButtonClick;
                    if(Commands.Count > 1)
                    {
                        cd.SecondaryButtonText = Commands[1].Label;
                        cd.SecondaryButtonClick += Cd_SecondaryButtonClick;
                    }
                }
                
                return Task.Run<IUICommand>(async () => 
                {
                    ManualResetEvent mre = new ManualResetEvent(false);
                    IUICommand command = null;

                    await cd.Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
                    {
                        ContentDialogResult dr = await cd.ShowAsync();
                        if (Commands.Count > 0)
                        {
                            switch (dr)
                            {
                                case ContentDialogResult.Primary:
                                    command = Commands[0];
                                    if(Commands[0].Invoked != null)
                                    {
                                        Commands[0].Invoked.Invoke(Commands[0]);
                                    }
                                    break;

                                case ContentDialogResult.Secondary:
                                    command = Commands[1];
                                    if (Commands[1].Invoked != null)
                                    {
                                        Commands[1].Invoked.Invoke(Commands[1]);
                                    }
                                    break;
                            }
                        }
                    });

                    mre.WaitOne();

                    return command;
                });
            }
            else
            {
                Windows.UI.Popups.MessageDialog dialog = new Windows.UI.Popups.MessageDialog(Content, Title);
                foreach (IUICommand command in Commands)
                {
                    dialog.Commands.Add(new Windows.UI.Popups.UICommand(command.Label, (c)=> { command.Invoked(command); }, command.Id));
                }
                return Task.Run<IUICommand>(async () => {
                    Windows.UI.Popups.IUICommand command = await dialog.ShowAsync();
                    if (command != null)
                    {
                        int i = 0;
                        foreach(Windows.UI.Popups.IUICommand c in dialog.Commands)
                        {
                            if(command == c)
                            {
                                break;
                            }

                            i++;
                        }

                        return Commands[i];
                    }
                    return null;
                });
            }
#elif WIN32
            return Task.Run<IUICommand>(() =>
            {
                IUICommand cmd = ShowTaskDialog();
                if (cmd != null)
                {
                    cmd.Invoked?.Invoke(cmd);
                }

                return cmd;
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
 public void btnCloseA_OnClick(object sender, EventArgs EventArgs)
 {
     var builder = new Android.App.AlertDialog.Builder(this);
     builder.SetTitle ("Exit.");
     builder.SetIcon (Android.Resource.Drawable.IcDialogAlert);
     builder.SetMessage("Exit App?");
     builder.SetPositiveButton("OK", (s, e) =>
         {
             Finish();
             Android.OS.Process.KillProcess(Android.OS.Process.MyPid());
             //System.Environment.Exit(0);
         });
     builder.SetNegativeButton("Cancel", (s, e) => { });
     builder.Create().Show();
 }
		private async void OpenFileIn (TreeNode clickedItem)
		{
			try {
	
				if (popupWindow != null) {
					popupWindow.Dismiss ();
				}



				string mimeTypeOfClickedItem = MimeTypeHelper.GetMimeType (clickedItem.Path);
				clickedItem.Type = mimeTypeOfClickedItem;

				if (clickedItem.Type.Equals ("application/pdf")) {

					Intent intent = new Intent (Intent.ActionView);

					new Thread (new ThreadStart (async delegate {

						//Show progress dialog while loading
						parentActivity.HideProgressDialog ();
						parentActivity.ShowProgressDialog (null);
						string fullFilePath = await DataLayer.Instance.GetFilePath (clickedItem.Path);

						//Controleer internet verbinding
						var connectivityManager = (ConnectivityManager)Android.App.Application.Context.GetSystemService (Context.ConnectivityService);
						var activeConnection = connectivityManager.ActiveNetworkInfo;

						if ((activeConnection != null) && activeConnection.IsConnected) {  	//Internet verbinding gedetecteerd

							//Create temp file
							string temporaryFilePath = System.IO.Path.Combine ("/storage/emulated/0/Download", clickedItem.Name);

							if (File.Exists (temporaryFilePath)) {
								File.Delete (temporaryFilePath);
							}
							
							//Save settings of last opened file
							ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences (Activity);
							ISharedPreferencesEditor editor = prefs.Edit ();
							editor.PutString ("fileNameLastOpenedPdf", clickedItem.Name);
							editor.PutString ("pathLastOpenedPdf", clickedItem.Path);
							editor.PutString ("temporaryFilePath", temporaryFilePath);
							editor.PutBoolean ("isFavorite", clickedItem.IsFavorite);
							editor.Commit ();

							//Save temporary file in filesystem
							Byte[] fileBytes = File.ReadAllBytes (fullFilePath);

							File.WriteAllBytes (temporaryFilePath, fileBytes);

							Android.Net.Uri uri = Android.Net.Uri.Parse ("file://" + temporaryFilePath);
							intent.SetDataAndType (uri, clickedItem.Type);

							parentActivity.HideProgressDialog ();
							if(File.Exists (temporaryFilePath)){
								Activity.StartActivity (intent);
							}
							else {
								Toast.MakeText (Android.App.Application.Context, "Openen bestand mislukt", ToastLength.Long).Show ();
							}
						} else {	

							//Geen internet verbinding
							var alertDialogConfirmDelete = new Android.App.AlertDialog.Builder (Activity);
							alertDialogConfirmDelete.SetTitle ("Geen verbinding");
							alertDialogConfirmDelete.SetMessage ("U heeft momenteel geen internet verbinding. Het maken van PDF annotaties is daarom niet mogelijk.");

							alertDialogConfirmDelete.SetPositiveButton ("OK", async delegate { 

								Android.Net.Uri uri = Android.Net.Uri.Parse ("file://" + fullFilePath);
								intent.SetDataAndType (uri, clickedItem.Type);

								parentActivity.HideProgressDialog ();
								Activity.StartActivity (intent);
							});
							alertDialogConfirmDelete.Create ().Show ();
						}
					})).Start ();
				} else {//Ander bestandstype dan PDF openen


					//Show progress dialog while loading
					parentActivity.HideProgressDialog ();
					parentActivity.ShowProgressDialog (null);
					string fullFilePath = await DataLayer.Instance.GetFilePath (clickedItem.Path);


					Intent intent = new Intent(Intent.ActionView, Android.Net.Uri.Parse (CustomContentProvider.CONTENT_URI + fullFilePath));
					intent.SetFlags (ActivityFlags.GrantReadUriPermission);
					intent.SetFlags (ActivityFlags.NewTask);
					intent.SetFlags (ActivityFlags.ClearWhenTaskReset);
					Activity.StartActivity (intent);

				}
			} catch (Exception ex){
				Insights.Report(ex);
				Console.WriteLine (ex.Message);

				parentActivity.HideProgressDialog ();

				if (ex is ActivityNotFoundException) {
					Toast.MakeText (Android.App.Application.Context, "Geen app op uw apparaat gevonden om dit bestandstype te kunnen openen", ToastLength.Long).Show ();
				} else {
					Toast.MakeText (Android.App.Application.Context, "Openen bestand mislukt", ToastLength.Long).Show ();
				}
			}
		}
Beispiel #43
0
        /// <summary>
        /// Shows the context menu in the preferred placement relative to the specified selection.
        /// </summary>
        /// <param name="selection">The coordinates (in DIPs) of the selected rectangle, relative to the window.</param>
        /// <param name="preferredPlacement">The preferred placement of the context menu relative to the selection rectangle.</param>
        /// <returns></returns>
        public Task<IUICommand> ShowForSelectionAsync(Rect selection, Placement preferredPlacement)
        { 
            if (Commands.Count > MaxCommands)
            {
                throw new InvalidOperationException();
            }

#if WINDOWS_UWP
            return Task.Run<IUICommand>(async () =>
            {
                foreach (IUICommand command in Commands)
                {
                    _menu.Commands.Add(new Windows.UI.Popups.UICommand(command.Label, new Windows.UI.Popups.UICommandInvokedHandler((c2) => { command.Invoked?.Invoke(command); }), command.Id));
                }
                Windows.Foundation.Rect r = new Windows.Foundation.Rect(selection.X, selection.Y, selection.Width, selection.Height);
                var c = await _menu.ShowForSelectionAsync(r, (Windows.UI.Popups.Placement)((int)preferredPlacement));
                return c == null ? null : new UICommand(c.Label, new UICommandInvokedHandler((c2) => { c2.Invoked?.Invoke(c2); }), c.Id);
            });
#elif __ANDROID__
            Android.App.AlertDialog.Builder builder = new Android.App.AlertDialog.Builder(Plugin.CurrentActivity.CrossCurrentActivity.Current.Activity);
            Android.App.AlertDialog dialog = builder.Create();
            dialog.SetTitle(Title);
            dialog.SetMessage(Content);
            if (Commands.Count == 0)
            {
                dialog.SetButton(-1, Resources.System.GetString(Android.Resource.String.Cancel), new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    dialog.SetButton(-1 - i, Commands[i].Label, new EventHandler<Android.Content.DialogClickEventArgs>(Clicked));
                }
            }
            dialog.Show();

            return Task.Run<IUICommand>(() =>
            {
                handle.WaitOne();
                return _selectedCommand;
            });

#elif __IOS__
            uac = UIAlertController.Create("", "", UIAlertControllerStyle.ActionSheet);
            if (Commands.Count == 0)
            {
                uac.AddAction(UIAlertAction.Create("Cancel", UIAlertActionStyle.Cancel | UIAlertActionStyle.Default, ActionClicked));
            }
            else
            {
                for (int i = 0; i < Commands.Count; i++)
                {
                    UIAlertAction action = UIAlertAction.Create(Commands[i].Label, UIAlertActionStyle.Default, ActionClicked);
                    uac.AddAction(action);
                }
            }

             

            UIViewController currentController = UIApplication.SharedApplication.KeyWindow.RootViewController;
            while (currentController.PresentedViewController != null)
                currentController = currentController.PresentedViewController;

            // set layout requirements for iPad
            var popoverController = uac.PopoverPresentationController;
            if(popoverController != null)
            {
                popoverController.SourceView = currentController.View;
                popoverController.SourceRect = new CoreGraphics.CGRect(selection.X, selection.Y, selection.Width, selection.Height);
                popoverController.PermittedArrowDirections = PlacementHelper.ToArrowDirection(preferredPlacement);
            }

            currentController.PresentViewController(uac, true, null);

            return Task.Run<IUICommand>(() =>
            {
                handle.WaitOne();
                return _selectedCommand;
            });
#else
            throw new PlatformNotSupportedException();
#endif
        }
Beispiel #44
0
//		async void example(){
//			ParseObject gameScore = new ParseObject("GameScore");
//			gameScore["score"] = 1337;
//			gameScore["playerName"] = "Sean Plott";
//			await gameScore.SaveAsync();
//		}
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
//			ParseClient.Initialize("LNAuxom26NKczyL2hfU3deDyFvxkR9vAEVt3NYom",
//				"pTK01DCWyIlw3DQJludWbtnBgvpe2PqNFKa8aDmm");
			//example ();
            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);
			string Dominio_webservice = "http://alertapp-jovel.rhcloud.com/index.php/Mobile";
            WebServices = new Dictionary<string, System.Uri> {
				{"getDenuncias",new System.Uri(Dominio_webservice+"/getDenuncias")},
				{"setDenuncia",new System.Uri(Dominio_webservice+"/setDenuncia")},
				{"getDenunciaPicture",new System.Uri(Dominio_webservice+"/getDenunciaPicture")}
            };
			//este diccionario dejo de usarse pero puede resultar util luego
            ColorTipoDenuncia = new Dictionary<int, float>{
                {1, BitmapDescriptorFactory.HueRed},
                {2, BitmapDescriptorFactory.HueAzure},
                {3, BitmapDescriptorFactory.HueGreen},
                {4, BitmapDescriptorFactory.HueYellow},
            };
			MarkerTipoDenuncia = new Dictionary<int, int>{
				{1, Resource.Drawable.corte_marker},
				{2, Resource.Drawable.fuga_marker},
				{3, Resource.Drawable.damage_marker},
				{4, Resource.Drawable.otros_marker}
			};
            btnNormal = FindViewById<Button>(Resource.Id.btnNormal);
            btnSatellite = FindViewById<Button>(Resource.Id.btnSatellite);
            ibtnReload = FindViewById<ImageButton>(Resource.Id.ibtnReload);
            ibtnGps = FindViewById<ImageButton>(Resource.Id.ibtnGps);
            ibtnSearch = FindViewById<ImageButton>(Resource.Id.ibtnSearch);
            txtBuscar = FindViewById<EditText>(Resource.Id.txtBuscar);
            txtBuscar.ClearFocus();
            btnNormal.RequestFocus();
            btnNormal.Click +=btnNormal_Click;
            btnSatellite.Click +=btnSatellite_Click;
            txtBuscar.EditorAction += txtBuscar_EditorAction;
            ibtnReload.Click += ibtnReload_Click;
            ibtnGps.Click += ibtnGps_Click;
            ibtnSearch.Click += ibtnSearch_Click;

            toolBar = FindViewById<SupportToolbar>(Resource.Id.toolbar);
            toolBar.SetTitleTextColor(Color.White);
            mDrawerLayout = FindViewById<DrawerLayout>(Resource.Id.drawe_layout);
            mLeftDrawer = FindViewById<ListView>(Resource.Id.left_drawer);
            SetSupportActionBar(toolBar);

            mLeftDataSet = new List<string>();
            mLeftDataSet.Add("Bienvenido Luis Jovel");
			mLeftDataSet.Add("Listado de Denuncias");
            mLeftDataSet.Add("Filtrar Resultados");
            mLeftDataSet.Add("     Ver Todos");
            mLeftDataSet.Add("     Corte de servicio");
            mLeftDataSet.Add("     Fuga de Agua");
            mLeftDataSet.Add("     Daño a Infraestructura");
            mLeftDataSet.Add("     Otros");
            mLeftDataSet.Add("Cerrar Sesion");
            mLeftAdapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleListItem1, mLeftDataSet);
            mLeftDrawer.ItemClick += mLeftDrawer_ItemClick;
            mLeftDrawer.Adapter = mLeftAdapter;

            mDrawerToggle = new MyActionBarDrawerToggle(
                this,
                mDrawerLayout,
                Resource.String.openDrawer,
                Resource.String.closeDrawer
            );
            mDrawerLayout.SetDrawerListener(mDrawerToggle);
            SupportActionBar.SetHomeButtonEnabled(true);
            SupportActionBar.SetDisplayShowTitleEnabled(true);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);
            mDrawerToggle.SyncState();
			//GPS NUEVO
			setupGPS();
            SetUpMap();
			//GPS OBSOLETO
//            InitializeLocationManager();
            cliente = new WebClient();
            //llamar a web service
            cliente.DownloadDataAsync(WebServices["getDenuncias"]);
            cliente.DownloadDataCompleted += cliente_DownloadDataCompleted;           

            //alertdialog
            builder = new Android.App.AlertDialog.Builder(this);
            alert = builder.Create();
        }