public void Test_phonewordFailMethod() { Console.WriteLine("test2 phoneword translator"); string output = PhonewordTranslator.ToNumber("BCDEFG"); Assert.AreEqual("223335", output); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); // Set our view from the "main" layout resource SetContentView(Resource.Layout.activity_main); var phoneNumberText = FindViewById <EditText>(Resource.Id.PhoneNumberText); var translatedPhoneWord = FindViewById <TextView>(Resource.Id.TranslatedPhoneword); var translateButton = FindViewById <Button>(Resource.Id.TranslateButton); var translationHistoryButton = FindViewById <Button>(Resource.Id.TranslationHistoryButton); translateButton.Click += (sender, e) => { string translatedNumber = PhonewordTranslator.ToNumber(phoneNumberText.Text); if (string.IsNullOrWhiteSpace(translatedNumber)) { translatedPhoneWord.Text = string.Empty; } else { translatedPhoneWord.Text = translatedNumber; _phoneNumbers.Add(translatedNumber); translationHistoryButton.Enabled = true; } }; translationHistoryButton.Click += (sender, e) => { var intent = new Intent(this, typeof(TranslationHistoryActivity)); intent.PutStringArrayListExtra("phone_numbers", _phoneNumbers); StartActivity(intent); }; }
public void Test_phonewordPassMethod() { Console.WriteLine("test1 phoneword translator"); string output = PhonewordTranslator.ToNumber("ABCDEF"); Assert.AreEqual("222333", output); }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); // Get our UI controls from the loaded layout EditText phoneNumberText = FindViewById <EditText>(Resource.Id.PhoneNumberText); TextView translatedPhoneWord = FindViewById <TextView>(Resource.Id.TranslatedPhoneWord); Button translateButton = FindViewById <Button>(Resource.Id.TranslateButton); // Add code to translate number string translatedNumber = string.Empty; translateButton.Click += (sender, e) => { // Translate user's alphanumeric phone number to numeric translatedNumber = PhonewordTranslator.ToNumber(phoneNumberText.Text); if (string.IsNullOrWhiteSpace(translatedNumber)) { translatedPhoneWord.Text = string.Empty; } else { translatedPhoneWord.Text = translatedNumber; } }; }
public override void ViewDidLoad() { base.ViewDidLoad(); TranslateButton.TouchUpInside += (object sender, EventArgs e) => { // Convert the phone number with text to a number // using PhoneTranslator.cs translatedNumber = PhonewordTranslator.ToNumber(PhonewordText.Text); // Dismiss the keyboard if text field was tapped PhonewordText.ResignFirstResponder(); makeInsertCall(); }; CallButton.TouchUpInside += (object sender, EventArgs e) => { // Use URL handler with tel: prefix to invoke Apple's Phone app... 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); } }; HistoryButton.TouchUpInside += (object sender, EventArgs e) => { }; }
public void TestXamarinPhoneNumber() { var originalNumber = "1-855-XAMARIN"; var expectedValue = "1-855-9262746"; var translatedNumber = PhonewordTranslator.ToNumber(originalNumber); Assert.AreEqual(expectedValue, translatedNumber, "The expected phone numbers are not equivilant"); }
public void OnTranslate(object sender, EventArgs e) { TranslatedNumber = PhonewordTranslator.ToNumber(phoneNumberText.Text); if (!string.IsNullOrWhiteSpace(TranslatedNumber)) { callButton.IsEnabled = true; callButton.Text = "Call " + TranslatedNumber; } else { callButton.IsEnabled = false; callButton.Text = "Call"; } }
void OnTranslate(object sender, EventArgs e) { translatedNumber = PhonewordTranslator.ToNumber(displayLabel.Text); if (!string.IsNullOrWhiteSpace(translatedNumber)) { callButton.IsEnabled = true; callButton.Text = " " + translatedNumber; } else { callButton.IsEnabled = false; callButton.Text = "拨号"; } }
protected override void OnCreate(Bundle bundle) { base.OnCreate(bundle); // Set our view from the "main" layout resource SetContentView(Resource.Layout.Main); EditText phoneNumberText = FindViewById <EditText>(Resource.Id.PhoneNumberText); Button translateButton = FindViewById <Button>(Resource.Id.TranslateButton); Button callButton = FindViewById <Button>(Resource.Id.CallButton); // Disable the "Call" button callButton.Enabled = false; // Add code to translate number string translatedNumber = string.Empty; translateButton.Click += (object sender, EventArgs e) => { // Translate user's alphanumeric phone number to numeric translatedNumber = PhonewordTranslator.ToNumber(phoneNumberText.Text); if (String.IsNullOrWhiteSpace(translatedNumber)) { callButton.Text = "Call"; callButton.Enabled = false; } else { callButton.Text = "Call " + translatedNumber; callButton.Enabled = true; } }; callButton.Click += (object sender, EventArgs e) => { // On "Call" button click, try to dial phone number. var callDialog = new AlertDialog.Builder(this); callDialog.SetMessage(string.Format("Call {0} ?", translatedNumber)); callDialog.SetNeutralButton("Call", delegate { // Create intent to dial phone var callIntent = new Intent(Intent.ActionCall); callIntent.SetData(Android.Net.Uri.Parse("tel:" + translatedNumber)); StartActivity(callIntent); }); callDialog.SetNegativeButton("Cancel", delegate { }); // Show the alert dialog to the user and wait for response. callDialog.Show(); }; }
private void TranslateButtonOnClicked(object sender, EventArgs eventArgs) { string translatedText = PhonewordTranslator.ToNumber(userEntry.Text); bool success = !string.IsNullOrEmpty(translatedText); callButton.IsEnabled = success; if (success) { userEntry.Text = translatedText; callButton.Text = "Call " + translatedText; } else { callButton.Text = "Call"; } }
private void OnTranslate(object sender, EventArgs e) { string enteredNumber = phoneNumberText.Text; translatedNumber = PhonewordTranslator.ToNumber(enteredNumber); if (!string.IsNullOrEmpty(translatedNumber)) { callButton.IsEnabled = true; callButton.Text = "Call " + translatedNumber; } else { callButton.IsEnabled = false; callButton.Text = "Call"; } }
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) => { // Convert the phone number with text to a number // using PhoneTranslator.cs translatedNumber = PhonewordTranslator.ToNumber( PhoneNumberText.Text); // Dismiss the keyboard if text field was tapped 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) => { 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); } }; }
private async void TranslateButton_Click(object sender, System.EventArgs e) { TranslatedNumber = PhonewordTranslator.ToNumber(phoneNumberText.Text); if (string.IsNullOrWhiteSpace(TranslatedNumber)) { callButton.Text = "Call"; callButton.Enabled = false; } else { callButton.Text = "Call " + TranslatedNumber; callButton.Enabled = true; TranslationRecord record = new TranslationRecord(); record.character = phoneNumberText.Text; record.number = TranslatedNumber; var response = await apiService.AddTranslation(record); System.Diagnostics.Debug.Write(response.affectedRows); } }
void Translation(object sender, EventArgs e) { var result = PhonewordTranslator.ToNumber(InputNumber.Text); InputNumber.Text = result; }