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();
        }
        public override void ActionSheet(ActionSheetConfig config)
        {
            var array = config
                        .Options
                        .Select(x => x.Text)
                        .ToArray();

            var dlg = new AlertDialog
                      .Builder(this.getTopActivity())
                      .SetCancelable(false)
                      .SetTitle(config.Title);

            dlg.SetItems(array, (sender, args) => config.Options[args.Which].Action.TryExecute());

            if (config.Destructive != null)
            {
                dlg.SetNegativeButton(config.Destructive.Text, (sender, e) => config.Destructive.Action.TryExecute());
            }

            if (config.Cancel != null)
            {
                dlg.SetNeutralButton(config.Cancel.Text, (sender, e) => config.Cancel.Action.TryExecute());
            }

            Utils.RequestMainThread(() => dlg.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();
        }
        public override void ActionSheet(ActionSheetConfig config)
        {
            var dlg = new AlertDialog
                .Builder(this.GetTopActivity())
                .SetCancelable(false)
                .SetTitle(config.Title);

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null)) {
                var adapter = new ActionSheetListAdapter(this.GetTopActivity(), Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else {
                var array = config
                    .Options
                    .Select(x => x.Text)
                    .ToArray();

                dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke());
            }

            if (config.Destructive != null)
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());

            if (config.Cancel != null)
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());

            Utils.RequestMainThread(() => dlg.ShowExt());
        }
Beispiel #5
0
        public override void ActionSheet(ActionSheetConfig config)
        {
            var dlg = new AlertDialog
                      .Builder(this.GetTopActivity())
                      .SetCancelable(false)
                      .SetTitle(config.Title);

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null))
            {
                var adapter = new ActionSheetListAdapter(this.GetTopActivity(), Android.Resource.Layout.SelectDialogItem, Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else
            {
                var array = config
                            .Options
                            .Select(x => x.Text)
                            .ToArray();

                dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke());
            }

            if (config.Destructive != null)
            {
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());
            }

            if (config.Cancel != null)
            {
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());
            }

            Utils.RequestMainThread(() => dlg.ShowExt());
        }
Beispiel #6
0
        private void ProfilePic_Click(object sender, EventArgs e)
        {
            //Open Dialog
            AlertDialog.Builder alertBuilder = new AlertDialog.Builder(this);

            alertBuilder.SetTitle("Add Photo");
            alertBuilder.SetItems(Resource.Array.upload_photo, this);

            AlertDialog alertDialog = alertBuilder.Create();

            alertDialog.Show();
        }
Beispiel #7
0
        private void KeepDeletedClick(object sender, Preference.PreferenceClickEventArgs e)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
            builder.SetTitle("Delete song when removing them from a synced playlist:");
            builder.SetItems(new string[] { "True", "False" }, (s, args) =>
            {
                ISharedPreferences pref         = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                ISharedPreferencesEditor editor = pref.Edit();
                editor.PutBoolean("keepDeleted", args.Which == 1);
                editor.Apply();

                Preference prefButton = FindPreference("keepDeleted");
                prefButton.Summary    = args.Which == 0 ? "True" : "False";
            });
            builder.Show();
        }
        public Dialog Build(AppCompatActivity activity, ActionSheetConfig config)
        {
            var dialog = new AppCompatAlertDialog.Builder(activity, config.AndroidStyleId ?? 0)
                         .SetTitle(config.Title);

            if (config.Cancel != null)
            {
                dialog.SetNeutralButton(config.Cancel.Text, (s, a) =>
                {
                    config.Cancel.Action?.Invoke();
                });
            }

            if (config.Destructive != null)
            {
                dialog.SetNegativeButton(config.Destructive.Text, (s, a) =>
                {
                    config.Destructive.Action?.Invoke();
                });
            }

            if (config.Items != null && config.Items.Count > 0)
            {
                if (config.Items.Any(t => t.ItemIcon != null))
                {
                    var adapter = new ActionSheetListAdapter(activity, global::Android.Resource.Layout.SelectDialogItem, global::Android.Resource.Id.Text1, config);

                    dialog.SetAdapter(adapter, (s, a) =>
                    {
                        config.Items[a.Which].Action?.Invoke();
                    });
                }
                else
                {
                    var array = config.Items.Select(t => t.Text).ToArray();

                    dialog.SetItems(array, (s, a) =>
                    {
                        config.Items[a.Which].Action?.Invoke();
                    });
                }
            }

            return(dialog.Create());
        }
Beispiel #9
0
        public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
        {
            view = inflater.Inflate(Resource.Layout.weld_count_fragment, container, false);

            var refresher = view.FindViewById <SwipeRefreshLayout>(Resource.Id.srl);

            if (refresher != null)
            {
                refresher.Refresh += delegate
                {
                    Refresh(forced: true);
                    refresher.Refreshing = false;
                };
            }

            listView            = view.FindViewById <ListView>(Resource.Id.listView);
            listView.Adapter    = adapter;
            listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
            {
                var builder = new AlertDialog.Builder(Context);
                builder.SetItems(Resource.Array.select_dialog_items, (object sender1, DialogClickEventArgs e1) =>
                {
                    var items = Resources.GetStringArray(Resource.Array.select_dialog_items);
                    var item  = items[(int)e1.Which];
                    if (e1.Which == 0)
                    {
                        ListView_Click(e.Position);
                    }
                    else if (e1.Which == 1)
                    {
                        Pref.TextViewDialog(Context, null, adapter.GetItem(e.Position).RowText());
                    }
                });
                builder.Create().Show();
            };
            listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
            {
                ListView_Click(e.Position);
            };

            return(view);
        }
Beispiel #10
0
        private void ChangeTheme(object sender, Preference.PreferenceClickEventArgs e)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(Activity, MainActivity.dialogTheme);
            builder.SetTitle(Resources.GetString(Resource.String.theme_dialog));
            builder.SetItems(new[] { Resources.GetString(Resource.String.white_theme), Resources.GetString(Resource.String.dark_theme), Resources.GetString(Resource.String.black_theme) }, (s, args) =>
            {
                ISharedPreferences pref         = PreferenceManager.GetDefaultSharedPreferences(Application.Context);
                ISharedPreferencesEditor editor = pref.Edit();
                editor.PutInt("theme", args.Which);
                editor.Apply();

                Preference prefButton = FindPreference("theme");
                prefButton.Summary    = args.Which == 0 ? Resources.GetString(Resource.String.white_theme) : Resources.GetString(Resource.String.dark_theme);

                MainActivity.LoadTheme(MainActivity.instance);
                MainActivity.instance.Recreate();
                Activity.Recreate();
            });
            builder.Show();
        }
Beispiel #11
0
        public static AppCompatAlertDialog.Builder Build(AppCompatActivity activity, ActionSheetConfig config)
        {
            var dlg = new AppCompatAlertDialog
                      .Builder(activity)
                      .SetCancelable(false)
                      .SetTitle(config.Title);

            //.SetCustomTitle(new TextView(activity) {
            //    Text = config.Title,
            //    TextSize = 18.0f
            //});

            if (config.ItemIcon != null || config.Options.Any(x => x.ItemIcon != null))
            {
                var adapter = new ActionSheetListAdapter(activity, Android.Resource.Layout.SelectDialogItem,
                                                         Android.Resource.Id.Text1, config);
                dlg.SetAdapter(adapter, (s, a) => config.Options[a.Which].Action?.Invoke());
            }
            else
            {
                var array = config
                            .Options
                            .Select(x => x.Text)
                            .ToArray();

                dlg.SetItems(array, (s, args) => config.Options[args.Which].Action?.Invoke());
            }

            if (config.Destructive != null)
            {
                dlg.SetNegativeButton(config.Destructive.Text, (s, a) => config.Destructive.Action?.Invoke());
            }

            if (config.Cancel != null)
            {
                dlg.SetNeutralButton(config.Cancel.Text, (s, a) => config.Cancel.Action?.Invoke());
            }

            return(dlg);
        }
Beispiel #12
0
        public override void ActionSheet(ActionSheetConfig config)
        {
            var array = config
                .Options
                .Select(x => x.Text)
                .ToArray();

            var dlg = new AlertDialog
                .Builder(this.getTopActivity())
                .SetCancelable(false)
                .SetTitle(config.Title);

            dlg.SetItems(array, (sender, args) => config.Options[args.Which].Action.TryExecute());

            if (config.Destructive != null)
                dlg.SetNegativeButton(config.Destructive.Text, (sender, e) => config.Destructive.Action.TryExecute());

            if (config.Cancel != null)
                dlg.SetNeutralButton(config.Cancel.Text, (sender, e) => config.Cancel.Action.TryExecute());

            Utils.RequestMainThread(() => dlg.Show());
        }
		public override View OnCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState)
		{
			view = inflater.Inflate(Resource.Layout.weld_count_fragment, container, false);

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

			listView = view.FindViewById<ListView>(Resource.Id.listView);
			listView.Adapter = adapter;
			listView.ItemClick += (object sender, AdapterView.ItemClickEventArgs e) =>
			{
				var builder = new AlertDialog.Builder(Context);
				builder.SetItems(Resource.Array.select_dialog_items, (object sender1, DialogClickEventArgs e1) =>
				{
					var items = Resources.GetStringArray(Resource.Array.select_dialog_items);
					var item = items[(int)e1.Which];
					if (e1.Which == 0) {
						ListView_Click(e.Position);
					} else if (e1.Which == 1) {
						Pref.TextViewDialog(Context, null, adapter.GetItem(e.Position).RowText());
					}
				});
				builder.Create().Show();
			};
			listView.ItemLongClick += (object sender, AdapterView.ItemLongClickEventArgs e) =>
			{
				ListView_Click(e.Position);
			};

			return view;
		}