/// <summary> /// Displays message dialog with positive, negative buttons and neutral buttons /// </summary> /// <param name="title">Dialog title</param> /// <param name="message">Dialog message</param> /// <param name="positiveButtonText">Text for positive button</param> /// <param name="onPositiveButtonClick">Positive button callback</param> /// <param name="negativeButtonText">Text for negative button</param> /// <param name="onNegativeButtonClick">Negative button callback</param> /// <param name="neutralButtonText">Text for neutral button</param> /// <param name="onNeutralButtonClick">Neutral button callback</param> /// <param name="onDismiss">On dismiss callback</param> /// <param name="theme">Dialog theme</param> public static void ShowMessageDialog(string title, string message, string positiveButtonText, Action onPositiveButtonClick, string negativeButtonText, Action onNegativeButtonClick, string neutralButtonText, Action onNeutralButtonClick, Action onDismiss = null, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroidCheck()) { return; } if (onPositiveButtonClick == null) { throw new ArgumentNullException("onPositiveButtonClick", "Button callback cannot be null"); } if (onNegativeButtonClick == null) { throw new ArgumentNullException("onNegativeButtonClick", "Button callback cannot be null"); } if (onNeutralButtonClick == null) { throw new ArgumentNullException("onNeutralButtonClick", "Button callback cannot be null"); } AGUtils.RunOnUiThread(() => { var builder = CreateMessageDialogBuilder(title, message, positiveButtonText, onPositiveButtonClick, onDismiss).SetTheme(theme); builder.SetNegativeButton(negativeButtonText, onNegativeButtonClick); builder.SetNeutralButton(neutralButtonText, onNeutralButtonClick); var dialog = builder.Create(); dialog.Show(); }); }
// Bug with date picker: http://stackoverflow.com/questions/38315419/unity-android-datepicker-size-on-nexus-7-2-gen public static int GetDialogTheme(AGDialogTheme theme) { if (theme == AGDialogTheme.Default) { return(ThemeDefault); } int deviceSdkInt = AGDeviceInfo.SDK_INT; if (deviceSdkInt >= AGDeviceInfo.VersionCodes.LOLLIPOP) { return(theme == AGDialogTheme.Light ? Theme_Material_Light_Dialog_Alert : Theme_Material_Dialog_Alert); } if (deviceSdkInt >= AGDeviceInfo.VersionCodes.ICE_CREAM_SANDWICH) { return(theme == AGDialogTheme.Light ? THEME_DEVICE_DEFAULT_LIGHT : THEME_DEVICE_DEFAULT_DARK); } if (deviceSdkInt >= AGDeviceInfo.VersionCodes.HONEYCOMB) { return(theme == AGDialogTheme.Light ? THEME_HOLO_LIGHT : THEME_HOLO_DARK); } return(ThemeDefault); }
/// <summary> /// Shows the multi item choice dialog. /// </summary> /// <returns>The multi item choice dialog.</returns> /// <param name="title">Title.</param> /// <param name="items">Items.</param> /// <param name="checkedItems">Checked items.</param> /// <param name="onItemClicked">On item clicked.</param> /// <param name="positiveButtonText">Positive button text.</param> /// <param name="onPositiveButtonClick">On positive button click.</param> /// <param name="theme">Dialog theme</param> public static void ShowMultiItemChoiceDialog(string title, string[] items, bool[] checkedItems, Action <int, bool> onItemClicked, string positiveButtonText, Action onPositiveButtonClick, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroidCheck()) { return; } if (items == null) { throw new ArgumentNullException("items", "Items can't be null"); } if (checkedItems == null) { throw new ArgumentNullException("checkedItems", "Checked items can't be null"); } if (onItemClicked == null) { throw new ArgumentNullException("onItemClicked", "Item click callback can't be null"); } if (onPositiveButtonClick == null) { throw new ArgumentNullException("onPositiveButtonClick", "Button click callback can;t be null"); } AGUtils.RunOnUiThread(() => { var builder = CreateMultiChoiceDialogBuilder(title, items, checkedItems, onItemClicked).SetTheme(theme); builder.SetPositiveButton(positiveButtonText, onPositiveButtonClick); var dialog = builder.Create(); dialog.Show(); }); }
private static AndroidJavaObject CreateDialogBuilder(AGDialogTheme theme) { int themeResource = AndroidDialogUtils.GetDialogTheme(theme); return(AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(AlertDialogBuilderClass, AGUtils.Activity) : new AndroidJavaObject(AlertDialogBuilderClass, AGUtils.Activity, themeResource)); }
/// <summary> /// Creates the spinner dialog. /// Call <see cref="Show"/> to show the spinner dialog. /// Call <see cref="Dismiss"/> to hide the spinner dialog. /// </summary> /// <returns>The spinner dialog.</returns> /// <param name="title">Title.</param> /// <param name="message">Message.</param> /// <param name="theme">Theme of the dialog.</param> public static AGProgressDialog CreateSpinnerDialog(string title, string message, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroid()) { return(null); } return(new AGProgressDialog(Style.Spinner, title, message, theme)); }
/// <summary> /// Creates the horizontal loading dialog /// </summary> /// <param name="title">Dialog title</param> /// <param name="message">Dialog message</param> /// <param name="maxValue">Maximum value of the progress bar</param> /// <param name="theme">Theme of the dialog.</param> public static AGProgressDialog CreateHorizontalDialog(string title, string message, int maxValue, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroid()) { return(null); } return(new AGProgressDialog(Style.Horizontal, title, message, theme, maxValue)); }
/// <summary> /// Shows the default Android date picker. /// </summary> /// <param name="year">Year.</param> /// <param name="month">Month.</param> /// <param name="day">Day.</param> /// <param name="onDatePicked">Date was picked callback.</param> /// <param name="onCancel">Dialog was cancelled callback.</param> /// <param name="theme">Dialog theme</param> public static void ShowDatePicker(int year, int month, int day, OnDatePicked onDatePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroid()) { return; } AGUtils.RunOnUiThread(() => { var dialog = CreateDatePickerDialog(year, month, day, onDatePicked, onCancel, theme); AndroidDialogUtils.ShowWithImmersiveModeWorkaround(dialog); }); }
/// <summary> /// Shows the chooser dialog to choose one item from the list. Dialog is dismissed on item click. /// </summary> /// <param name="title">Dialog title</param> /// <param name="items">Itmes to choose from</param> /// <param name="onClickCallback">Invoked on item click</param> /// <param name="theme">Dialog theme</param> public static void ShowChooserDialog(string title, string[] items, Action <int> onClickCallback, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroidCheck()) { return; } AGUtils.RunOnUiThread(() => { var builder = new Builder().SetTitle(title).SetTheme(theme); builder.SetItems(items, onClickCallback); var dialog = builder.Create(); dialog.Show(); }); }
public static void ShowDatePickerWithLimits(int year, int month, int day, OnDatePicked onDatePicked, Action onCancel, DateTime minDate, DateTime maxDate, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroid()) { return; } AGUtils.RunOnUiThread(() => { var dialog = CreateDatePickerDialog(year, month, day, onDatePicked, onCancel, theme); var picker = dialog.CallAJO("getDatePicker"); picker.Call("setMinDate", minDate.ToMillisSinceEpoch()); picker.Call("setMaxDate", maxDate.ToMillisSinceEpoch()); AndroidDialogUtils.ShowWithImmersiveModeWorkaround(dialog); }); }
AGProgressDialog(Style style, string title, string message, AGDialogTheme theme, int maxValue = 100) { AGUtils.RunOnUiThread( () => { var d = CreateDialog(theme); d.Call("setProgressStyle", (int)style); d.Call("setCancelable", false); d.Call("setTitle", title); d.Call("setMessage", message); d.Call("setCancelable", false); if (style == Style.Spinner) { d.Call("setIndeterminate", true); } else { d.Call("setIndeterminate", false); d.Call("setProgress", 0); d.Call("setMax", maxValue); } _dialog = d; }); }
/// <summary> /// Shows the default Android time picker. /// </summary> /// <param name="hourOfDay">Hour of day.</param> /// <param name="minute">Minute. Not Zero-base as on Android!</param> /// <param name="onTimePicked">Time was picked callback.</param> /// <param name="onCancel">Dialog was cancelled callback.</param> /// <param name="theme">Dialog theme</param> /// <param name="is24HourFormat">If the picker is in 24 hour format</param> public static void ShowTimePicker(int hourOfDay, int minute, OnTimePicked onTimePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default, bool is24HourFormat = true) { if (AGUtils.IsNotAndroidCheck()) { return; } AGUtils.RunOnUiThread(() => { var listener = new OnTimeSetListenerPoxy(onTimePicked); int themeResource = AndroidDialogUtils.GetDialogTheme(theme); var dialog = AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(TimePickerClass, AGUtils.Activity, listener, hourOfDay, minute, is24HourFormat) : new AndroidJavaObject(TimePickerClass, AGUtils.Activity, themeResource, listener, hourOfDay, minute, is24HourFormat); dialog.Call("setOnCancelListener", new DialogOnCancelListenerPoxy(onCancel)); AndroidDialogUtils.ShowWithImmersiveModeWorkaround(dialog); }); }
/// <summary> /// Shows the default Android time picker. /// </summary> /// <param name="hourOfDay">Hour of day.</param> /// <param name="minute">Minute. Not Zero-base as on Android!</param> /// <param name="onTimePicked">Time was picked callback.</param> /// <param name="onCancel">Dialog was cancelled callback.</param> /// <param name="theme">Dialog theme</param> public static void ShowTimePicker(int hourOfDay, int minute, OnTimePicked onTimePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroidCheck()) { return; } AGUtils.RunOnUiThread(() => { var listener = new AGDateTimePicker.OnTimeSetListenerPoxy(onTimePicked); int themeResource = AndroidDialogUtils.GetDialogTheme(theme); var dialog = AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(TimePickerClass, AGUtils.Activity, listener, hourOfDay, minute, true) : new AndroidJavaObject(TimePickerClass, AGUtils.Activity, themeResource, listener, hourOfDay, minute, true); dialog.Call("setOnCancelListener", new DialogOnCancelListenerPoxy(onCancel)); dialog.Call("show"); }); }
static AndroidJavaObject CreateDialog(AGDialogTheme theme) { int themeResource = AndroidDialogUtils.GetDialogTheme(theme); return(AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(ProgressDialogClass, AGUtils.Activity) : new AndroidJavaObject(ProgressDialogClass, AGUtils.Activity, themeResource)); }
public Builder SetTheme(AGDialogTheme theme) { _theme = theme; return(this); }
/// <summary> /// Shows the default Android time picker. /// </summary> /// <param name="hourOfDay">Hour of day.</param> /// <param name="minute">Minute. Not Zero-base as on Android!</param> /// <param name="onTimePicked">Time was picked callback.</param> /// <param name="onCancel">Dialog was cancelled callback.</param> /// <param name="theme">Dialog theme</param> /// <param name="is24HourFormat">If the picker is in 24 hour format</param> public static void ShowTimePicker(int hourOfDay, int minute, OnTimePicked onTimePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default, bool is24HourFormat = true) { if (AGUtils.IsNotAndroid()) { return; } AGUtils.RunOnUiThread(() => { var dialog = CreateBaseTimePicker(hourOfDay, minute, onTimePicked, onCancel, theme, is24HourFormat); AndroidDialogUtils.ShowWithImmersiveModeWorkaround(dialog); }); }
public static AndroidJavaObject CreateDatePickerDialog(int year, int month, int day, OnDatePicked onDatePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default) { var listener = new OnDateSetListenerPoxy(onDatePicked); int themeResource = AndroidDialogUtils.GetDialogTheme(theme); // Month! (0-11 for compatibility with MONTH) var dialog = AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(DatePickerClass, AGUtils.Activity, listener, year, month - 1, day) : new AndroidJavaObject(DatePickerClass, AGUtils.Activity, themeResource, listener, year, month - 1, day); dialog.Call("setOnCancelListener", new DialogOnCancelListenerPoxy(onCancel)); return(dialog); }
/// <summary> /// Shows the default Android date picker. /// </summary> /// <param name="year">Year.</param> /// <param name="month">Month.</param> /// <param name="day">Day.</param> /// <param name="onDatePicked">Date was picked callback.</param> /// <param name="onCancel">Dialog was cancelled callback.</param> /// <param name="theme">Dialog theme</param> public static void ShowDatePicker(int year, int month, int day, OnDatePicked onDatePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default) { if (AGUtils.IsNotAndroidCheck()) { return; } AGUtils.RunOnUiThread(() => { var listener = new AGDateTimePicker.OnDateSetListenerPoxy(onDatePicked); int themeResource = AndroidDialogUtils.GetDialogTheme(theme); // Month! (0-11 for compatibility with MONTH) var dialog = AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(DatePickerClass, AGUtils.Activity, listener, year, month - 1, day) : new AndroidJavaObject(DatePickerClass, AGUtils.Activity, themeResource, listener, year, month - 1, day); dialog.Call("setOnCancelListener", new DialogOnCancelListenerPoxy(onCancel)); dialog.Call("show"); }); }
static AndroidJavaObject CreateBaseTimePicker(int hourOfDay, int minute, OnTimePicked onTimePicked, Action onCancel, AGDialogTheme theme = AGDialogTheme.Default, bool is24HourFormat = true) { var listener = new OnTimeSetListenerPoxy(onTimePicked); var themeResource = AndroidDialogUtils.GetDialogTheme(theme); var dialog = AndroidDialogUtils.IsDefault(themeResource) ? new AndroidJavaObject(TimePickerClass, AGUtils.Activity, listener, hourOfDay, minute, is24HourFormat) : new AndroidJavaObject(TimePickerClass, AGUtils.Activity, themeResource, listener, hourOfDay, minute, is24HourFormat); dialog.Call("setOnCancelListener", new DialogOnCancelListenerPoxy(onCancel)); return(dialog); }