public UM_AndroidNativeDialogImpl(UM_NativeDialogBuilder builder)
        {
            m_dialog = new AN_AlertDialog(AN_DialogTheme.Light);

            m_dialog.Title   = builder.Title;
            m_dialog.Message = builder.Message;

            if (builder.PositiveButton != null)
            {
                m_dialog.SetPositiveButton(builder.PositiveButton.Title, builder.PositiveButton.ButtonAction);
            }

            if (builder.NegativeButton != null)
            {
                m_dialog.SetNegativeButton(builder.NegativeButton.Title, builder.NegativeButton.ButtonAction);
            }

            if (builder.DestructiveButton != null)
            {
                m_dialog.SetNegativeButton(builder.DestructiveButton.Title, builder.DestructiveButton.ButtonAction);
            }

            if (builder.NeutralButton != null)
            {
                m_dialog.SetNeutralButton(builder.NeutralButton.Title, builder.NeutralButton.ButtonAction);
            }
        }
        private IEnumerator TestDialogVariants(List <AN_AlertDialogConfiguration> configs)
        {
            foreach (var config in configs)
            {
                var dialog = new AN_AlertDialog(config.DialogTheme);
                dialog.Title   = config.DialogTheme.ToString();
                dialog.Message = "Alert Dialog Test with " + config.ButtonsCount + " buttons";

                if (config.ButtonsCount >= 1)
                {
                    dialog.SetPositiveButton("Positive", () => {
                    });
                }

                if (config.ButtonsCount >= 2)
                {
                    dialog.SetNegativeButton("Negative", () => {
                    });
                }

                if (config.ButtonsCount >= 3)
                {
                    dialog.SetNeutralButton("Neutral", () => {
                    });
                }

                dialog.Show();
                yield return(new WaitForSeconds(1f));

                dialog.Hide();
            }

            SetResult(SA_TestResult.OK);
            yield return(null);
        }
        //--------------------------------------
        // Private Methods
        //--------------------------------------

        public static void ShowErrorMessage(SA_iError error)
        {
            var billingResponseCode = (AN_BillingClient.BillingResponseCode)error.Code;
            var message             = new AN_AlertDialog(AN_DialogTheme.Material);

            message.Title   = "Error";
            message.Message = error.FullMessage + billingResponseCode.ToString();

            message.SetPositiveButton("Okay", () => { });
            message.Show();
        }
        public void CreateOkPopup(string title, string message, Action onOk)
        {
            AN_AlertDialog popup = new AN_AlertDialog(AN_DialogTheme.Material_Light);

            popup.Title      = title;
            popup.Message    = message;
            popup.Cancelable = false;

            popup.SetPositiveButton("OK", () =>
            {
                popup.Hide();
                Debug.Log("Ok on " + title + " is pressed.");
                onOk.SafeInvoke();
            });
            popup.Show();
        }
Beispiel #5
0
        /// <summary>
        /// Use the <see cref="RequestReview"/>  method to indicate when it makes sense
        /// within the logic of your app to ask the user for ratings and reviews within your app.
        /// </summary>
        public static void RequestReview()
        {
            string appName       = Application.productName;
            string appIdentifier = Application.identifier;

            string title     = string.Format("Rate {0}!", appName);
            string message   = string.Format("If you enjoy using {0}, please take a moment to rate it.Thanks for your support!", appName);
            string noTitle   = "No, thanks";
            string rateTitle = "Rate";

            if (Application.isEditor)
            {
                var builder = new UM_NativeDialogBuilder(title, message);
                builder.SetPositiveButton(rateTitle, () => {});
                builder.SetNegativeButton(noTitle, () => {});

                var dialog = builder.Build();
                dialog.Show();
            }

            switch (Application.platform)
            {
            case RuntimePlatform.IPhonePlayer:
                ISN_SKStoreReviewController.RequestReview();
                break;

            case RuntimePlatform.Android:


                var dialog = new AN_AlertDialog(AN_DialogTheme.Default);
                dialog.Title   = title;
                dialog.Message = message;

                dialog.SetNegativeButton(noTitle, () => {
                });

                dialog.SetPositiveButton(rateTitle, () => {
                    //This code will take user to your app Play Market page
                    System.Uri uri       = new System.Uri("market://details?id=" + appIdentifier);
                    AN_Intent viewIntent = new AN_Intent(AN_Intent.ACTION_VIEW, uri);
                    AN_MainActivity.Instance.StartActivity(viewIntent);
                });

                dialog.Show();
                break;
            }
        }
        public void CreateYesNo(string title, string message, Action onYes, Action onNo, [CanBeNull] string yesButtonName = null, [CanBeNull] string noButtonName = null)
        {
            AN_AlertDialog popup = new AN_AlertDialog(AN_DialogTheme.Material_Light);

            popup.Title      = title;
            popup.Message    = message;
            popup.Cancelable = false;

            popup.SetPositiveButton(yesButtonName ?? "YES", () =>
            {
                popup.Hide();
                Debug.Log("YES on " + title + " is pressed.");
                onYes.SafeInvoke();
            });

            popup.SetNegativeButton(noButtonName ?? "NO", () =>
            {
                popup.Hide();
                Debug.Log("NO on " + title + " is pressed.");
                onNo.SafeInvoke();
            });

            popup.Show();
        }
Beispiel #7
0
        public void AlertDialogShow(AN_AlertDialog dialog, Action <AN_AlertDialog.AN_AlertDialogCloseInfo> callback)
        {
            string json = JsonUtility.ToJson(dialog);

            AN_Java.Bridge.CallStaticWithCallback(AN_ALERT_DIALOG_CLASS, "Show", callback, json);
        }
Beispiel #8
0
        //--------------------------------------
        //  Alert Dialog
        //--------------------------------------

        public void AlertDialogHide(AN_AlertDialog dialog)
        {
            string json = JsonUtility.ToJson(dialog);

            AN_Java.Bridge.CallStatic(AN_ALERT_DIALOG_CLASS, "Hide", json);
        }
    void Start()
    {
        m_progressButton.onClick.AddListener(() => {
            //Show the preloader
            AN_Preloader.LockScreen("Please Wait...");

            //and hide it in 2 sec
            SA_Coroutine.WaitForSeconds(2f, () => {
                AN_Preloader.UnlockScreen();
            });
        });

        m_messageButton.onClick.AddListener(() => {
            var message     = new AN_AlertDialog(AN_DialogTheme.Material);
            message.Title   = "Message";
            message.Message = "Some message text";

            message.SetPositiveButton("Okay", () => {
                AN_Logger.Log("message: ok button was clicked");
            });


            message.Show();
        });


        m_dialogButton.onClick.AddListener(() => {
            var dialog     = new AN_AlertDialog(AN_DialogTheme.Light);
            dialog.Title   = "Dialog";
            dialog.Message = "Some dialog text";

            dialog.SetPositiveButton("Yes", () => {
                AN_Logger.Log("dialog: Yes button was clicked");
            });

            dialog.SetNegativeButton("No", () => {
                AN_Logger.Log("dialog: No button was clicked");
            });

            dialog.Show();
        });


        m_rateButton.onClick.AddListener(() => {
            string appName       = Application.productName;
            string appIdentifier = Application.identifier;

            var dialog     = new AN_AlertDialog(AN_DialogTheme.Default);
            dialog.Title   = string.Format("Rate {0}!", appName);
            dialog.Message = string.Format("If you enjoy using {0}, please take a moment to rate it.Thanks for your support!", appName);

            dialog.SetPositiveButton("Rate", () => {
                AN_Logger.Log("dialog: Rate button was clicked");

                //This code will take user to your app Play Market page
                System.Uri uri       = new System.Uri("market://details?id=" + appIdentifier);
                AN_Intent viewIntent = new AN_Intent(AN_Intent.ACTION_VIEW, uri);
                AN_MainActivity.Instance.StartActivity(viewIntent);
            });

            dialog.SetNegativeButton("No, thanks", () => {
                AN_Logger.Log("dialog: No, thanks button was clicked");
            });


            dialog.SetNeutralButton("Remind me later", () => {
                AN_Logger.Log("dialog: Remind me later button was clicked");
            });

            dialog.Show();
        });


        m_calendarButton.onClick.AddListener(() => {
            var date  = DateTime.Now;
            int year  = date.Year;
            int month = date.Month - 1; //Compatibility with Android Calendar..
            int day   = date.Day;

            AN_DatePickerDialog picker = new AN_DatePickerDialog(year, month, day);
            picker.Show((result) => {
                if (result.IsSucceeded)
                {
                    Debug.Log("date picked result.Year: " + result.Year);
                    //Same  Android Calendar Compatibility
                    Debug.Log("date picked result.Month: " + result.Month + 1);
                    Debug.Log("date picked result.Day: " + result.Day);
                }
                else
                {
                    Debug.Log("Failed to pick a date: " + result.Error.FullMessage);
                }
            });
        });
    }