public void Show(Context context) { var adb = new IONAlertDialog(context); var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_rename, null, false); var entry = view.FindViewById <EditText>(Resource.Id.name); entry.Hint = renamable.defaultName; entry.Text = renamable.name; adb.SetTitle(Resource.String.rename); adb.SetMessage(renamable.GetRenameMessage(context)); adb.SetView(view); adb.SetNegativeButton(Resource.String.cancel, (obj, e) => { var dialog = obj as Dialog; dialog.Dismiss(); }); adb.SetPositiveButton(Resource.String.ok_done, (obj, e) => { var dialog = obj as Dialog; dialog.Dismiss(); if (string.IsNullOrEmpty(entry.Text.Trim())) { renamable.name = renamable.defaultName; } else { renamable.name = entry.Text; } }); adb.Show(); }
public Dialog Show() { var item = rss.channels[0].items[rss.channels[0].items.Count - 1]; var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_rss, null); var title = view.FindViewById <TextView>(Resource.Id.title); var content = view.FindViewById <TextView>(Resource.Id.content); title.Text = item.title; content.Text = Html.FromHtml(item.description).ToString(); var adb = new IONAlertDialog(context); adb.SetPositiveButton(Resource.String.open, (sender, e) => { var uri = Android.Net.Uri.Parse(item.link); var intent = new Intent(); intent.SetData(uri); intent.AddFlags(ActivityFlags.NewTask); context.StartActivity(intent); }); adb.SetNegativeButton(Resource.String.close, (sender, e) => { }); adb.SetTitle(Resource.String.rss); adb.SetView(view); var ret = adb.Create(); ret.Show(); return(ret); }
public Android.App.Dialog Show() { var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_manual_sensor_edit, null); var title = view.FindViewById <TextView>(Resource.Id.title); var name = view.FindViewById <EditText>(Resource.Id.name); var measurement = view.FindViewById <EditText>(Resource.Id.measurement); var button = view.FindViewById <Button>(Resource.Id.unit); var unit = sensor.unit; button.Text = unit.ToString(); if (sensor != null) { name.Text = sensor.name; measurement.Text = SensorUtils.ToFormattedString(sensor.measurement); } button.SetOnClickListener(new ViewClickAction((v) => { UnitDialog.Create(context, sensor.supportedUnits, (obj, u) => { unit = u; button.Text = unit.ToString(); }).Show(); })); var adb = new IONAlertDialog(context); adb.SetTitle(Resource.String.edit_manual_entry); adb.SetView(view); adb.SetNegativeButton(Resource.String.cancel, (obj, args) => { var d = obj as Android.App.Dialog; d.Dismiss(); }); adb.SetPositiveButton(Resource.String.ok_done, (obj, args) => { var d = obj as Android.App.Dialog; try { sensor.name = name.Text; var meas = double.Parse(measurement.Text); sensor.measurement = unit.OfScalar(meas); if (action != null) { action(d, sensor); } d.Dismiss(); } catch (Exception e) { Log.E(this, "Failed to edit manual sensor", e); Toast.MakeText(context, Resource.String.please_enter_valid_number, ToastLength.Long).Show(); } }); return(adb.Show()); }
/// <summary> /// Shows the dialog. /// </summary> /// <param name="context">Context.</param> public AlertDialog Show(Context context) { var adb = new IONAlertDialog(context); adb.SetTitle(title); adb.SetMessage(message); var entry = new EditText(context); entry.Hint = hint; entry.Text = initialValue + ""; entry.InputType = Android.Text.InputTypes.NumberFlagDecimal; adb.SetView(entry); AlertDialog ret = null; adb.SetNegativeButton(context.GetString(Resource.String.cancel), (obj, args) => { var dialog = obj as Android.App.Dialog; dialog.Dismiss(); }); adb.SetPositiveButton(context.GetString(Resource.String.ok_done), (obj, args) => { var dialog = obj as Android.App.Dialog; try { if (string.IsNullOrEmpty(entry.Text)) { handler(ret, 0); } else { var number = double.Parse(entry.Text); if (handler != null) { handler(ret, number); } } dialog.Dismiss(); } catch (Exception) { Toast.MakeText(context, Resource.String.please_enter_valid_number, ToastLength.Long).Show(); } }); ret = adb.Create(); ret.Show(); return(ret); }
/// <summary> /// Shows the dialog. /// </summary> /// <param name="context">Context.</param> public AlertDialog Show(Context context) { var view = LayoutInflater.From(context).Inflate(Resource.Layout.dialog_date_time, null); var date = view.FindViewById <DatePicker>(Resource.Id.date); var time = view.FindViewById <TimePicker>(Resource.Id.time); var hours = 0; var minutes = 0; time.TimeChanged += (sender, e) => { hours = e.HourOfDay; minutes = e.Minute; }; date.MinDate = start.ToUTCMilliseconds(); date.MaxDate = end.ToUTCMilliseconds(); date.CalendarViewShown = false; var adb = new IONAlertDialog(context); adb.SetTitle(title); adb.SetView(view); adb.SetNegativeButton(context.GetString(Resource.String.cancel), (obj, args) => { var dialog = obj as Android.App.Dialog; dialog.Dismiss(); }); adb.SetPositiveButton(context.GetString(Resource.String.ok_done), (obj, args) => { var dialog = obj as Android.App.Dialog; dialog.Dismiss(); var dateTime = date.DateTime; dateTime = dateTime.AddHours(hours); dateTime = dateTime.AddMinutes(minutes); if (handler != null) { handler(obj, dateTime); } }); return(adb.Show()); }
public static Dialog ShowDialog(Context context, string title, string message, Action positive, Action negative = null) { var adb = new IONAlertDialog(context, title); adb.SetMessage(message); adb.SetNegativeButton(Resource.String.cancel, (sender, e) => { (sender as Dialog).Dismiss(); if (negative != null) { negative(); } }); adb.SetPositiveButton(Resource.String.ok, (sender, e) => { (sender as Dialog).Dismiss(); positive(); }); return(adb.Show()); }
public Android.App.Dialog Show() { var r = context.Resources; var view = LayoutInflater.From(context).Inflate(Resource.Layout.analyzer_dialog_viewer, null); var state = view.FindViewById <TextView>(Resource.Id.state); switch (side) { case Analyzer.ESide.High: state.SetText(Resource.String.analyzer_side_high); state.SetBackgroundColor(Resource.Color.red.AsResourceColor(context)); state.SetTextColor(Resource.Color.white.AsResourceColor(context)); break; case Analyzer.ESide.Low: state.SetText(Resource.String.analyzer_side_low); state.SetBackgroundColor(Resource.Color.blue.AsResourceColor(context)); state.SetTextColor(Resource.Color.white.AsResourceColor(context)); break; default: state.SetText(Resource.String.analyzer_side_none); state.SetBackgroundColor(Resource.Color.white.AsResourceColor(context)); state.SetTextColor(Resource.Color.black.AsResourceColor(context)); break; } var template = new ManifoldViewTemplate(view, cache); template.Bind(new Manifold(sensor)); var adb = new IONAlertDialog(context); adb.SetTitle(sensor.name); adb.SetView(view); adb.SetNegativeButton(Resource.String.cancel, (obj, which) => { var d = obj as Android.App.Dialog; d.Dismiss(); cache.Clear(); }); if (analyzer.isEditable) { adb.SetPositiveButton(Resource.String.actions, (sender, e) => { var ldb = new ListDialogBuilder(context); ldb.SetTitle(string.Format(context.GetString(Resource.String.devices_actions_1arg), sensor.name)); var dgs = sensor as GaugeDeviceSensor; if (dgs != null && !dgs.device.isConnected) { ldb.AddItem(Resource.String.reconnect, () => { dgs.device.connection.Connect(); }); } ldb.AddItem(Resource.String.rename, () => { if (sensor is GaugeDeviceSensor) { var gds = sensor as GaugeDeviceSensor; new RenameDialog(gds.device).Show(context); } else { new RenameDialog(sensor).Show(context); } }); ldb.AddItem(Resource.String.alarm, () => { var i = new Intent(context, typeof(SensorAlarmActivity)); i.PutExtra(SensorAlarmActivity.EXTRA_SENSOR, sensor.ToParcelable()); context.StartActivity(i); }); if (dgs != null && dgs.device.isConnected) { ldb.AddItem(Resource.String.disconnect, () => { dgs.device.connection.Disconnect(); }); } ldb.AddItem(Resource.String.remove, () => { analyzer.RemoveSensor(sensor); }); ldb.Show(); cache.Clear(); }); } return(adb.Show()); }