Exemplo n.º 1
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Set our view from the "main" layout resource
            SetContentView(Resource.Layout.Main);

            EditText phoneNumberText     = FindViewById <EditText>(Resource.Id.PhoneNumberText);
            TextView translatedPhoneword = FindViewById <TextView>(Resource.Id.TranslatedPhoneWord);
            Button   translateButton     = FindViewById <Button>(Resource.Id.TranslateButton);

            Button translationHistoryButton = FindViewById <Button>(Resource.Id.TranslationHistoryButton);

            string translatedNumber = string.Empty;

            translateButton.Click += (sender, e) =>
            {
                translatedNumber = PhoneTranslator.ToNumber(phoneNumberText.Text);
                if (!string.IsNullOrWhiteSpace(translatedNumber))
                {
                    translatedPhoneword.Text = translatedNumber;
                    phoneNumbers.Add(translatedNumber);
                    translationHistoryButton.Enabled = true;
                }
                else
                {
                    translatedPhoneword.Text = string.Empty;
                }
            };

            translationHistoryButton.Click += (sender, e) =>
            {
                var intent = new Intent(this, typeof(TranslationHistoryActivity));
                intent.PutStringArrayListExtra("phone_numbers", phoneNumbers);
                StartActivity(intent);
            };
        }
Exemplo n.º 2
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();
            // Perform any additional setup after loading the view, typically from a nib.

            string translatedNumber = "";

            TranslateButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                translatedNumber = PhoneTranslator.ToNumber(PhoneTextNumber.Text);

                PhoneTextNumber.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call" + translatedNumber, UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };

            CallButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                var url = new NSUrl("tel:" + translatedNumber);
                if (UIApplication.SharedApplication.OpenUrl(url))
                {
                    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            };
        }
Exemplo n.º 3
0
        public override void ViewDidLoad()
        {
            base.ViewDidLoad();

            string translatedNumber = "";

            TranslateButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                // Convert the phone number with text to a number
                // using PhoneTranslator.cs
                translatedNumber = PhoneTranslator.ToNumber(PhoneNumberText.Text);

                // 키보드 해제
                PhoneNumberText.ResignFirstResponder();

                if (translatedNumber == "")
                {
                    CallButton.SetTitle("Call", UIControlState.Normal);
                    CallButton.Enabled = false;
                }
                else
                {
                    CallButton.SetTitle("Call " + translatedNumber, UIControlState.Normal);
                    CallButton.Enabled = true;
                }
            };


            CallButton.TouchUpInside += (object sender, EventArgs e) =>
            {
                PhoneNumbers.Add(translatedNumber);
                var url = new NSUrl("tel:" + translatedNumber);

                // Use URL handler with tel: prefix to invoke Apple's Phone app,
                // otherwise show an alert dialog

                if (!UIApplication.SharedApplication.OpenUrl(url))
                {
                    var alert = UIAlertController.Create("Not supported", "Scheme 'tel:' is not supported on this device", UIAlertControllerStyle.Alert);
                    alert.AddAction(UIAlertAction.Create("Ok", UIAlertActionStyle.Default, null));
                    PresentViewController(alert, true, null);
                }
            };

            //Segue 없이 탐색
            //CallHistoryButton.TouchUpInside += (object sender, EventArgs e) =>
            //{
            //    CallHistoryController callHistory = this.Storyboard.InstantiateViewController("CallHistoryController") as CallHistoryController;
            //    if (callHistory != null)
            //    {
            //        callHistory.PhoneNumbers = PhoneNumbers;
            //        this.NavigationController.PushViewController(callHistory, true);
            //    }
            //};

            //CAGradientLayer gradient = new CAGradientLayer();
            //gradient.Frame = this.CallButton.Frame;
            //gradient.Colors = new CGColor[] {UIColor.Yellow.CGColor , UIColor.Blue.CGColor};
            //gradient.StartPoint = new CGPoint(0.0, 0.5);
            //gradient.EndPoint = new CGPoint(0.5, 0.5);
            //gradient.Locations = new NSNumber[] {Convert.NS(this.CallButton.Frame.Location.X), this.CallButton.Frame.Location.X };

            //CallButton.Layer.InsertSublayer(gradient, 0);
            //CallButton.Layer.CornerRadius = CallButton.Frame.Size.Height / 2;
            //CallButton.Layer.BorderWidth = 5.0f;
        }