Exemple #1
0
 public static AlertDialog createIncomingCallDialog(Context context, IncomingCall incomingCall, DialogInterface.OnClickListener answerCallClickListener, DialogInterface.OnClickListener cancelClickListener)
 {
     AlertDialog.Builder alertDialogBuilder = new AlertDialog.Builder(context);
     alertDialogBuilder.Icon  = R.drawable.ic_call_black_24dp;
     alertDialogBuilder.Title = "Incoming Call";
     alertDialogBuilder.setPositiveButton("Accept", answerCallClickListener);
     alertDialogBuilder.setNegativeButton("Reject", cancelClickListener);
     alertDialogBuilder.Message = incomingCall.From + " is calling.";
     return(alertDialogBuilder.create());
 }
Exemple #2
0
 public static AlertDialog ShowAlertDialog(Context mContext, String message, String PositiveButton, String NegativeButton)
 {
     AlertDialog.Builder builder = new AlertDialog.Builder(mContext);
     builder.SetMessage(message);
     builder.SetCancelable(true);
     builder.SetNegativeButton(NegativeButton, null);
     builder.setPositiveButton(PositiveButton, null);
     AlertDialog alertDialog = builder.Create();
     alertDialog.Show();
     return alertDialog;
 }
Exemple #3
0
        public override bool onOptionsItemSelected(MenuItem item)
        {
            int id = item.ItemId;

            switch (id)
            {
            case R.id.action_new_thing:
                renderNewThingPopup();
                break;

            case R.id.change_floor:
                renderChangeCarpetPopup();
                break;

            case R.id.action_rotate:
                if (mSelectedThing != null)
                {
                    int rotation = mSelectedThing.Rotation;

                    if (rotation >= 270)
                    {
                        mSelectedThing.Rotation = 0;
                    }
                    else
                    {
                        mSelectedThing.Rotation = rotation + 90;
                    }
                    updateOfficeThing(mSelectedThing.Key, mSelectedThing);
                }
                break;

            case R.id.action_delete:
                deleteOfficeThing(mSelectedThing.Key, mSelectedThing);
                break;

            case R.id.action_edit:
                AlertDialog.Builder builder = new AlertDialog.Builder(this);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.EditText entry = new android.widget.EditText(this);
                EditText entry = new EditText(this);

                builder.setMessage(getString([email protected]_desk_name_description)).setTitle(getString([email protected]_desk_name_title)).setView(entry);

                builder.setPositiveButton(getString([email protected]_desk_name_save), new OnClickListenerAnonymousInnerClassHelper(this, id, entry));
                builder.show();
                break;
            }
            return(base.onOptionsItemSelected(item));
        }
Exemple #4
0
 public virtual void onFileActionTransferRequested(int id, string path)
 {
     outerInstance.mFilePath = path;
     outerInstance.mTransId  = id;
     runOnUiThread(() =>
     {
         AlertDialog.Builder alertbox = new AlertDialog.Builder(outerInstance);
         alertbox.Message             = "Do you want to receive file: " + outerInstance.mFilePath + " ?";
         alertbox.setPositiveButton("Accept", new OnClickListenerAnonymousInnerClassHelper(this));
         alertbox.setNegativeButton("Reject", new OnClickListenerAnonymousInnerClassHelper2(this));
         alertbox.Cancelable  = false;
         outerInstance.mAlert = alertbox.create();
         outerInstance.mAlert.show();
     });
 }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: public void showDiallog(final int position)
        public virtual void showDiallog(int position)
        {
            AlertDialog.Builder builder = new AlertDialog.Builder(this);

            builder.Title   = "Confirm";
            builder.Message = "Disconnect ?";

            builder.setPositiveButton("YES", new OnClickListenerAnonymousInnerClassHelper(this, position));

            builder.setNegativeButton("NO", new OnClickListenerAnonymousInnerClassHelper2(this));

            AlertDialog alert = builder.create();

            alert.show();
        }
Exemple #6
0
 void btnExecute(View v)
 {
     try
     {
         var eval = new Evaluator();
         var res  = eval.Evaluate(TbValue.Text.toString());
         TbValue.Text = res.toString();
     }
     catch (Exception e)
     {
         var dlg = new AlertDialog.Builder(this);
         dlg.Message = "Error evaluating: " + e.Message;
         dlg.setPositiveButton("OK", null);
         dlg.Cancelable = true;
         dlg.create().show();
     }
 }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void invokeInstallOption(final int msgID, String msg)
        private void invokeInstallOption(int msgID, string msg)
        {
            DialogInterface.OnClickListener msgClick = new OnClickListenerAnonymousInnerClassHelper(this, msgID);

            AlertDialog.Builder message = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK);

            if (msgID != -1)
            {
                message.Message = msgID;
            }

            if (msg != null)
            {
                message.Message = msg;
            }

            message.setPositiveButton([email protected]_str, msgClick);
            message.Cancelable = false;

            message.show();
        }
        // http://www.codeproject.com/Tips/623446/Style-Any-Activity-as-an-Alert-Dialog-in-Android
        // android:theme="@android:style/Theme.Holo.Dialog"



        protected override void onCreate(global::android.os.Bundle savedInstanceState)
        {
            ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext = this;

            // X:\jsc.svn\examples\java\android\forms\AndroidFormsActivity\AndroidFormsActivity\ApplicationActivity.cs

            // cmd /K c:\util\android-sdk-windows\platform-tools\adb.exe logcat
            // Camera PTP

            // http://developer.android.com/guide/topics/ui/notifiers/notifications.html

            base.onCreate(savedInstanceState);

            var sv = new ScrollView(this);
            var ll = new LinearLayout(this);

            ll.setOrientation(LinearLayout.VERTICAL);
            sv.addView(ll);


            var b = new android.widget.Button(this);

            // jsc is doing the wrong thing here
            var SDK_INT = android.os.Build.VERSION.SDK_INT;

            b.setText("Notify! " + new { SDK_INT, android.os.Build.VERSION.SDK });
            int counter = 0;



            // http://stackoverflow.com/questions/12900795/how-to-get-a-pin-number-password-keyboard-in-android
            //var t = new EditText(this);
            //t.setInputType(android.text.InputType.TYPE_NUMBER_VARIATION_PASSWORD);
            //t.setTransformationMethod(android.text.method.PasswordTransformationMethod.getInstance());
            //ll.addView(t);

            // ScriptCoreLib.Ultra ?
            b.AtClick(
                delegate
            {
                counter++;

                // X:\jsc.svn\examples\javascript\android\Test\TestPINDialog\TestPINDialog\ApplicationWebService.cs

                var alertDialog = new AlertDialog.Builder(this);

                alertDialog.setTitle("Hello world");



                alertDialog.setPositiveButton("OK",
                                              new xOnClickListener
                {
                    yield = delegate
                    {
                        b.setText("clicked! " + new { id = Thread.currentThread().getId() });
                    }
                }

                                              );


                var cc = new AndroidFormsActivity.ApplicationControl();


                //ScriptCoreLib.Extensions.Android.AndroidFormsExtensions.AttachTo(
                //    cc,

                // X:\jsc.svn\core\ScriptCoreLibAndroid.Windows.Forms\ScriptCoreLibAndroid.Windows.Forms\Extensions\Android\AndroidFormsExtensions.cs

                __Control _cc = cc;

                _cc.InternalSetContext(this);

                alertDialog.setView(_cc.InternalGetElement());


                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);

                // can we do async yet?
                alertDialog.create().show();
            }
                );

            ll.addView(b);

            this.setContentView(sv);

            // X:\jsc.svn\examples\java\android\HelloOpenGLES20Activity\HelloOpenGLES20Activity\ScriptCoreLib.Android\Shader.cs

            // Error	1	'FormsMessageBox.Activities.ApplicationActivity' does not contain a definition for 'ShowLongToast' and no extension method 'ShowLongToast' accepting a first argument of type 'FormsMessageBox.Activities.ApplicationActivity' could be found (are you missing a using directive or an assembly reference?)	X:\jsc.svn\examples\java\android\FormsMessageBox\FormsMessageBox\ApplicationActivity.cs	80	18	FormsMessageBox
            //this.ShowLongToast("http://jsc-solutions.net");
        }
		public override bool onOptionsItemSelected(MenuItem item)
		{
			int id = item.ItemId;
			switch (id)
			{
				case R.id.action_new_thing:
					renderNewThingPopup();
					break;
				case R.id.change_floor:
					renderChangeCarpetPopup();
					break;
				case R.id.action_rotate:
					if (mSelectedThing != null)
					{
						int rotation = mSelectedThing.Rotation;

						if (rotation >= 270)
						{
							mSelectedThing.Rotation = 0;
						}
						else
						{
							mSelectedThing.Rotation = rotation + 90;
						}
						updateOfficeThing(mSelectedThing.Key, mSelectedThing);
					}
					break;
				case R.id.action_delete:
					deleteOfficeThing(mSelectedThing.Key, mSelectedThing);
					break;
				case R.id.action_edit:
					AlertDialog.Builder builder = new AlertDialog.Builder(this);
//JAVA TO C# CONVERTER WARNING: The original Java variable was marked 'final':
//ORIGINAL LINE: final android.widget.EditText entry = new android.widget.EditText(this);
					EditText entry = new EditText(this);

					builder.setMessage(getString([email protected]_desk_name_description)).setTitle(getString([email protected]_desk_name_title)).setView(entry);

					builder.setPositiveButton(getString([email protected]_desk_name_save), new OnClickListenerAnonymousInnerClassHelper(this, id, entry));
					builder.show();
					break;
			}
			return base.onOptionsItemSelected(item);
		}
        public static global::System.Windows.Forms.DialogResult Show(string text, string caption)
        {
            // or are we called on a background thread?
            // for java, we can block a worker thread until ui is shown. for javascript cannot do it without async?
            // assume we are activity based..
            var context = ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext as Activity;
            var ui      = context.getMainLooper() == Looper.myLooper();

            Console.WriteLine("enter MessageBox.Show " + new { ui });

            var value   = default(global::System.Windows.Forms.DialogResult);
            var thread0 = Thread.CurrentThread;
            var sync    = new AutoResetEvent(false);

            context.runOnUiThread(
                a =>
            {
                //thread0 = Thread.CurrentThread;
                //sync0ui.Set();

                // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\Library\ApplicationControl.cs
                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201410/20141025
                // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs


                var alertDialog = new AlertDialog.Builder(context);

                alertDialog.setTitle(caption);

                if (!string.IsNullOrEmpty(caption))
                {
                    alertDialog.setMessage(text);
                }

                // https://sites.google.com/a/jsc-solutions.net/backlog/knowledge-base/2014/201410/20141026


                alertDialog.setPositiveButton("OK",
                                              new xDialogInterface_OnClickListener
                {
                    yield = delegate
                    {
                        Console.WriteLine(" alertDialog.setPositiveButton");
                        value = global::System.Windows.Forms.DialogResult.OK;
                        //sync.Set();
                    }
                }
                                              );

                // skip icons?
                //alertDialog.setIcon(android.R.drawable.star_off);
                var dialog = alertDialog.create();

                dialog.setOnDismissListener(
                    new xDialogInterface_OnDismissListener
                {
                    yield = delegate
                    {
                        Console.WriteLine("  dialog.setOnDismissListener");
                        sync.Set();

                        if (ui)
                        {
                            throw null;
                        }
                    }
                }
                    );

                dialog.show();


                // http://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android
                // http://developer.android.com/reference/android/os/Looper.html



                //sync.Set();
            }
                );



            // need to poll? discard?


            if (ui)
            {
                try
                {
                    // loop until we throw null
                    // where is it thrown?
                    android.os.Looper.loop();
                }
                catch
                {
                }
            }
            else
            {
                sync.WaitOne();
            }

            Console.WriteLine("exit MessageBox.Show " + new { ui, value });
            return(value);
        }
        private void button1_Click(object sender, EventArgs e)
        {
            // http://stackoverflow.com/questions/2028697/dialogs-alertdialogs-how-to-block-execution-while-dialog-is-up-net-style
            // http://mindfiremobile.wordpress.com/2014/04/21/displaying-alert-dialog-in-android-using-xamarin/

            //button1.Text = "Clicked!";

            // X:\jsc.svn\examples\java\android\forms\FormsMessageBox\FormsMessageBox\ApplicationActivity.cs
            // X:\jsc.svn\examples\java\android\Test\TestAlertDialog\TestAlertDialog\ApplicationActivity.cs
            var alertDialog = new AlertDialog.Builder(ScriptCoreLib.Android.ThreadLocalContextReference.CurrentContext);

            alertDialog.setTitle("Reset...");
            alertDialog.setMessage("Are you sure?");

            alertDialog.setOnDismissListener(
                new xDialogInterface_OnDismissListener
            {
                yield = delegate
                {
                    throw null;
                }
            }
                );

            alertDialog.setPositiveButton("OK",
                                          new xOnClickListener
            {
                yield = delegate
                {
                    button1.Text = "clicked! " + new
                    {
                        Thread.CurrentThread.ManagedThreadId
                    };
                }
            }

                                          );

            // skip icons?
            //alertDialog.setIcon(android.R.drawable.star_off);

            // can we do async yet?
            alertDialog.create().show();

            // http://stackoverflow.com/questions/13974661/runonuithread-vs-looper-getmainlooper-post-in-android

            //android.os.Looper.getMainLooper().loop();

            // http://developer.android.com/reference/android/os/Looper.html

            try
            {
                // loop until we throw null
                android.os.Looper.loop();
            }
            catch
            {
            }

            button1.Text = "clicked! after looper " + new
            {
                Thread.CurrentThread.ManagedThreadId
            };

            //alertDialog.create().show();
        }
//JAVA TO C# CONVERTER WARNING: 'final' parameters are not available in .NET:
//ORIGINAL LINE: private void invokeInstallOption(final int msgID, String msg)
		private void invokeInstallOption(int msgID, string msg)
		{

			DialogInterface.OnClickListener msgClick = new OnClickListenerAnonymousInnerClassHelper(this, msgID);

			AlertDialog.Builder message = new AlertDialog.Builder(this, AlertDialog.THEME_HOLO_DARK);

			if (msgID != -1)
			{
				message.Message = msgID;
			}

			if (msg != null)
			{
				message.Message = msg;
			}

			message.setPositiveButton([email protected]_str, msgClick);
			message.Cancelable = false;

			message.show();

		}
			public virtual void onFileActionTransferRequested(int id, string path)
			{
				outerInstance.mFilePath = path;
				outerInstance.mTransId = id;
				runOnUiThread(() =>
				{
					AlertDialog.Builder alertbox = new AlertDialog.Builder(outerInstance);
					alertbox.Message = "Do you want to receive file: " + outerInstance.mFilePath + " ?";
					alertbox.setPositiveButton("Accept", new OnClickListenerAnonymousInnerClassHelper(this));
					alertbox.setNegativeButton("Reject", new OnClickListenerAnonymousInnerClassHelper2(this));
					alertbox.Cancelable = false;
					outerInstance.mAlert = alertbox.create();
					outerInstance.mAlert.show();
				});
			}