Exemple #1
0
        /// <summary>
        /// Default ctor
        /// </summary>
        private CultureInfo(Locale locale, bool isInvariant = false)
        {
            this._locale = locale;
            _numberFormat = new LazyAndWeak<NumberFormatInfo>(()=>new NumberFormatInfo(locale));
            _dateTimeFormat = new LazyAndWeak<DateTimeFormatInfo>(() => new DateTimeFormatInfo(locale, isInvariant));

        }
Exemple #2
0
		/// <exception cref="Java.IO.UnsupportedEncodingException"></exception>
		public virtual void Test1()
		{
			NeoDatis.Odb.ODB odb = null;
			string baseName = GetBaseName();
			Java.Util.Locale defaultLocale = Java.Util.Locale.GetDefault();
			try
			{
				odb = Open(baseName);
				NeoDatis.Odb.OdbConfiguration.SetLatinDatabaseCharacterEncoding();
				Java.Util.Locale brLocale = new Java.Util.Locale("pt", "BR");
				Java.Util.Locale.SetDefault(brLocale);
				NeoDatis.Odb.Test.VO.Attribute.TestClass tc = new NeoDatis.Odb.Test.VO.Attribute.TestClass
					();
				tc.SetBigDecimal1(new System.Decimal(5.3));
				Println(tc.GetBigDecimal1().ToString());
				odb.Store(tc);
				odb.Close();
				odb = Open(baseName);
				NeoDatis.Odb.Objects<NeoDatis.Odb.Test.VO.Attribute.TestClass> objects = odb.GetObjects
					(typeof(NeoDatis.Odb.Test.VO.Attribute.TestClass));
				AssertEquals(1, objects.Count);
				AssertEquals(new System.Decimal(5.3), objects.GetFirst().GetBigDecimal1());
			}
			finally
			{
				if (odb != null && !odb.IsClosed())
				{
					odb.Close();
				}
				NeoDatis.Odb.OdbConfiguration.SetDatabaseCharacterEncoding(null);
				Java.Util.Locale.SetDefault(defaultLocale);
			}
		}
	    internal DateTimeFormatInfo(Java.Util.Locale locale, bool isInvariant = false)
	    {
	        _isInvariant = isInvariant;
	        Locale = locale;

            monthDayPattern = "MMMM dd";
            yearMonthPattern = "yyyy MMMM";
	    }
		public void Speak (string text)
		{
			var c = Forms.Context; 
			toSpeak = text;
			if (speaker == null) {
				speaker = new TextToSpeech (c, this);
				var languageIso = "en_GB";
				var locale = new Java.Util.Locale(languageIso);// languageIso is locale string
				speaker.SetLanguage (locale);
			}
			else
			{
				var p = new Dictionary<string,string> ();
				speaker.Speak (toSpeak, QueueMode.Flush, p);
			}
        }
Exemple #5
0
        private void CultureLayout()
        {
            //culture
            TextView culturetxt = new TextView(context);

            culturetxt.LayoutParameters = new FrameLayout.LayoutParams((int)(totalWidth * 0.33), ViewGroup.LayoutParams.WrapContent, GravityFlags.Center);
            culturetxt.TextSize         = 15;
            culturetxt.Text             = "Culture";
            cultureSpinner = new Spinner(context, SpinnerMode.Dialog);
            cultureSpinner.LayoutParameters = new FrameLayout.LayoutParams((int)(totalWidth * 0.33), ViewGroup.LayoutParams.WrapContent, GravityFlags.Center);
            List <String> cultureList = new List <String>();

            cultureList.Add("United States");
            cultureList.Add("United Kingdom");
            cultureList.Add("Japan");
            cultureList.Add("France");
            cultureList.Add("Italy");
            cultureDataAdapter = new ArrayAdapter <String>
                                     (context, Android.Resource.Layout.SimpleSpinnerItem, cultureList);
            cultureDataAdapter.SetDropDownViewResource
                (Android.Resource.Layout.SimpleSpinnerDropDownItem);
            cultureSpinner.Adapter = cultureDataAdapter;
            cultureSpinner.SetSelection(culturePosition);
            cultureSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                String selectedItem = cultureDataAdapter.GetItem(e.Position);
                culturePosition = e.Position;
                if (selectedItem.Equals("United States"))
                {
                    localinfo = Java.Util.Locale.Us;
                }
                if (selectedItem.Equals("United Kingdom"))
                {
                    localinfo = Java.Util.Locale.Uk;
                }
                if (selectedItem.Equals("Japan"))
                {
                    localinfo = Java.Util.Locale.Japan;
                }
                if (selectedItem.Equals("France"))
                {
                    localinfo = Java.Util.Locale.France;
                }
                if (selectedItem.Equals("Italy"))
                {
                    localinfo = Java.Util.Locale.Italy;
                }

                ApplyChanges();
            };

            LinearLayout cultureLayout = new LinearLayout(context);

            cultureLayout.Orientation = Android.Widget.Orientation.Horizontal;
            cultureLayout.AddView(culturetxt);
            cultureLayout.AddView(cultureSpinner);

            proprtyOptionsLayout.AddView(cultureLayout);

            //spaceText
            TextView spaceText2 = new TextView(context);

            spaceText2.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, (int)(totalHeight * 0.067), GravityFlags.Center);
            proprtyOptionsLayout.AddView(spaceText2);
        }
Exemple #6
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            if (prefs.GetString("locale", "") == "")
            {
                editor.PutString("locale", "en");
                editor.Apply();
            }
            string loc    = prefs.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;
            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_workplace);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            busyTimes = new List <TimeSpan>()
            {
                new TimeSpan(9, 0, 0),
                new TimeSpan(9, 30, 0),
                new TimeSpan(10, 0, 0),
                new TimeSpan(10, 30, 0),
                new TimeSpan(11, 0, 0),
                new TimeSpan(11, 30, 0),
                new TimeSpan(12, 0, 0),
                new TimeSpan(12, 30, 0),
                new TimeSpan(13, 0, 0),
                new TimeSpan(13, 30, 0),
                new TimeSpan(14, 0, 0),
                new TimeSpan(14, 30, 0),
                new TimeSpan(15, 0, 0),
                new TimeSpan(15, 30, 0),
                new TimeSpan(16, 0, 0),
                new TimeSpan(16, 30, 0),
                new TimeSpan(17, 0, 0),
                new TimeSpan(17, 30, 0),
                new TimeSpan(18, 0, 0),
                new TimeSpan(18, 30, 0),
                new TimeSpan(19, 0, 0),
                new TimeSpan(19, 30, 0),
                new TimeSpan(20, 0, 0),
                new TimeSpan(20, 30, 0)
            };
            orderedTimes = new List <TimeSpan>();

            selectedDateTextView = FindViewById <TextView>(Resource.Id.sel_date_text_view);

            Button selectDateButton = FindViewById <Button>(Resource.Id.sel_date_button);
            selectDateButton.Click += SelectDateButtonOnClick;
            timeTextViews           = new List <Button>();
            workplaceId             = int.Parse(prefs.GetString("workplaceId", ""));
            apiClient = new APIClient();
            workplace = await apiClient.GetWorkplaceByIdAsync(workplaceId);

            building = await apiClient.GetBuildingByIdAsync((int)workplace.BuildingId);

            landlord = await apiClient.GetLandlordByIdAsync((int)building.LandlordId);

            client = await apiClient.GetClientByIdAsync(1);

            TextView workplaceNumberTextView = FindViewById <TextView>(Resource.Id.workplace_number_text_view);
            workplaceNumberTextView.Text += workplaceId.ToString();

            TextView addressTextView = FindViewById <TextView>(Resource.Id.address_text_view);
            addressTextView.Text += building.Country + ", " + building.City + ", " + building.Street
                                    + ", " + building.House + ", " + building.Flat.ToString();

            TextView landlordTextView = FindViewById <TextView>(Resource.Id.landloed_text_view);
            landlordTextView.Text += landlord.FirstName + ", " + landlord.LastName + ", " + landlord.Phone.ToString()
                                     + ", " + landlord.Email;

            workplaceOrders = await apiClient.GetWorkplaceOrdersListAsync();

            workplaceEquipments = await apiClient.GetWorkplaceEquipmentsListAsync();

            List <WorkplaceEquipment> we = workplaceEquipments.Where(x => x.WorkplaceId == workplaceId).ToList();
            string equipmentString       = "";
            foreach (WorkplaceEquipment equipment in we)
            {
                Equipment eq = await apiClient.GetEquipmentByIdAsync((int)(equipment.EquipmentId));

                equipmentString += eq.Name;
            }
            TextView eqTextView = FindViewById <TextView>(Resource.Id.equipment_text_view);
            eqTextView.Text += equipmentString;
        }
Exemple #7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.home);
            AdView mAdView   = FindViewById <AdView>(Resource.Id.adView1);
            var    adRequest = new AdRequest.Builder().Build();

            // Start loading the ad.
            mAdView.LoadAd(adRequest);
            b1         = FindViewById <Button>(Resource.Id.b1);
            b2         = FindViewById <Button>(Resource.Id.b2);
            b3         = FindViewById <Button>(Resource.Id.b3);
            b4         = FindViewById <Button>(Resource.Id.b4);
            b5         = FindViewById <Button>(Resource.Id.b5);
            b6         = FindViewById <Button>(Resource.Id.b6);
            b7         = FindViewById <Button>(Resource.Id.b7);
            b8         = FindViewById <Button>(Resource.Id.b8);
            b9         = FindViewById <Button>(Resource.Id.b9);
            b10        = FindViewById <Button>(Resource.Id.b10);
            b11        = FindViewById <Button>(Resource.Id.b11);
            b12        = FindViewById <Button>(Resource.Id.b12);
            b13        = FindViewById <Button>(Resource.Id.b13);
            b14        = FindViewById <Button>(Resource.Id.b14);
            b15        = FindViewById <Button>(Resource.Id.b15);
            b16        = FindViewById <Button>(Resource.Id.b16);
            b17        = FindViewById <Button>(Resource.Id.b17);
            b18        = FindViewById <Button>(Resource.Id.b18);
            b19        = FindViewById <Button>(Resource.Id.b19);
            b20        = FindViewById <Button>(Resource.Id.b20);
            b21        = FindViewById <Button>(Resource.Id.b21);
            b22        = FindViewById <Button>(Resource.Id.b22);
            b23        = FindViewById <Button>(Resource.Id.b23);
            b24        = FindViewById <Button>(Resource.Id.b24);
            b25        = FindViewById <Button>(Resource.Id.b25);
            b26        = FindViewById <Button>(Resource.Id.b26);
            b27        = FindViewById <Button>(Resource.Id.b27);
            b28        = FindViewById <Button>(Resource.Id.b28);
            b29        = FindViewById <Button>(Resource.Id.b29);
            b30        = FindViewById <Button>(Resource.Id.b30);
            b31        = FindViewById <Button>(Resource.Id.b31);
            b32        = FindViewById <Button>(Resource.Id.b32);
            b33        = FindViewById <Button>(Resource.Id.b33);
            b34        = FindViewById <Button>(Resource.Id.b34);
            b35        = FindViewById <Button>(Resource.Id.b35);
            b36        = FindViewById <Button>(Resource.Id.b36);
            b37        = FindViewById <Button>(Resource.Id.b37);
            b38        = FindViewById <Button>(Resource.Id.b38);
            b39        = FindViewById <Button>(Resource.Id.b39);
            b40        = FindViewById <Button>(Resource.Id.b40);
            b41        = FindViewById <Button>(Resource.Id.b41);
            b42        = FindViewById <Button>(Resource.Id.b42);
            b43        = FindViewById <Button>(Resource.Id.b43);
            b44        = FindViewById <Button>(Resource.Id.b44);
            b45        = FindViewById <Button>(Resource.Id.b45);
            b46        = FindViewById <Button>(Resource.Id.b46);
            b47        = FindViewById <Button>(Resource.Id.b47);
            b48        = FindViewById <Button>(Resource.Id.b48);
            b49        = FindViewById <Button>(Resource.Id.b49);
            b50        = FindViewById <Button>(Resource.Id.b50);
            b1.Click  += B1_Click;
            b2.Click  += B2_Click;
            b3.Click  += B3_Click;
            b4.Click  += B4_Click;
            b5.Click  += B5_Click;
            b6.Click  += B6_Click;
            b7.Click  += B7_Click;
            b8.Click  += B8_Click;
            b9.Click  += B9_Click;
            b10.Click += B10_Click;
            b11.Click += B11_Click;
            b12.Click += B12_Click;
            b13.Click += B13_Click;
            b14.Click += B14_Click;
            b15.Click += B15_Click;
            b16.Click += B16_Click;
            b17.Click += B17_Click;
            b18.Click += B18_Click;
            b19.Click += B19_Click;
            b20.Click += B20_Click;
            b21.Click += B21_Click;
            b22.Click += B22_Click;
            b23.Click += B23_Click;
            b24.Click += B24_Click;
            b25.Click += B25_Click;
            b26.Click += B26_Click;
            b27.Click += B27_Click;
            b28.Click += B28_Click;
            b29.Click += B29_Click;
            b30.Click += B30_Click;
            b31.Click += B31_Click;
            b32.Click += B32_Click;
            b33.Click += B33_Click;
            b34.Click += B34_Click;
            b35.Click += B35_Click;
            b36.Click += B36_Click;
            b37.Click += B37_Click;
            b38.Click += B38_Click;
            b39.Click += B39_Click;
            b40.Click += B40_Click;
            b41.Click += B41_Click;
            b42.Click += B42_Click;
            b43.Click += B43_Click;
            b44.Click += B44_Click;
            b45.Click += B45_Click;
            b46.Click += B46_Click;
            b47.Click += B47_Click;
            b48.Click += B48_Click;
            b49.Click += B49_Click;
            b50.Click += B50_Click;


            textToSpeech = new TextToSpeech(this, null, "com.google.android.tts");


            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);

            // set the speed and pitch
            textToSpeech.SetPitch(1.00f);
            textToSpeech.SetSpeechRate(.8f);
        }
Exemple #8
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs1  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor1 = prefs1.Edit();

            if (prefs1.GetString("locale", "") == "")
            {
                editor1.PutString("locale", "en");
                editor1.Apply();
            }
            string loc    = prefs1.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;
            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_workplace_parameters);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            APIClient apiClient = new APIClient();
            ObservableCollection <Equipment> equipmentList = await apiClient.GetEquipmentsListAsync();

            ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            if (prefs.GetString("searchingViewModel", "") == "")
            {
                searchingViewModel                = new SearchingViewModel();
                searchingViewModel.X              = 33;
                searchingViewModel.Y              = 33;
                searchingViewModel.Radius         = 500;
                searchingViewModel.WantedCost     = 500;
                searchingViewModel.SearchingModel = new ObservableCollection <SearchingModel>();
                for (int i = 0; i < equipmentList.Count; i++)
                {
                    SearchingModel searchingModel = new SearchingModel();
                    searchingModel.EquipmentId = equipmentList[i].Id;
                    searchingModel.Importancy  = 0;
                    searchingViewModel.SearchingModel.Add(searchingModel);
                }
            }
            else
            {
                searchingViewModel            = JsonConvert.DeserializeObject <SearchingViewModel>(prefs.GetString("searchingViewModel", ""));
                searchingViewModel.Radius     = (searchingViewModel.Radius == null) ? 500 : searchingViewModel.Radius;
                searchingViewModel.WantedCost = (searchingViewModel.WantedCost == null) ? 500 : searchingViewModel.WantedCost;
            }

            radiusEditText      = FindViewById <EditText>(Resource.Id.radius_edit_text);
            radiusEditText.Text = searchingViewModel.Radius.ToString();
            costEditText        = FindViewById <EditText>(Resource.Id.cost_edit_text);
            costEditText.Text   = searchingViewModel.WantedCost.ToString();

            LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.worplace_p);
            LinearLayout.LayoutParams layoutParamsLayout = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            layoutParamsLayout.Gravity = GravityFlags.Left;

            for (int i = 0; i < equipmentList.Count; i++)
            {
                LinearLayout newLayout = new LinearLayout(this)
                {
                    LayoutParameters = layoutParamsLayout,
                    Orientation      = Orientation.Horizontal
                };
                TextView textView = new TextView(this)
                {
                    Text = equipmentList[i].Name
                };
                textView.SetTextAppearance(Resource.Style.TextAppearance_AppCompat_Medium);
                RatingBar ratingBar = new RatingBar(this)
                {
                    NumStars         = 5,
                    Rating           = (int)(searchingViewModel.SearchingModel[i].Importancy * 5),
                    LayoutParameters = layoutParams,
                    StepSize         = 1,
                    Id = i
                };

                TextView cross = new TextView(this)
                {
                    LayoutParameters = layoutParams,
                    Id = i + 100
                };
                cross.SetCompoundDrawablesWithIntrinsicBounds(0, 0, Resource.Mipmap.cancel, 0);

                linearLayout.AddView(textView);
                newLayout.AddView(ratingBar);
                newLayout.AddView(cross);

                linearLayout.AddView(newLayout);

                ratingBar.RatingBarChange += (o, e) => {
                    Toast.MakeText(this, "New Rating: " + ratingBar.Rating.ToString(), ToastLength.Short).Show();
                    searchingViewModel.SearchingModel[ratingBar.Id].Importancy = Math.Round(ratingBar.Rating * 0.2, 2);
                };
                cross.Click += (o, e) => {
                    searchingViewModel.SearchingModel[ratingBar.Id].Importancy = 0;
                    ratingBar.FindViewById <RatingBar>(cross.Id - 100).Rating  = 0;
                };
            }
        }
Exemple #9
0
        private async void Signupbtn_Click(object sender, EventArgs e)
        {
            string             nametext, mobiletext, emailtext, passtext, cnfpasstext;
            InputMethodManager inputManager = (InputMethodManager)GetSystemService(InputMethodService);

            inputManager.HideSoftInputFromWindow(CurrentFocus.WindowToken, 0);
            nametext    = name.Text;
            mobiletext  = mobile.Text;
            emailtext   = email.Text;
            passtext    = password.Text;
            cnfpasstext = conpass.Text;
            if (!checkEmpty(nametext, "Name"))
            {
                return;
            }
            else if (!checkEmpty(mobiletext, "Phone number"))
            {
                return;
            }
            else if (!checkEmpty(emailtext, "Email"))
            {
                return;
            }
            else if (!checkEmpty(passtext, "Password"))
            {
                return;
            }
            else if (!checkEmpty(cnfpasstext, "Confirm Password"))
            {
                return;
            }
            else
            {
                if (isNameVaid(nametext) && isMobileValid(mobiletext) && isEmailValid(emailtext) && areTermsAccepted() && isPassValid(passtext) && checkPassValidity(passtext, cnfpasstext))
                {
                    mLoadingDialog.Show();
                    CabsAPI        api      = new CabsAPI();
                    SignupResponse response = await api.RegisterUser(nametext, emailtext, mobiletext, passtext);

                    if (response.Code == Utils.ResponseCode.SUCCESS)
                    {
                        mLoadingDialog.Dismiss();
                        mEditor.PutString("email", emailtext);
                        mEditor.PutString("mobile", mobiletext);
                        mEditor.PutString("name", nametext);
                        mEditor.PutString("token", response.Token);
                        mEditor.PutBoolean("isLoggedIn", true);
                        mEditor.Apply();
                        mTextToSpeech = new TextToSpeech(this, this, "com.google.android.tts");
                        //  new TextToSpeech(con, this, "com.google.android.tts");
                        lang = Java.Util.Locale.Default;
                        //setting language , pitch and speed rate to the voice
                        mTextToSpeech.SetLanguage(lang);
                        mTextToSpeech.SetPitch(1f);
                        mTextToSpeech.SetSpeechRate(1f);
                        mContext = signupbtn.Context;
                        mTextToSpeech.Speak(mSucLog, QueueMode.Flush, null, null);
                        StartActivity(new Intent(this, typeof(NavigationActivity)));

                        Finish();
                    }
                    else if (response.Code == Utils.ResponseCode.MYSQL_DUPLICATES)
                    {
                        mLoadingDialog.Dismiss();
                        Toast.MakeText(this, "User with same number is already present", ToastLength.Short).Show();
                        mobile.Text = "";
                    }
                    else
                    {
                        mLoadingDialog.Dismiss();
                        Toast.MakeText(this, "Server Error Try Again!", ToastLength.Short).Show();
                    }
                }
            }
        }
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);

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

            // we need to register the onscreen gadgets we're interested in

            var btnSayIt      = FindViewById <Button>(Resource.Id.btnSpeak);
            var editWhatToSay = FindViewById <EditText>(Resource.Id.editSpeech);
            var spinLanguages = FindViewById <Spinner>(Resource.Id.spinLanguage);
            var txtSpeedVal   = FindViewById <TextView>(Resource.Id.textSpeed);
            var txtPitchVal   = FindViewById <TextView>(Resource.Id.textPitch);
            var seekSpeed     = FindViewById <SeekBar>(Resource.Id.seekSpeed);
            var seekPitch     = FindViewById <SeekBar>(Resource.Id.seekPitch);

            // set up the initial pitch and speed values then the onscreen values
            // the pitch and rate both go from 0f to 1f, however if you have a seek bar with a max of 1, you get a single step
            // therefore, a simpler option is to have the slider go from 0 to 255 and divide the position of the slider by 255 to get
            // the float
            seekSpeed.Progress = seekPitch.Progress = 127;
            txtSpeedVal.Text   = txtPitchVal.Text = "0.5";

            // get the context - easiest way is to obtain it from an on screen gadget
            context = btnSayIt.Context;

            // set up the TextToSpeech object
            // third parameter is the speech engine to use
            textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

            // set up the langauge spinner
            // set the top option to be default
            var langAvailable = new List <string> {
                "Default"
            };

            // our spinner only wants to contain the languages supported by the tts and ignore the rest
            var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();

            foreach (var locale in localesAvailable)
            {
                LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
                switch (res)
                {
                case LanguageAvailableResult.Available:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryVarAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;
                }
            }
            langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();

            var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable);

            spinLanguages.Adapter = adapter;

            // set up the speech to use the default langauge
            // if a language is not available, then the default language is used.
            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);

            // set the speed and pitch
            textToSpeech.SetPitch(.5f);
            textToSpeech.SetSpeechRate(.5f);

            // connect up the events
            btnSayIt.Click += delegate
            {
                // if there is nothing to say, don't say it
                if (!string.IsNullOrEmpty(editWhatToSay.Text))
                {
                    textToSpeech.Speak(editWhatToSay.Text, QueueMode.Flush, null);
                }
            };

            // sliders
            seekPitch.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                textToSpeech.SetPitch(progress);
                txtPitchVal.Text = progress.ToString("F2");
            };
            seekSpeed.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                textToSpeech.SetSpeechRate(progress);
                txtSpeedVal.Text = progress.ToString("F2");
            };

            spinLanguages.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                lang = Java.Util.Locale.GetAvailableLocales().FirstOrDefault(t => t.DisplayLanguage == langAvailable[(int)e.Id]);
                // create intent to check the TTS has this language installed
                var checkTTSIntent = new Intent();
                checkTTSIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
                StartActivityForResult(checkTTSIntent, NeedLang);
            };
        }
Exemple #11
0
        public View GetPropertyWindowLayout(Context context)
        {
            width                      = (context.Resources.DisplayMetrics.WidthPixels) / 2;
            propertylayout             = new LinearLayout(context);
            propertylayout.Orientation = Orientation.Vertical;

            /***********
            **Culture**
            ***********/
            LinearLayout.LayoutParams cultureLayoutParams = new LinearLayout.LayoutParams(width * 2, 5);
            cultureLayoutParams.SetMargins(0, 20, 0, 0);

            //Culture Text
            TextView culturetxt = new TextView(context);

            culturetxt.TextSize = 20;
            culturetxt.Text     = "Culture";

            //CultureList
            List <String> cultureList = new List <String>();

            cultureList.Add("United States");
            cultureList.Add("United Kingdom");
            cultureList.Add("Japan");
            cultureList.Add("France");
            cultureList.Add("Italy");
            cultureDataAdapter = new ArrayAdapter <String>
                                     (context, Android.Resource.Layout.SimpleSpinnerItem, cultureList);
            cultureDataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            //CultureSpinner
            cultureSpinner         = new Spinner(context, SpinnerMode.Dialog);
            cultureSpinner.Adapter = cultureDataAdapter;

            //CultureSpinner ItemSelected Listener
            cultureSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                String selectedItem = cultureDataAdapter.GetItem(e.Position);
                if (selectedItem.Equals("United States"))
                {
                    localinfo = Java.Util.Locale.Us;
                }
                if (selectedItem.Equals("United Kingdom"))
                {
                    localinfo = Java.Util.Locale.Uk;
                }
                if (selectedItem.Equals("Japan"))
                {
                    localinfo = Java.Util.Locale.Japan;
                }
                if (selectedItem.Equals("France"))
                {
                    localinfo = Java.Util.Locale.France;
                }
                if (selectedItem.Equals("Italy"))
                {
                    localinfo = Java.Util.Locale.Italy;
                }
            };
            propertylayout.AddView(culturetxt);
            propertylayout.AddView(cultureSpinner);

            //CultureSeparate
            SeparatorView cultureSeparate = new SeparatorView(context, width * 2);

            cultureSeparate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            // propertylayout.AddView(cultureSeparate, cultureLayoutParams);

            /*************
            **AllowNull**
            *************/
            TextView allowNullText = new TextView(context);

            allowNullText.Text     = "Allow Null";
            allowNullText.Gravity  = GravityFlags.Center;
            allowNullText.TextSize = 20;

            //AllowNullCheckBox
            Switch allowNullCheckBox = new Switch(context);

            allowNullCheckBox.Checked        = true;
            allowNullCheckBox.CheckedChange += (object send, CompoundButton.CheckedChangeEventArgs eve) => {
                if (!eve.IsChecked)
                {
                    allownull = false;
                }
                else
                {
                    allownull = true;
                }
            };
            LinearLayout.LayoutParams allowNullCheckBoxLayoutParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            allowNullCheckBoxLayoutParams.SetMargins(0, 10, 0, 0);
            LinearLayout.LayoutParams allowNullTextLayoutParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WrapContent, 70);
            allowNullTextLayoutParams.SetMargins(0, 10, 0, 0);

            TextView textSpacing = new TextView(context);

            propertylayout.AddView(textSpacing);

            //AllowNullLayout
            allowNullLayout = new LinearLayout(context);
            allowNullLayout.AddView(allowNullText);
            allowNullLayout.AddView(allowNullCheckBox, allowNullCheckBoxLayoutParams);
            allowNullLayout.Orientation = Orientation.Horizontal;
            propertylayout.AddView(allowNullLayout);

            /*************
            **AllowDefaultDecimalDigits**
            *************/

            TextView allowDefaultDecimalDigitsText = new TextView(context);

            allowDefaultDecimalDigitsText.Text     = "Allow Default Decimal Digits";
            allowDefaultDecimalDigitsText.Gravity  = GravityFlags.Center;
            allowDefaultDecimalDigitsText.TextSize = 20;

            //AllowDefaultDecimalDigits checkbox
            Switch allowDefaultDecimalDigitsCheckBox = new Switch(context);

            allowDefaultDecimalDigitsCheckBox.Checked        = true;
            allowDefaultDecimalDigitsCheckBox.CheckedChange += (object send, CompoundButton.CheckedChangeEventArgs eve) => {
                if (!eve.IsChecked)
                {
                    allowDefaultDecimalDigits = false;
                }
                else
                {
                    allowDefaultDecimalDigits = true;
                }
            };

            LinearLayout.LayoutParams allowDefaultDecimalDigitsTextCheckBoxLayoutParams = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            allowNullCheckBoxLayoutParams.SetMargins(0, 10, 0, 0);

            //AllowDefaultDecimalDigits layout
            allowDefaultDecimalDigitsLayout = new LinearLayout(context);
            allowDefaultDecimalDigitsLayout.AddView(allowDefaultDecimalDigitsText);
            allowDefaultDecimalDigitsLayout.AddView(allowDefaultDecimalDigitsCheckBox, allowDefaultDecimalDigitsTextCheckBoxLayoutParams);
            allowDefaultDecimalDigitsLayout.Orientation = Orientation.Horizontal;
            propertylayout.AddView(allowDefaultDecimalDigitsLayout);

            TextView textSpacing1 = new TextView(context);

            propertylayout.AddView(textSpacing1);
            //AllowNullSeparate
            SeparatorView allowNullSeparate = new SeparatorView(context, width * 2);

            allowNullSeparate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            LinearLayout.LayoutParams allowNullLayoutParams = new LinearLayout.LayoutParams(width * 2, 5);
            allowNullLayoutParams.SetMargins(0, 20, 15, 0);
            //    propertylayout.AddView(allowNullSeparate, allowNullLayoutParams);
            propertylayout.SetPadding(5, 0, 5, 0);

            return(propertylayout);
        }
		//Java.Lang.Object.Locale localinfo;
		public override View GetSampleContent (Context con)
		{
			Context localcontext = con;
			int width = con.Resources.DisplayMetrics.WidthPixels -40;
			FrameLayout frameLayout = new FrameLayout(con);
			FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, GravityFlags.FillVertical);
			frameLayout.LayoutParameters = layoutParams;
			LinearLayout layout=new LinearLayout(con);
			layout.LayoutParameters=new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
			layout.SetGravity(GravityFlags.FillVertical);
			layout.Orientation=Orientation.Vertical;
			TextView dummy0 = new TextView(con);
			dummy0.Text="Simple Interest Calculator";
			dummy0.Gravity=GravityFlags.Center;
			dummy0.TextSize=24;
			layout.AddView(dummy0);
			TextView dummy7 = new TextView(con);
			layout.AddView(dummy7);
			TextView dummy = new TextView(con);
			dummy.Text="The formula for finding simple interest is:";
			dummy.TextSize=18;
			layout.AddView(dummy);


			layout.FocusableInTouchMode=true;
			SpannableStringBuilder builder = new SpannableStringBuilder();
			TextView dummy1 = new TextView(con);
			String str= "Interest";
			SpannableString strSpannable= new SpannableString(str);
			strSpannable.SetSpan(new ForegroundColorSpan(Color.ParseColor("#66BB6A")), 0, str.Length, 0);
			builder.Append(strSpannable);
			builder.Append(" = Principal * Rate * Time");
			dummy1.SetText(builder, TextView.BufferType.Spannable);
			dummy1.TextSize=18;
			layout.AddView(dummy1);

			TextView dummy8 = new TextView(con);
			layout.AddView(dummy8);

			/*
        Principal amount Stack
       */

			LinearLayout principalStack = new LinearLayout(con);

			TextView txtPricipal = new TextView(con);
			txtPricipal.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			txtPricipal.Text="Principal";

			principalamount =new SfNumericTextBox(con);
			principalamount.FormatString="C";
			principalamount.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			principalamount.Value=1000;
			principalamount.AllowNull = true;
			principalamount.Watermark = "Principal Amount";
			principalamount.MaximumNumberDecimalDigits=2;
			var culture = new Java.Util.Locale("en","US");

			principalamount.CultureInfo = culture;
			principalamount.ValueChangeMode=ValueChangeMode.OnKeyFocus;
			principalStack.Orientation = Orientation.Horizontal;
			principalStack.AddView(txtPricipal);
			principalStack.AddView(principalamount);

			layout.AddView(principalStack);

			TextView dummy3 = new TextView(con);
			layout.AddView(dummy3);

			/*
        Interest Input Box
        */

			LinearLayout InterestcalStack = new LinearLayout(con);

			TextView txtInterest = new TextView(con);
			txtInterest.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			txtInterest.Text="Interest Rate";
			Interestvalue =new SfNumericTextBox(con);
			Interestvalue.FormatString="P"; 
			Interestvalue.PercentDisplayMode=PercentDisplayMode.Compute;
			Interestvalue.MaximumNumberDecimalDigits=2;
			Interestvalue.ValueChangeMode=ValueChangeMode.OnKeyFocus;
			Interestvalue.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			Interestvalue.Value=0.1f;
			Interestvalue.Watermark = "Rate of Interest";
			Interestvalue.AllowNull = true;
			Interestvalue.CultureInfo = culture;
			InterestcalStack.Orientation=Orientation.Horizontal;
			InterestcalStack.AddView(txtInterest);
			InterestcalStack.AddView(Interestvalue);


			layout.AddView(InterestcalStack);

			TextView dummy2 = new TextView(con);
			layout.AddView(dummy2);



			/*
          Period Input TextBox
         */
			LinearLayout periodStack = new LinearLayout(con);

			TextView period = new TextView(con);
			period.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			period.Text="Term";

			periodValue =new SfNumericTextBox(con);
			periodValue.FormatString=" years";
			periodValue.MaximumNumberDecimalDigits=0;
			periodValue.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			periodValue.Value=20;
			periodValue.Watermark = "Period (in years)";
			periodValue.ValueChangeMode=ValueChangeMode.OnKeyFocus;
			periodValue.CultureInfo = culture;
			periodValue.AllowNull = true;

			periodStack.Orientation=Orientation.Horizontal;

			periodStack.AddView(period);
			periodStack.AddView(periodValue);

			layout.AddView(periodStack);



			/*
        OutPut values
         */

			LinearLayout outputStack = new LinearLayout(con);

			TextView outputtxt = new TextView(con);
			outputtxt.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			outputtxt.Text="Interest";
			outputtxt.SetTextColor(Color.ParseColor("#66BB6A"));

			OutputNumbertxtBox =new SfNumericTextBox(con);
			OutputNumbertxtBox.FormatString="c";
			OutputNumbertxtBox.MaximumNumberDecimalDigits=0;
			OutputNumbertxtBox.AllowNull=true;
			OutputNumbertxtBox.CultureInfo = culture;
			OutputNumbertxtBox.Watermark="Enter Values";
			OutputNumbertxtBox.Clickable=false;
			OutputNumbertxtBox.Value = (float)(1000 * 0.1 * 20);
			OutputNumbertxtBox.Enabled=false;
			OutputNumbertxtBox.LayoutParameters=new ViewGroup.LayoutParams(width / 2, 100);
			OutputNumbertxtBox.ValueChangeMode=ValueChangeMode.OnLostFocus;


			outputStack.Orientation=Orientation.Horizontal;

			outputStack.AddView(outputtxt);
			outputStack.AddView(OutputNumbertxtBox);
			layout.AddView(outputStack);

			TextView dummy4 = new TextView(con);
			layout.SetPadding(20, 20, 10, 20);
			layout.AddView(dummy4);

			principalamount.ValueChanged+= (object sender, SfNumericTextBox.ValueChangedEventArgs e) => {
				if(!e.P1.ToString().Equals("")&&!periodValue.Value.ToString().Equals("")&&!Interestvalue.Value.ToString().Equals(""))
					OutputNumbertxtBox.Value=e.P1 * periodValue.Value *  Interestvalue.Value;

			};

			periodValue.ValueChanged+= (object sender, SfNumericTextBox.ValueChangedEventArgs e) => {
				if(!e.P1.ToString().Equals("")&&!principalamount.Value.ToString().Equals("")&&!Interestvalue.Value.ToString().Equals(""))
					OutputNumbertxtBox.Value=e.P1* principalamount.Value*Interestvalue.Value;

			};

			Interestvalue.ValueChanged+= (object sender, SfNumericTextBox.ValueChangedEventArgs e) => {
				if(!e.P1.ToString().Equals("")&&!principalamount.Value.ToString().Equals("")&&!periodValue.Value.ToString().Equals(""))
					OutputNumbertxtBox.Value=e.P1 * principalamount.Value *  periodValue.Value;

			};

			layout.Touch+= (object sender, View.TouchEventArgs e) => {
				if(OutputNumbertxtBox.IsFocused || Interestvalue.IsFocused ||periodValue.IsFocused || principalamount.IsFocused){
					Rect outRect = new Rect();
					OutputNumbertxtBox.GetGlobalVisibleRect(outRect);
					Interestvalue.GetGlobalVisibleRect(outRect);
					periodValue.GetGlobalVisibleRect(outRect);
					principalamount.GetGlobalVisibleRect(outRect);

					if (!outRect.Contains((int)e.Event.RawX, (int)e.Event.RawY)) {
						if(!OutputNumbertxtBox.Value.ToString().Equals(""))
							OutputNumbertxtBox.ClearFocus();
						if(!Interestvalue.Value.ToString().Equals(""))
							Interestvalue.ClearFocus();
						if(!periodValue.Value.ToString().Equals(""))
							periodValue.ClearFocus();
						if(!principalamount.Value.ToString().Equals(""))
							principalamount.ClearFocus();

					}
					hideSoftKeyboard((Activity)localcontext);
				}
			};






			frameLayout.AddView(layout);

			ScrollView scrollView = new ScrollView(con);
			scrollView.AddView(frameLayout);

			return scrollView;
		}
		public override View GetPropertyWindowLayout (Context context)
		{
			/**
		 * Property Window
		 * */
			int width = (context.Resources.DisplayMetrics.WidthPixels) / 2;
			propertylayout = new LinearLayout(context); //= new LinearLayout(context);
			propertylayout.Orientation=Orientation.Vertical;

			LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(
				width * 2, 5);

			layoutParams1.SetMargins(0, 20, 0, 0);

			TextView culturetxt = new TextView(context);
			culturetxt.TextSize=20;
			culturetxt.Text="Culture";

			cultureSpinner = new Spinner(context);
			//cultureSpinner.Gravity=GravityFlags.Left;


			List<String> list = new List<String>();

			list.Add("United States");
			list.Add("United Kingdom");
			list.Add("Japan");
			list.Add("France");
			list.Add("Italy");


			dataAdapter = new ArrayAdapter<String>
				(context, Android.Resource.Layout.SimpleSpinnerItem, list);
			dataAdapter.SetDropDownViewResource
			(Android.Resource.Layout.SimpleSpinnerDropDownItem);

			cultureSpinner.Adapter = dataAdapter;

			cultureSpinner.ItemSelected+= (object sender, AdapterView.ItemSelectedEventArgs e) => {
				String selectedItem = dataAdapter.GetItem(e.Position);

				if (selectedItem.Equals("United States")) {
					localinfo=Java.Util.Locale.Us; //new Java.Util.Locale("en","US");
				}
				if (selectedItem.Equals("United Kingdom")) {
					localinfo=Java.Util.Locale.Uk;
										
				}
				if (selectedItem.Equals("Japan")) {
					localinfo=Java.Util.Locale.Japan;
				}
				if (selectedItem.Equals("France")) {
					localinfo=Java.Util.Locale.France;
				}
				if (selectedItem.Equals("Italy")) {
					localinfo=Java.Util.Locale.Italy;
				}

			};
			propertylayout.AddView(culturetxt);
			propertylayout.AddView(cultureSpinner);

			SeparatorView separate = new SeparatorView(context, width * 2);
			separate.LayoutParameters=new ViewGroup.LayoutParams(width * 2, 5);
			propertylayout.AddView(separate, layoutParams1);

			TextView textView6 = new TextView(context);
			textView6.Text="Allow Null";
			textView6.Gravity=GravityFlags.Center;
			textView6.TextSize=20;

			Switch checkBox = new Switch(context);
			checkBox.Checked=true;
			checkBox.CheckedChange+= (object send, CompoundButton.CheckedChangeEventArgs eve) => {
				if(!eve.IsChecked)
					allownull = false;
				else
					allownull = true;
			};

			LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
			layoutParams3.SetMargins(0, 10, 0, 0);
			LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(
				ViewGroup.LayoutParams.WrapContent, 55);
			layoutParams4.SetMargins(0, 10, 0, 0);
			stackView3 = new LinearLayout(context);
			stackView3.AddView(textView6,layoutParams4);
			stackView3.AddView(checkBox, layoutParams3);
			stackView3.Orientation=Orientation.Horizontal;
			propertylayout.AddView(stackView3);
			SeparatorView separate3 = new SeparatorView(context, width * 2);
			separate3.LayoutParameters=new ViewGroup.LayoutParams(width * 2, 5);
			LinearLayout.LayoutParams layoutParams5 = new LinearLayout.LayoutParams(width * 2, 5);
			layoutParams5.SetMargins(0, 20, 15, 0);
			propertylayout.AddView(separate3, layoutParams5);
			propertylayout.SetPadding(20,20,20,20);
			
			return  propertylayout;
		}
Exemple #14
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            var editText      = FindViewById <EditText>(Resource.Id.editText);
            var helloMyNameIs = FindViewById <Button>(Resource.Id.helloMyNameIs);
            var ralph         = FindViewById <Button>(Resource.Id.ralph);
            var speak         = FindViewById <Button>(Resource.Id.speak);
            var tired         = FindViewById <Button>(Resource.Id.tired);
            var goodbye       = FindViewById <Button>(Resource.Id.goodbye);
            var Hello         = FindViewById <Button>(Resource.Id.niceToMeetYou);
            var thankyou      = FindViewById <Button>(Resource.Id.thankYou);
            var thirsty       = FindViewById <Button>(Resource.Id.thirsty);
            var hungry        = FindViewById <Button>(Resource.Id.hungry);
            var potty         = FindViewById <Button>(Resource.Id.potty);
            var run           = FindViewById <Button>(Resource.Id.runAway);
            var love          = FindViewById <Button>(Resource.Id.iLoveYou);
            var play          = FindViewById <Button>(Resource.Id.wantToPlay);

            context      = speak.Context;
            textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);
            textToSpeech.SetPitch(.80f);
            textToSpeech.SetSpeechRate(1f);

            speak.Click += delegate
            {
                // if there is nothing to say, don't say it
                if (!string.IsNullOrEmpty(editText.Text))
                {
                    textToSpeech.Speak(editText.Text, QueueMode.Flush, null, null);
                }
                //add phrase to list of spoken phrases
                spokenHistoryList.Add(editText.Text);
                //empty editText string
                editText.Text = "";
            };

            Button history = FindViewById <Button>(Resource.Id.history);

            history.Click += delegate
            {
                String[] phraseHistoryArray = spokenHistoryList.ToArray();
                Intent   intent             = new Intent(this, typeof(HistoryActivity));
                intent.PutExtra("history_list", phraseHistoryArray);
                this.StartActivity(intent);
            };


            Button words = FindViewById <Button>(Resource.Id.words);

            words.Click += delegate
            {
                String[] phraseHistoryArray = spokenHistoryList.ToArray();
                Intent   intent             = new Intent(this, typeof(Words));
                intent.PutExtra("history_list", phraseHistoryArray);
                this.StartActivity(intent);
            };

            Button custom = FindViewById <Button>(Resource.Id.custom);

            custom.Click += delegate
            {
                String[] phraseHistoryArray = spokenHistoryList.ToArray();
                Intent   intent             = new Intent(this, typeof(CameraActivity));
                intent.PutExtra("history_list", phraseHistoryArray);
                this.StartActivity(intent);
            };

            love.Click += delegate
            {
                if (!TextUtils.IsEmpty(love.Text))
                {
                    editText.Append(love.Text);
                }
            };

            play.Click += delegate
            {
                if (!TextUtils.IsEmpty(play.Text))
                {
                    editText.Append(play.Text);
                }
            };

            run.Click += delegate
            {
                if (!TextUtils.IsEmpty(run.Text))
                {
                    editText.Append(run.Text);
                }
            };

            helloMyNameIs.Click += delegate
            {
                if (!TextUtils.IsEmpty(helloMyNameIs.Text))
                {
                    editText.Append(helloMyNameIs.Text);
                }
            };


            ralph.Click += delegate
            {
                if (!TextUtils.IsEmpty(ralph.Text))
                {
                    editText.Append(ralph.Text);
                }
            };

            tired.Click += delegate
            {
                if (!TextUtils.IsEmpty(tired.Text))
                {
                    editText.Append(tired.Text);
                }
            };

            goodbye.Click += delegate
            {
                if (!TextUtils.IsEmpty(goodbye.Text))
                {
                    editText.Append(goodbye.Text);
                }
            };

            Hello.Click += delegate
            {
                if (!TextUtils.IsEmpty(Hello.Text))
                {
                    editText.Append(Hello.Text);
                }
            };

            thankyou.Click += delegate
            {
                if (!TextUtils.IsEmpty(thankyou.Text))
                {
                    editText.Append(thankyou.Text);
                }
            };

            thirsty.Click += delegate
            {
                if (!TextUtils.IsEmpty(thirsty.Text))
                {
                    editText.Append(thirsty.Text);
                }
            };


            potty.Click += delegate
            {
                if (!TextUtils.IsEmpty(potty.Text))
                {
                    editText.Append(potty.Text);
                }
            };

            hungry.Click += delegate
            {
                if (!TextUtils.IsEmpty(hungry.Text))
                {
                    editText.Append(hungry.Text);
                }
            };
        }
Exemple #15
0
        public void OnSharedPreferenceChanged(ISharedPreferences sharedPreferences, string key)
        {
            switch (key)
            {
            case ("languages_list_preference"):
            {
                // language changed

                var languagePref = FindPreference("languages_list_preference");
                var newLanguage  = sharedPreferences.GetString(key, "en");

                var languageValues = new List <string>(Resources.GetStringArray(Resource.Array.PreferencesLayout_Languages_List_Values));
                var languageNames  = Resources.GetStringArray(Resource.Array.PreferencesLayout_Languages_List);

                if (languageValues.Contains(newLanguage))
                {
                    ConfigurationService.Instance.Language = newLanguage;
                    languagePref.Summary = languageNames[languageValues.IndexOf(newLanguage)];
                }
                else
                {
                    _log.ErrorFormat("Not valid language '{0}' in preferences dialog. Default value used instead.", newLanguage);
                    languagePref.Summary = languageNames[languageValues.IndexOf("en")];
                }
                _log.InfoFormat("Changed language to '{0}'", newLanguage);

                // set a new language
                var languageIso = ConfigurationService.Instance.Language;
                var locale      = new Java.Util.Locale(languageIso);

                Resources.Configuration.Locale = locale;
                BaseContext.Resources.UpdateConfiguration(Resources.Configuration, BaseContext.Resources.DisplayMetrics);
                RunOnUiThread(() => Toast.MakeText(this, Resources.GetString(Resource.String.PreferencesLayout_PreferenceChange_Information), ToastLength.Short).Show());

                break;
            }

            case ("notification_vibration_preference"):
            {
                // find a particular preference a retrieve value from check box preference or switch preference
                var preference = FindPreference(key);
                var enabled    = (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) ? ((SwitchPreference)preference).Checked : ((CheckBoxPreference)preference).Checked;

                ConfigurationService.Instance.NotificationVibrating = enabled;
                var notificationVibPref = FindPreference("notification_vibration_preference");
                notificationVibPref.Summary = (enabled)
                            ? Resources.GetString(Resource.String.PreferencesLayout_NotificationsCategory_Vibrate_Active)
                            : Resources.GetString(Resource.String.PreferencesLayout_NotificationsCategory_Vibrate_Inactive);

                break;
            }

            case ("notification_sound_preference"):
            {
                // find a particular preference a retrieve value from check box preference or switch preference
                var preference = FindPreference(key);
                var enabled    = (Build.VERSION.SdkInt >= BuildVersionCodes.Honeycomb) ? ((SwitchPreference)preference).Checked : ((CheckBoxPreference)preference).Checked;

                ConfigurationService.Instance.NotificationSound = enabled;
                var notificationSoundPref = FindPreference("notification_sound_preference");
                notificationSoundPref.Summary = (enabled)
                            ? Resources.GetString(Resource.String.PreferencesLayout_NotificationsCategory_Sound_Active)
                            : Resources.GetString(Resource.String.PreferencesLayout_NotificationsCategory_Sound_Inactive);

                break;
            }

            default:
            {
                _log.WarnFormat("Application error. Unknown preference in settings.");

                break;
            }
            }
        }
Exemple #16
0
        private Java.Util.Locale GetLocale()
        {
            Java.Util.Locale locale = Java.Util.Locale.GetAvailableLocales().Where(l => l.Language == LangCode).FirstOrDefault();

            return(locale);
        }
Exemple #17
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs1  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor1 = prefs1.Edit();

            if (prefs1.GetString("locale", "") == "")
            {
                editor1.PutString("locale", "en");
                editor1.Apply();
            }
            string loc    = prefs1.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;

            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_login);


            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            loginSendButton = FindViewById <Button>(Resource.Id.loginSendButton);

            loginSendButton.Click += async(s, arg) =>
            {
                CredentialsViewModel credentialViewModel = new CredentialsViewModel();

                var loginEditText = FindViewById <EditText>(Resource.Id.loginEditText);
                credentialViewModel.UserName = loginEditText.Text;

                var passwordEditText = FindViewById <EditText>(Resource.Id.passwordEditText);
                credentialViewModel.Password = passwordEditText.Text;

                apiClient = new APIClient();
                if (credentialViewModel.Password == "4443345" && credentialViewModel.UserName == "*****@*****.**")
                {
                    string token = await apiClient.Post2Async(credentialViewModel);

                    ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                    ISharedPreferencesEditor editor = prefs.Edit();
                    editor.PutString("auth_token", token);
                    editor.Apply();

                    var intent = new Intent(this, typeof(HomeActivity));
                    StartActivity(intent);
                }
                else if (credentialViewModel.Password == "111111" && credentialViewModel.UserName == "*****@*****.**")
                {
                    string token = await apiClient.Post2Async(credentialViewModel);

                    ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                    ISharedPreferencesEditor editor = prefs.Edit();
                    editor.PutString("auth_token", token);
                    editor.Apply();

                    var intent = new Intent(this, typeof(AdminClientsActivity));
                    StartActivity(intent);
                }
            };
        }
Exemple #18
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.activity_main);
            var btnSayIt      = FindViewById <Button>(Resource.Id.btnSpeak);
            var editWhatToSay = FindViewById <EditText>(Resource.Id.editSpeech);
            var spinLanguages = FindViewById <Spinner>(Resource.Id.spinLanguage);
            var txtSpeedVal   = FindViewById <TextView>(Resource.Id.textSpeed);
            var txtPitchVal   = FindViewById <TextView>(Resource.Id.textPitch);
            var seekSpeed     = FindViewById <SeekBar>(Resource.Id.seekSpeed);
            var seekPitch     = FindViewById <SeekBar>(Resource.Id.seekPitch);

            seekSpeed.Progress = seekPitch.Progress = 127;
            txtSpeedVal.Text   = txtPitchVal.Text = "0.5";
            context            = btnSayIt.Context;
            textToSpeech       = new TextToSpeech(this, this, "com.google.android.tts");
            var langAvailable = new List <string> {
                "Default"
            };
            var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();

            foreach (var locale in localesAvailable)
            {
                LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
                switch (res)
                {
                case LanguageAvailableResult.Available:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryVarAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;
                }
            }

            langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();
            var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable);

            spinLanguages.Adapter = adapter;
            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);
            textToSpeech.SetPitch(0.5f);
            textToSpeech.SetSpeechRate(0.5f);
            btnSayIt.Click += delegate
            {
                if (!string.IsNullOrEmpty(editWhatToSay.Text))
                {
                    textToSpeech.Speak(editWhatToSay.Text, QueueMode.Flush, null);
                }
            };
            seekPitch.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                textToSpeech.SetPitch(progress);
                txtPitchVal.Text = progress.ToString("F2");
            };
            seekSpeed.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
            {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                textToSpeech.SetSpeechRate(progress);
                txtSpeedVal.Text = progress.ToString("F2");
            };
            spinLanguages.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                lang = Java.Util.Locale.GetAvailableLocales().FirstOrDefault(t => t.DisplayLanguage == langAvailable[(int)e.Id]);
                var checkTTSIntent = new Intent();
                checkTTSIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
                StartActivityForResult(checkTTSIntent, NeedLang);
            };
        }
		protected override void OnCreate(Bundle bundle)
		{
			base.OnCreate(bundle);

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

			// we need to register the onscreen gadgets we're interested in

			var btnSayIt = FindViewById<Button>(Resource.Id.btnSpeak);
			var editWhatToSay = FindViewById<EditText>(Resource.Id.editSpeech);
			var spinLanguages = FindViewById<Spinner>(Resource.Id.spinLanguage);
			var txtSpeedVal = FindViewById<TextView>(Resource.Id.textSpeed);
			var txtPitchVal = FindViewById<TextView>(Resource.Id.textPitch);
			var seekSpeed = FindViewById<SeekBar>(Resource.Id.seekSpeed);
			var seekPitch = FindViewById<SeekBar>(Resource.Id.seekPitch);

			// set up the initial pitch and speed values then the onscreen values
			// the pitch and rate both go from 0f to 1f, however if you have a seek bar with a max of 1, you get a single step
			// therefore, a simpler option is to have the slider go from 0 to 255 and divide the position of the slider by 255 to get
			// the float
			seekSpeed.Progress = seekPitch.Progress = 127;
			txtSpeedVal.Text = txtPitchVal.Text = "0.5";

			// get the context - easiest way is to obtain it from an on screen gadget
			context = btnSayIt.Context;

			// set up the TextToSpeech object
			// third parameter is the speech engine to use
			textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

			// set up the langauge spinner
			// set the top option to be default
			var langAvailable = new List<string>{ "Default" };

			// our spinner only wants to contain the languages supported by the tts and ignore the rest
			var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();
			foreach (var locale in localesAvailable)
			{
				LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
				switch (res)
				{
				case LanguageAvailableResult.Available:
					langAvailable.Add(locale.DisplayLanguage);
					break;
				case LanguageAvailableResult.CountryAvailable:
					langAvailable.Add(locale.DisplayLanguage);
					break;
				case LanguageAvailableResult.CountryVarAvailable:
					langAvailable.Add(locale.DisplayLanguage);
					break;
				}

			}
			langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();

			var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable);
			spinLanguages.Adapter = adapter;

			// set up the speech to use the default langauge
			// if a language is not available, then the default language is used.
			lang = Java.Util.Locale.Default;
			textToSpeech.SetLanguage(lang);

			// set the speed and pitch
			textToSpeech.SetPitch(.5f);
			textToSpeech.SetSpeechRate(.5f);

			// connect up the events
			btnSayIt.Click += delegate
			{
				// if there is nothing to say, don't say it
				if (!string.IsNullOrEmpty(editWhatToSay.Text))
					textToSpeech.Speak(editWhatToSay.Text, QueueMode.Flush, null);
			};

			// sliders
			seekPitch.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
			{
				var seek = sender as SeekBar;
				var progress = seek.Progress / 255f;
				textToSpeech.SetPitch(progress);
				txtPitchVal.Text = progress.ToString("F2");
			};
			seekSpeed.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) =>
			{
				var seek = sender as SeekBar;
				var progress = seek.Progress / 255f;
				textToSpeech.SetSpeechRate(progress);
				txtSpeedVal.Text = progress.ToString("F2");
			};

			spinLanguages.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
			{
				lang = Java.Util.Locale.GetAvailableLocales().FirstOrDefault(t => t.DisplayLanguage == langAvailable[(int)e.Id]);
				// create intent to check the TTS has this language installed
				var checkTTSIntent = new Intent();
				checkTTSIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
				StartActivityForResult(checkTTSIntent, NeedLang);
			};
		}
Exemple #20
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            if (prefs.GetString("locale", "") == "")
            {
                editor.PutString("locale", "en");
                editor.Apply();
            }
            string loc    = prefs.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;
            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_settings);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            FindLayoutControls();

            apiClient = new APIClient();
            client    = await apiClient.GetClientByIdAsync(0);

            double recomChairValue = await apiClient.CalculateRecommendedChairHeightAsync((int)client.Id);

            double recomTableValue = await apiClient.CalculateRecommendedTableHeightAsync((int)client.Id);

            ManageLayoutData();
            SetControlsClick();

            Button recomTable = FindViewById <Button>(Resource.Id.rec_table);
            recomTable.Click += async(s, arg) => {
                if (client != null)
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Recommended table height");
                    alert.SetMessage(((int)recomTableValue).ToString());
                    alert.SetPositiveButton("Apply", async(senderAlert, arg1) =>
                    {
                        client.TableHight              = (int)recomTableValue;
                        tableHeightEditText.Text       = client.TableHight.ToString();
                        tableHeightEditText.Visibility = ViewStates.Visible;
                    });

                    alert.SetNegativeButton("Close", (senderAlert, arg1) =>
                    {
                        Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show();
                    });

                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
            };

            Button recomChair = FindViewById <Button>(Resource.Id.rec_chair);
            recomChair.Click += async(s, arg) => {
                if (client != null)
                {
                    AlertDialog.Builder alert = new AlertDialog.Builder(this);
                    alert.SetTitle("Recommended chair height");
                    alert.SetMessage(((int)recomChairValue).ToString());
                    alert.SetPositiveButton("Apply", async(senderAlert, arg1) =>
                    {
                        client.ChairHight              = (int)recomChairValue;
                        chairHeightEditText.Text       = client.ChairHight.ToString();
                        chairHeightEditText.Visibility = ViewStates.Visible;
                    });

                    alert.SetNegativeButton("Close", (senderAlert, arg1) =>
                    {
                        Toast.MakeText(this, "Cancelled!", ToastLength.Short).Show();
                    });

                    Dialog dialog = alert.Create();
                    dialog.Show();
                }
            };
        }
Exemple #21
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);

            //Speak to text
            isRecording = false;
            recButton   = FindViewById <Button> (Resource.Id.btnRecord);
            Log.Info("MainActivity", "recButton 1=" + recButton);
            textBox = FindViewById <TextView> (Resource.Id.textYourText);
            string rec = Android.Content.PM.PackageManager.FeatureMicrophone;

            if (rec != "android.hardware.microphone")
            {
                // no microphone, no recording. Disable the button and output an alert
                var alert = new AlertDialog.Builder(recButton.Context);
                alert.SetTitle("You don't seem to have a microphone to record with");
                alert.SetPositiveButton("OK", (sender, e) => {
                    textBox.Text      = "No microphone present";
                    recButton.Enabled = false;
                    return;
                });

                alert.Show();
            }
            else
            {
                Log.Info("MainActivity", "recButton 2=" + recButton);
                recButton.Click += delegate {
                    // change the text on the button
                    recButton.Text = "End Recording";
                    isRecording    = !isRecording;
                    if (isRecording)
                    {
                        Log.Info("MainActivity", "isRecording=" + isRecording);
                        // create the intent and start the activity
                        var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, RecognizerIntent.LanguageModelFreeForm);

                        // put a message on the modal dialog
                        voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, Application.Context.GetString(Resource.String.messageSpeakNow));

                        // if there is more then 1.5s of silence, consider the speech over
                        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
                        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                        voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                        voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);

                        // you can specify other languages recognised here, for example
                        // voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.German);
                        // if you wish it to recognise the default Locale language and German
                        // if you do use another locale, regional dialects may not be recognised very well

                        voiceIntent.PutExtra(RecognizerIntent.ExtraLanguage, Java.Util.Locale.Default);
                        StartActivityForResult(voiceIntent, VOICE);
                    }
                };
            }

            //Text to speak
            var btnSayIt      = FindViewById <Button> (Resource.Id.btnSpeak);
            var editWhatToSay = FindViewById <EditText> (Resource.Id.editSpeech);
            var spinLanguages = FindViewById <Spinner> (Resource.Id.spinLanguage);
            var txtSpeedVal   = FindViewById <TextView> (Resource.Id.textSpeed);
            var txtPitchVal   = FindViewById <TextView> (Resource.Id.textPitch);
            var seekSpeed     = FindViewById <SeekBar> (Resource.Id.seekSpeed);
            var seekPitch     = FindViewById <SeekBar> (Resource.Id.seekPitch);

            seekSpeed.Progress = seekPitch.Progress = 127;
            txtSpeedVal.Text   = txtPitchVal.Text = "1.0";
            context            = btnSayIt.Context;
            textToSpeech       = new TextToSpeech(this, this, "com.google.android.tts");
            var langAvailable = new List <string> {
                "Default"
            };
            var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();

            foreach (var locale in localesAvailable)
            {
                LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
                Log.Info("MainActivity", "locale available=" + locale);
                switch (res)
                {
                case LanguageAvailableResult.Available:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryVarAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;
                }
            }
            langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();
            var adapter = new ArrayAdapter <string> (this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable);

            spinLanguages.Adapter = adapter;
            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);
            textToSpeech.SetPitch(1.1f);
            textToSpeech.SetSpeechRate(1.0f);
            btnSayIt.Click += delegate {
                Log.Info("MainActivity", "btnSayIt: " + editWhatToSay.Text);
                if (!string.IsNullOrEmpty(editWhatToSay.Text))
                {
                    textToSpeech.Speak(editWhatToSay.Text, QueueMode.Flush, null);
                }
            };
            seekPitch.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) => {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                textToSpeech.SetPitch(progress);
                txtPitchVal.Text = progress.ToString("F2");
            };
            seekSpeed.StopTrackingTouch += (object sender, SeekBar.StopTrackingTouchEventArgs e) => {
                var seek     = sender as SeekBar;
                var progress = seek.Progress / 255f;
                textToSpeech.SetSpeechRate(progress);
                txtSpeedVal.Text = progress.ToString("F2");
            };
            spinLanguages.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                lang = Java.Util.Locale.GetAvailableLocales().FirstOrDefault(t => t.DisplayLanguage == langAvailable [(int)e.Id]);
                // create intent to check the TTS has this language installed
                var checkTTSIntent = new Intent();
                checkTTSIntent.SetAction(TextToSpeech.Engine.ActionCheckTtsData);
                StartActivityForResult(checkTTSIntent, NeedLang);
            };
            //VOLUMKONTROLL!! Volumet er uavhengig fra alle andre volumkontroller på device!

            //parsing
            var btnTell = FindViewById <Button> (Resource.Id.btnTell);
            var say     = FindViewById <EditText> (Resource.Id.textYouSay);

            btnTell.Click += delegate {
                Log.Info("MainActivity", "btnTell: " + say.Text);
                if (!string.IsNullOrEmpty(say.Text))
                {
                    String tell = learner.respondToSentence(say.Text);
                    textBox.Text = tell;
                    textToSpeech.Speak(tell, QueueMode.Flush, null);
                    //learn (say.Text);
                }
            };
        }
Exemple #22
0
        public View GetSampleContent(Context con)
        {
            SamplePageContent(con);
            FrameLayout mainFrameLayout = new FrameLayout(con);

            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, GravityFlags.FillVertical);
            mainFrameLayout.LayoutParameters = layoutParams;

            //PrincipalAmountNumericTextBox
            principalAmountNumericTextBox = new SfNumericTextBox(con);
            principalAmountNumericTextBox.FormatString               = "C";
            principalAmountNumericTextBox.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, numerHeight);
            principalAmountNumericTextBox.Value                      = 1000;
            principalAmountNumericTextBox.AllowNull                  = true;
            principalAmountNumericTextBox.Watermark                  = "Principal Amount";
            principalAmountNumericTextBox.MaximumNumberDecimalDigits = 2;
            var culture = new Java.Util.Locale("en", "US");

            principalAmountNumericTextBox.CultureInfo     = culture;
            principalAmountNumericTextBox.ValueChangeMode = ValueChangeMode.OnKeyFocus;

            //InterestNumericTextBox
            interestNumericTextBox = new SfNumericTextBox(con);
            interestNumericTextBox.FormatString               = "P";
            interestNumericTextBox.Value                      = 0.1;
            interestNumericTextBox.PercentDisplayMode         = PercentDisplayMode.Compute;
            interestNumericTextBox.MaximumNumberDecimalDigits = 2;
            interestNumericTextBox.ValueChangeMode            = ValueChangeMode.OnKeyFocus;
            interestNumericTextBox.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, numerHeight);
            interestNumericTextBox.Watermark                  = "Rate of Interest";
            interestNumericTextBox.AllowNull                  = true;
            interestNumericTextBox.CultureInfo                = culture;

            //PeriodValueNumericTextBox
            periodValueNumericTextBox = new SfNumericTextBox(con);
            periodValueNumericTextBox.FormatString = " years";
            periodValueNumericTextBox.Value        = 20;
            periodValueNumericTextBox.MaximumNumberDecimalDigits = 0;
            periodValueNumericTextBox.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, numerHeight);
            periodValueNumericTextBox.Watermark       = "Period (in years)";
            periodValueNumericTextBox.ValueChangeMode = ValueChangeMode.OnKeyFocus;
            periodValueNumericTextBox.CultureInfo     = culture;
            periodValueNumericTextBox.AllowNull       = true;

            //OutputNumberTextBox
            outputNumberTextBox = new SfNumericTextBox(con);
            outputNumberTextBox.FormatString = "c";
            outputNumberTextBox.MaximumNumberDecimalDigits = 0;
            outputNumberTextBox.AllowNull        = true;
            outputNumberTextBox.CultureInfo      = culture;
            outputNumberTextBox.Watermark        = "Enter Values";
            outputNumberTextBox.Clickable        = false;
            outputNumberTextBox.Value            = (float)(1000 * 0.1 * 20);
            outputNumberTextBox.Enabled          = false;
            outputNumberTextBox.LayoutParameters = new ViewGroup.LayoutParams(width / 2, numerHeight);
            outputNumberTextBox.ValueChangeMode  = ValueChangeMode.OnLostFocus;

            //Numerictextbox Value Changed Listener
            principalAmountNumericTextBox.ValueChanged += (object sender, ValueChangedEventArgs e) => {
                if (e.Value != null && periodValueNumericTextBox.Value != null && interestNumericTextBox.Value != null)
                {
                    outputNumberTextBox.Value = Double.Parse(e.Value.ToString()) * Double.Parse(periodValueNumericTextBox.Value.ToString()) * Double.Parse(interestNumericTextBox.Value.ToString());
                }
            };
            periodValueNumericTextBox.ValueChanged += (object sender, ValueChangedEventArgs e) => {
                if (e.Value != null && principalAmountNumericTextBox.Value != null && interestNumericTextBox.Value != null)
                {
                    outputNumberTextBox.Value = Double.Parse(e.Value.ToString()) * Double.Parse(principalAmountNumericTextBox.Value.ToString()) * Double.Parse(interestNumericTextBox.Value.ToString());
                }
            };
            interestNumericTextBox.ValueChanged += (object sender, ValueChangedEventArgs e) => {
                if (e.Value != null && principalAmountNumericTextBox.Value != null && periodValueNumericTextBox.Value != null)
                {
                    outputNumberTextBox.Value = Double.Parse(e.Value.ToString()) * Double.Parse(principalAmountNumericTextBox.Value.ToString()) * Double.Parse(periodValueNumericTextBox.Value.ToString());
                }
            };

            mainFrameLayout.AddView(GetView(con));
            ScrollView mainScrollView = new ScrollView(con);

            mainScrollView.AddView(mainFrameLayout);

            return(mainScrollView);
        }
Exemple #23
0
        private void InvokeRead(string TextToRead, long MillisecValue)
        {
            // set up the TextToSpeech object
            // third parameter is the speech engine to use
            textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

            // set up the langauge spinner
            // set the top option to be default
            var langAvailable = new List <string> {
                "Default"
            };

            // our spinner only wants to contain the languages supported by the tts and ignore the rest
            var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();

            foreach (var locale in localesAvailable)
            {
                LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
                switch (res)
                {
                case LanguageAvailableResult.Available:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryVarAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;
                }
            }
            langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();

            //var adapter = new ArrayAdapter<string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable);
            //spinLanguages.Adapter = adapter;

            // set up the speech to use the default langauge
            // if a language is not available, then the default language is used.
            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);


            var editWhatToSay = FindViewById <EditText>(Resource.Id.etxtTTSEmailForm);

            editWhatToSay.Text = TextToRead;

            if (!string.IsNullOrEmpty(TextToRead))
            {
                //new Thread(new ThreadStart(() =>
                //{
                //    RunOnUiThread(() =>
                //    {
                textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");
                textToSpeech.Speak(TextToRead, QueueMode.Flush, null, null);
                //    });
                //})).Start();
            }

            var btnAction = FindViewById <ImageButton>(Resource.Id.imgBtnListenEmailForm);

            btnAction.SetImageResource(Resource.Drawable.micspeak);
            //@android:drawable/presence_audio_online + Android.Resource.Drawable.PresenceAudioOnline + Android.Resource.Drawable.IcDialogInfo

            NeedToSpeak = false;
        }
Exemple #24
0
        protected override async void OnCreate(Bundle savedInstanceState)
        {
            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            if (prefs.GetString("locale", "") == "")
            {
                editor.PutString("locale", "en");
                editor.Apply();
            }
            string loc    = prefs.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;
            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.activity_buildings);

            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;


            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            apiClient = new APIClient();
            buildings = await apiClient.GetBuildingsListAsync();

            workplaces = await apiClient.GetWorkplacesListAsync();

            workplacesList = workplaces.ToList();

            LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.lay_build);

            //foreach (Building building in buildings)
            //{
            //    TextView buildTextView = new TextView(this);
            //    buildTextView.Text = "Address: " + building.Country + ", " + building.City + ", " + building.Street + ", "
            //        + building.House.ToString() + ", " + building.Flat.ToString();
            //    Landlord landlord = await apiClient.GetLandlordByIdAsync((int)building.LandlordId);
            //    buildTextView.Text += "\nLandlord: " + landlord.FirstName + " " + landlord.LastName
            //        + "\n Phone: " + landlord.Phone.ToString() + "\n Email: " + landlord.Email;
            //    linearLayout.AddView(buildTextView);
            //}

            Button          search      = FindViewById <Button>(Resource.Id.search_button);
            EditText        editCountry = FindViewById <EditText>(Resource.Id.country_edit_text);
            EditText        editCity    = FindViewById <EditText>(Resource.Id.city_edit_text);
            EditText        editStreet  = FindViewById <EditText>(Resource.Id.street_edit_text);
            EditText        editHouse   = FindViewById <EditText>(Resource.Id.house_edit_text);
            EditText        editFlat    = FindViewById <EditText>(Resource.Id.flat_edit_text);
            int             flat        = 0;
            List <Building> resultList  = new List <Building>(buildings).ToList();

            search.Click += async(s, arg) =>
            {
                linearLayout.RemoveAllViews();
                if (editCountry.Text != "")
                {
                    resultList = resultList.Where(x => x.Country == editCountry.Text).ToList();
                }
                if (editCity.Text != "")
                {
                    resultList = resultList.Where(x => x.City == editCity.Text).ToList();
                }
                if (editStreet.Text != "")
                {
                    resultList = resultList.Where(x => x.Street == editStreet.Text).ToList();
                }
                if (editHouse.Text != "")
                {
                    resultList = resultList.Where(x => x.House == editHouse.Text).ToList();
                }
                if (int.TryParse(editFlat.Text, out flat) && flat > 0)
                {
                    resultList = resultList.Where(x => x.Flat == flat).ToList();
                }

                foreach (var item in resultList)
                {
                    TextView buildTextView = new TextView(this);
                    buildTextView.Text = "Address: " + item.Country + ", " + item.City + ", " + item.Street + ", "
                                         + item.House.ToString() + ", " + item.Flat.ToString();
                    Landlord lord = await apiClient.GetLandlordByIdAsync((int)item.LandlordId);

                    buildTextView.Text += "\nLandlord: " + lord.FirstName + " " + lord.LastName
                                          + "\n Phone: " + lord.Phone.ToString() + "\n Email: " + lord.Email;
                    buildTextView.Id = (int)item.Id;
                    linearLayout.AddView(buildTextView);

                    buildTextView.Click += (s1, arg1) =>
                    {
                        List <Workplace> wokpl = workplacesList.Where(x => x.BuildingId == buildTextView.Id).ToList();
                        PopupMenu        menu  = new PopupMenu(this, buildTextView);
                        foreach (var work in wokpl)
                        {
                            menu.Menu.Add(work.Mark.ToString() + "," + work.Id.ToString());
                        }

                        menu.MenuItemClick += async(s2, arg2) =>
                        {
                            string                   workplaceString = arg2.Item.TitleFormatted.ToString();
                            int                      workplaceId     = int.Parse(workplaceString.Split(',')[1]);
                            ISharedPreferences       prefs1          = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                            ISharedPreferencesEditor editor1         = prefs1.Edit();

                            editor1.PutString("workplaceId", workplaceId.ToString());
                            editor1.Apply();

                            var intent = new Intent(this, typeof(WorkplaceActivity));
                            StartActivity(intent);
                        };
                        menu.Show();
                    };
                }
            };
        }
Exemple #25
0
        private void InitTTSMethod()
        {
            btnSayIt = FindViewById <Button>(Resource.Id.btnReadEmailReader);

            // set up the TextToSpeech object
            // third parameter is the speech engine to use
            textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");

            // set up the langauge spinner
            // set the top option to be default
            var langAvailable = new List <string> {
                "Default"
            };

            // our spinner only wants to contain the languages supported by the tts and ignore the rest
            var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();

            foreach (var locale in localesAvailable)
            {
                LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
                switch (res)
                {
                case LanguageAvailableResult.Available:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryVarAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;
                }
            }
            langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();

            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);

            // connect up the events
            btnSayIt.Click += delegate
            {
                // if there is nothing to say, don't say it
                var EmailsToRead = "";
                //var curemail = new EmailObject(message.MessageId, message.From.ToString(), message.Subject, message.TextBody, message.Cc.ToString());
                EmailsToRead += " You have an email:" + emlSubject;
                EmailsToRead += " From: " + emlFrom;
                EmailsToRead += " Content is: " + emlBody;
                EmailsToRead += " On: " + emlDate;

                if (!string.IsNullOrEmpty(EmailsToRead))
                {
                    if (EmailsToRead.Length > 3000)
                    {
                        textToSpeech.Speak(EmailsToRead.Substring(0, 3000), QueueMode.Add, null, null);
                    }
                    else
                    {
                        textToSpeech.Speak(EmailsToRead, QueueMode.Add, null, null);
                    }
                }
            };
        }
Exemple #26
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.menu_save)
            {
                int radiusValue = 0;
                int costValue   = 0;
                if (radiusEditText.Text == "" || costEditText.Text == "" || !int.TryParse(radiusEditText.Text, out radiusValue) ||
                    !int.TryParse(costEditText.Text, out costValue) || radiusValue <= 0 || costValue <= 0)
                {
                    Toast.MakeText(this, "Invalid data", ToastLength.Short).Show();
                }
                else
                {
                    searchingViewModel.Radius     = radiusValue;
                    searchingViewModel.WantedCost = costValue;

                    ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                    ISharedPreferencesEditor editor = prefs.Edit();
                    string json = JsonConvert.SerializeObject(searchingViewModel);
                    editor.PutString("searchingViewModel", json);
                    editor.Apply();
                }
                return(true);
            }
            else if (id == Resource.Id.menu_main_logout)
            {
                var intent = new Intent(this, typeof(MainActivity));
                StartActivity(intent);
                return(true);
            }
            else if (id == Resource.Id.menu_main_lang)
            {
                ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
                ISharedPreferencesEditor editor = prefs.Edit();
                if (prefs.GetString("locale", "") == "en")
                {
                    editor.PutString("locale", "uk");
                }
                else
                {
                    editor.PutString("locale", "en");
                }
                editor.Apply();

                string loc    = prefs.GetString("locale", "");
                var    locale = new Java.Util.Locale(loc);
                var    config = new Android.Content.Res.Configuration {
                    Locale = locale
                };
#pragma warning disable CS0618 // Type or member is obsolete
                BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete

                //ava.Util.Locale.Default = locale;
                this.Recreate();
            }

            return(base.OnOptionsItemSelected(item));
        }
        public override View GetPropertyWindowLayout(Context context)
        {
            /**
             * Property Window
             * */
            int width = (context.Resources.DisplayMetrics.WidthPixels) / 2;

            propertylayout             = new LinearLayout(context); //= new LinearLayout(context);
            propertylayout.Orientation = Orientation.Vertical;

            LinearLayout.LayoutParams layoutParams1 = new LinearLayout.LayoutParams(
                width * 2, 5);

            layoutParams1.SetMargins(0, 20, 0, 0);

            TextView culturetxt = new TextView(context);

            culturetxt.TextSize = 20;
            culturetxt.Text     = "Culture";

            cultureSpinner = new Spinner(context);
            //cultureSpinner.Gravity=GravityFlags.Left;


            List <String> list = new List <String>();

            list.Add("United States");
            list.Add("United Kingdom");
            list.Add("Japan");
            list.Add("France");
            list.Add("Italy");


            dataAdapter = new ArrayAdapter <String>
                              (context, Android.Resource.Layout.SimpleSpinnerItem, list);
            dataAdapter.SetDropDownViewResource
                (Android.Resource.Layout.SimpleSpinnerDropDownItem);

            cultureSpinner.Adapter = dataAdapter;

            cultureSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                String selectedItem = dataAdapter.GetItem(e.Position);

                if (selectedItem.Equals("United States"))
                {
                    localinfo = Java.Util.Locale.Us;                   //new Java.Util.Locale("en","US");
                }
                if (selectedItem.Equals("United Kingdom"))
                {
                    localinfo = Java.Util.Locale.Uk;
                }
                if (selectedItem.Equals("Japan"))
                {
                    localinfo = Java.Util.Locale.Japan;
                }
                if (selectedItem.Equals("France"))
                {
                    localinfo = Java.Util.Locale.France;
                }
                if (selectedItem.Equals("Italy"))
                {
                    localinfo = Java.Util.Locale.Italy;
                }
            };
            propertylayout.AddView(culturetxt);
            propertylayout.AddView(cultureSpinner);

            SeparatorView separate = new SeparatorView(context, width * 2);

            separate.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            propertylayout.AddView(separate, layoutParams1);

            TextView textView6 = new TextView(context);

            textView6.Text     = "Allow Null";
            textView6.Gravity  = GravityFlags.Center;
            textView6.TextSize = 20;

            Switch checkBox = new Switch(context);

            checkBox.Checked        = true;
            checkBox.CheckedChange += (object send, CompoundButton.CheckedChangeEventArgs eve) => {
                if (!eve.IsChecked)
                {
                    allownull = false;
                }
                else
                {
                    allownull = true;
                }
            };

            LinearLayout.LayoutParams layoutParams3 = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            layoutParams3.SetMargins(0, 10, 0, 0);
            LinearLayout.LayoutParams layoutParams4 = new LinearLayout.LayoutParams(
                ViewGroup.LayoutParams.WrapContent, 55);
            layoutParams4.SetMargins(0, 10, 0, 0);
            stackView3 = new LinearLayout(context);
            stackView3.AddView(textView6, layoutParams4);
            stackView3.AddView(checkBox, layoutParams3);
            stackView3.Orientation = Orientation.Horizontal;
            propertylayout.AddView(stackView3);
            SeparatorView separate3 = new SeparatorView(context, width * 2);

            separate3.LayoutParameters = new ViewGroup.LayoutParams(width * 2, 5);
            LinearLayout.LayoutParams layoutParams5 = new LinearLayout.LayoutParams(width * 2, 5);
            layoutParams5.SetMargins(0, 20, 15, 0);
            propertylayout.AddView(separate3, layoutParams5);
            propertylayout.SetPadding(20, 20, 20, 20);

            return(propertylayout);
        }
        public async Task SpeakAsync(string text, int max, SpeakSettings settings, CancellationToken cancelToken)
        {
            await Initialize();

            // Wait for any previous calls to finish up
            if (tcsUtterances?.Task != null)
            {
                await tcsUtterances.Task;
            }

            if (cancelToken != null)
            {
                cancelToken.Register(() =>
                {
                    try
                    {
                        tts?.Stop();

                        tcsUtterances?.TrySetResult(true);
                    }
                    catch
                    {
                    }
                });
            }

            if (settings?.Locale?.Language != null)
            {
                JavaLocale locale = null;
                if (!string.IsNullOrWhiteSpace(settings?.Locale.Country))
                {
                    locale = new JavaLocale(settings.Locale.Language, settings.Locale.Country);
                }
                else
                {
                    locale = new JavaLocale(settings.Locale.Language);
                }

                tts.SetLanguage(locale);
            }
            else
            {
                SetDefaultLanguage();
            }

            if (settings?.Pitch.HasValue ?? false)
            {
                tts.SetPitch(settings.Pitch.Value);
            }
            else
            {
                tts.SetPitch(TextToSpeech.PitchDefault);
            }

            var parts = text.SplitSpeak(max);

            numExpectedUtterances = parts.Count;
            tcsUtterances         = new TaskCompletionSource <bool>();

            var guid = Guid.NewGuid().ToString();

            for (var i = 0; i < parts.Count && !cancelToken.IsCancellationRequested; i++)
            {
                // We require the utterance id to be set if we want the completed listener to fire
                var map = new Dictionary <string, string>
                {
                    { AndroidTextToSpeech.Engine.KeyParamUtteranceId, $"{guid}.{i}" }
                };

                if (settings != null && settings.Volume.HasValue)
                {
                    map.Add(AndroidTextToSpeech.Engine.KeyParamVolume, settings.Volume.Value.ToString(CultureInfo.InvariantCulture));
                }

                // We use an obsolete overload here so it works on older API levels at runtime
                // Flush on first entry and add (to not flush our own previous) subsequent entries
#pragma warning disable CS0618
                tts.Speak(parts[i], i == 0 ? QueueMode.Flush : QueueMode.Add, map);
#pragma warning restore CS0618
            }

            await tcsUtterances.Task;
        }
        //Java.Lang.Object.Locale localinfo;
        public override View GetSampleContent(Context con)
        {
            Context     localcontext = con;
            int         width        = con.Resources.DisplayMetrics.WidthPixels - 40;
            FrameLayout frameLayout  = new FrameLayout(con);

            FrameLayout.LayoutParams layoutParams = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.MatchParent, GravityFlags.FillVertical);
            frameLayout.LayoutParameters = layoutParams;
            LinearLayout layout = new LinearLayout(con);

            layout.LayoutParameters = new ViewGroup.LayoutParams(ViewGroup.LayoutParams.WrapContent, ViewGroup.LayoutParams.WrapContent);
            layout.SetGravity(GravityFlags.FillVertical);
            layout.Orientation = Orientation.Vertical;
            TextView dummy0 = new TextView(con);

            dummy0.Text     = "Simple Interest Calculator";
            dummy0.Gravity  = GravityFlags.Center;
            dummy0.TextSize = 24;
            layout.AddView(dummy0);
            TextView dummy7 = new TextView(con);

            layout.AddView(dummy7);
            TextView dummy = new TextView(con);

            dummy.Text     = "The formula for finding simple interest is:";
            dummy.TextSize = 18;
            layout.AddView(dummy);


            layout.FocusableInTouchMode = true;
            SpannableStringBuilder builder = new SpannableStringBuilder();
            TextView        dummy1         = new TextView(con);
            String          str            = "Interest";
            SpannableString strSpannable   = new SpannableString(str);

            strSpannable.SetSpan(new ForegroundColorSpan(Color.ParseColor("#66BB6A")), 0, str.Length, 0);
            builder.Append(strSpannable);
            builder.Append(" = Principal * Rate * Time");
            dummy1.SetText(builder, TextView.BufferType.Spannable);
            dummy1.TextSize = 18;
            layout.AddView(dummy1);

            TextView dummy8 = new TextView(con);

            layout.AddView(dummy8);

            /*
             * Principal amount Stack
             */

            LinearLayout principalStack = new LinearLayout(con);

            TextView txtPricipal = new TextView(con);

            txtPricipal.LayoutParameters = new ViewGroup.LayoutParams(width / 2, 100);
            txtPricipal.Text             = "Principal";

            principalamount = new SfNumericTextBox(con);
            principalamount.FormatString               = "C";
            principalamount.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, 100);
            principalamount.Value                      = 1000;
            principalamount.AllowNull                  = true;
            principalamount.Watermark                  = "Principal Amount";
            principalamount.MaximumNumberDecimalDigits = 2;
            var culture = new Java.Util.Locale("en", "US");

            principalamount.CultureInfo     = culture;
            principalamount.ValueChangeMode = ValueChangeMode.OnKeyFocus;
            principalStack.Orientation      = Orientation.Horizontal;
            principalStack.AddView(txtPricipal);
            principalStack.AddView(principalamount);

            layout.AddView(principalStack);

            TextView dummy3 = new TextView(con);

            layout.AddView(dummy3);

            /*
             * Interest Input Box
             */

            LinearLayout InterestcalStack = new LinearLayout(con);

            TextView txtInterest = new TextView(con);

            txtInterest.LayoutParameters = new ViewGroup.LayoutParams(width / 2, 100);
            txtInterest.Text             = "Interest Rate";
            Interestvalue = new SfNumericTextBox(con);
            Interestvalue.FormatString               = "P";
            Interestvalue.PercentDisplayMode         = PercentDisplayMode.Compute;
            Interestvalue.MaximumNumberDecimalDigits = 2;
            Interestvalue.ValueChangeMode            = ValueChangeMode.OnKeyFocus;
            Interestvalue.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, 100);
            Interestvalue.Value          = 0.1f;
            Interestvalue.Watermark      = "Rate of Interest";
            Interestvalue.AllowNull      = true;
            Interestvalue.CultureInfo    = culture;
            InterestcalStack.Orientation = Orientation.Horizontal;
            InterestcalStack.AddView(txtInterest);
            InterestcalStack.AddView(Interestvalue);


            layout.AddView(InterestcalStack);

            TextView dummy2 = new TextView(con);

            layout.AddView(dummy2);



            /*
             * Period Input TextBox
             */
            LinearLayout periodStack = new LinearLayout(con);

            TextView period = new TextView(con);

            period.LayoutParameters = new ViewGroup.LayoutParams(width / 2, 100);
            period.Text             = "Term";

            periodValue = new SfNumericTextBox(con);
            periodValue.FormatString = " years";
            periodValue.MaximumNumberDecimalDigits = 0;
            periodValue.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, 100);
            periodValue.Value           = 20;
            periodValue.Watermark       = "Period (in years)";
            periodValue.ValueChangeMode = ValueChangeMode.OnKeyFocus;
            periodValue.CultureInfo     = culture;
            periodValue.AllowNull       = true;

            periodStack.Orientation = Orientation.Horizontal;

            periodStack.AddView(period);
            periodStack.AddView(periodValue);

            layout.AddView(periodStack);



            /*
             * OutPut values
             */

            LinearLayout outputStack = new LinearLayout(con);

            TextView outputtxt = new TextView(con);

            outputtxt.LayoutParameters = new ViewGroup.LayoutParams(width / 2, 100);
            outputtxt.Text             = "Interest";
            outputtxt.SetTextColor(Color.ParseColor("#66BB6A"));

            OutputNumbertxtBox = new SfNumericTextBox(con);
            OutputNumbertxtBox.FormatString = "c";
            OutputNumbertxtBox.MaximumNumberDecimalDigits = 0;
            OutputNumbertxtBox.AllowNull        = true;
            OutputNumbertxtBox.CultureInfo      = culture;
            OutputNumbertxtBox.Watermark        = "Enter Values";
            OutputNumbertxtBox.Clickable        = false;
            OutputNumbertxtBox.Value            = (float)(1000 * 0.1 * 20);
            OutputNumbertxtBox.Enabled          = false;
            OutputNumbertxtBox.LayoutParameters = new ViewGroup.LayoutParams(width / 2, 100);
            OutputNumbertxtBox.ValueChangeMode  = ValueChangeMode.OnLostFocus;


            outputStack.Orientation = Orientation.Horizontal;

            outputStack.AddView(outputtxt);
            outputStack.AddView(OutputNumbertxtBox);
            layout.AddView(outputStack);

            TextView dummy4 = new TextView(con);

            layout.SetPadding(20, 20, 10, 20);
            layout.AddView(dummy4);

            principalamount.ValueChanged += (object sender, SfNumericTextBox.ValueChangedEventArgs e) => {
                if (!e.P1.ToString().Equals("") && !periodValue.Value.ToString().Equals("") && !Interestvalue.Value.ToString().Equals(""))
                {
                    OutputNumbertxtBox.Value = e.P1 * periodValue.Value * Interestvalue.Value;
                }
            };

            periodValue.ValueChanged += (object sender, SfNumericTextBox.ValueChangedEventArgs e) => {
                if (!e.P1.ToString().Equals("") && !principalamount.Value.ToString().Equals("") && !Interestvalue.Value.ToString().Equals(""))
                {
                    OutputNumbertxtBox.Value = e.P1 * principalamount.Value * Interestvalue.Value;
                }
            };

            Interestvalue.ValueChanged += (object sender, SfNumericTextBox.ValueChangedEventArgs e) => {
                if (!e.P1.ToString().Equals("") && !principalamount.Value.ToString().Equals("") && !periodValue.Value.ToString().Equals(""))
                {
                    OutputNumbertxtBox.Value = e.P1 * principalamount.Value * periodValue.Value;
                }
            };

            layout.Touch += (object sender, View.TouchEventArgs e) => {
                if (OutputNumbertxtBox.IsFocused || Interestvalue.IsFocused || periodValue.IsFocused || principalamount.IsFocused)
                {
                    Rect outRect = new Rect();
                    OutputNumbertxtBox.GetGlobalVisibleRect(outRect);
                    Interestvalue.GetGlobalVisibleRect(outRect);
                    periodValue.GetGlobalVisibleRect(outRect);
                    principalamount.GetGlobalVisibleRect(outRect);

                    if (!outRect.Contains((int)e.Event.RawX, (int)e.Event.RawY))
                    {
                        if (!OutputNumbertxtBox.Value.ToString().Equals(""))
                        {
                            OutputNumbertxtBox.ClearFocus();
                        }
                        if (!Interestvalue.Value.ToString().Equals(""))
                        {
                            Interestvalue.ClearFocus();
                        }
                        if (!periodValue.Value.ToString().Equals(""))
                        {
                            periodValue.ClearFocus();
                        }
                        if (!principalamount.Value.ToString().Equals(""))
                        {
                            principalamount.ClearFocus();
                        }
                    }
                    hideSoftKeyboard((Activity)localcontext);
                }
            };



            frameLayout.AddView(layout);

            ScrollView scrollView = new ScrollView(con);

            scrollView.AddView(frameLayout);

            return(scrollView);
        }
        ///////////////////////////////////////////////////////

        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);;
            string TxtToVoice = this.Intent.GetStringExtra("TxtToVoice");
            int    para2      = this.Intent.GetIntExtra("DelayTime", -1);

            isRecording = false;
            SetContentView(Resource.Layout.TextToLuisMain);

            textBox        = FindViewById <TextView>(Resource.Id.textYourText);
            LuisBox_Intent = FindViewById <TextView>(Resource.Id.LuisIntentText);
            LuisBox_Entiti = FindViewById <TextView>(Resource.Id.LuisEntitiText);

            int para3 = this.Intent.GetIntExtra("para3", -1);

            if (para3 >= 0)
            {
                VoiceIndex = para3; para3 = 0;
                PollingJobTime(300, para3);
            }
            else
            {
                PollingJobTime(300, 0);
            }
            textToSpeech = new TextToSpeech(this, this, "com.google.android.tts");
            var langAvailable = new List <string> {
                "Default"
            };

            // our spinner only wants to contain the languages supported by the tts and ignore the rest
            var localesAvailable = Java.Util.Locale.GetAvailableLocales().ToList();

            foreach (var locale in localesAvailable)
            {
                LanguageAvailableResult res = textToSpeech.IsLanguageAvailable(locale);
                switch (res)
                {
                case LanguageAvailableResult.Available:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;

                case LanguageAvailableResult.CountryVarAvailable:
                    langAvailable.Add(locale.DisplayLanguage);
                    break;
                }
            }
            langAvailable = langAvailable.OrderBy(t => t).Distinct().ToList();

            var adapter = new ArrayAdapter <string>(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, langAvailable);

            // set up the speech to use the default langauge
            // if a language is not available, then the default language is used.
            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);

            // set the speed and pitch
            textToSpeech.SetPitch(.9f);
            textToSpeech.SetSpeechRate(.9f);


            // check to see if we can actually record - if we can, assign the event to the button
            string rec = Android.Content.PM.PackageManager.FeatureMicrophone;

            if (rec != "android.hardware.microphone")
            {
                // no microphone, no recording. Disable the button and output an alert
                var alert = new AlertDialog.Builder(recButton.Context);
                alert.SetTitle("You don't seem to have a microphone to record with");
                alert.SetPositiveButton("OK", (sender, e) =>
                {
                    textBox.Text      = "No microphone present";
                    recButton.Enabled = false;
                    return;
                });

                alert.Show();
            }
        }
Exemple #31
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            // Create your application here
            SetContentView(Resource.Layout.letters);

            AdView mAdView = FindViewById<AdView>(Resource.Id.adView1);
            var adRequest = new AdRequest.Builder().Build();
            // Start loading the ad.
            mAdView.LoadAd(adRequest);


            textToSpeech = new TextToSpeech(this, null, "com.google.android.tts");


            lang = Java.Util.Locale.Default;
            textToSpeech.SetLanguage(lang);

            // set the speed and pitch
            textToSpeech.SetPitch(1.00f);
            textToSpeech.SetSpeechRate(.8f);



             a = FindViewById<Button>(Resource.Id.a);
            b = FindViewById<Button>(Resource.Id.b);
            c = FindViewById<Button>(Resource.Id.c);
            d = FindViewById<Button>(Resource.Id.d);
            e = FindViewById<Button>(Resource.Id.e);
            f = FindViewById<Button>(Resource.Id.f);
            g = FindViewById<Button>(Resource.Id.g);
            h = FindViewById<Button>(Resource.Id.h);
            i = FindViewById<Button>(Resource.Id.i);
            j = FindViewById<Button>(Resource.Id.j);
            k = FindViewById<Button>(Resource.Id.k);
            l = FindViewById<Button>(Resource.Id.l);
            m = FindViewById<Button>(Resource.Id.m);
            n = FindViewById<Button>(Resource.Id.n);
            o = FindViewById<Button>(Resource.Id.o);
            p = FindViewById<Button>(Resource.Id.p);
            u = FindViewById<Button>(Resource.Id.u);
            q = FindViewById<Button>(Resource.Id.q);
            r = FindViewById<Button>(Resource.Id.r);
            s = FindViewById<Button>(Resource.Id.s);
            w = FindViewById<Button>(Resource.Id.w);
            v = FindViewById<Button>(Resource.Id.v);
            x = FindViewById<Button>(Resource.Id.x);
            y = FindViewById<Button>(Resource.Id.y);
            z = FindViewById<Button>(Resource.Id.z);
            one = FindViewById<Button>(Resource.Id.one);
            two = FindViewById<Button>(Resource.Id.two);
            three = FindViewById<Button>(Resource.Id.three);
            four = FindViewById<Button>(Resource.Id.four);
            five = FindViewById<Button>(Resource.Id.five);
            six = FindViewById<Button>(Resource.Id.six);
            seven = FindViewById<Button>(Resource.Id.seven);
            eight = FindViewById<Button>(Resource.Id.eight);
            nine = FindViewById<Button>(Resource.Id.nine);
            ten = FindViewById<Button>(Resource.Id.ten);
            t = FindViewById<Button>(Resource.Id.t);
            
            a.Click +=  A_Click;
            b.Click += B_Click;
            c.Click += C_Click;
            d.Click += D_Click;
            e.Click += E_Click;
            f.Click += F_Click;
            g.Click += G_Click;
            h.Click += H_Click;
            i.Click += I_Click;
            k.Click += K_Click;

            w.Click += w_Click;
            k.Click += K_Click;
            l.Click += L_Click;
            m.Click += M_Click;
            n.Click += N_Click;
            o.Click += O_Click;
            j.Click += J_Click;
            t.Click += T_Click;
            q.Click += Q_Click;
            p.Click += P_Click;
            r.Click += R_Click;
            s.Click += S_Click;
            u.Click += U_Click;
            v.Click += V_Click;
            x.Click += X_Click;

            z.Click += Z_Click;
            one.Click += One_Click;
            two.Click += Two_Click;
            three.Click += Three_Click;
            four.Click += Four_Click;
            five.Click += Five_Click;
            six.Click += Six_Click;
            seven.Click += Seven_Click;
            eight.Click += Eight_Click;
            nine.Click += Nine_Click;
            ten.Click += Ten_Click;
            y.Click += y_Click;






        }
Exemple #32
0
 public FluentInitializer WithLocale(Java.Util.Locale locale)
 {
     //Not sure how to translate this to C# flavor.
     //Leave it later.
     throw new NotImplementedException();
 }
Exemple #33
0
        private async Task Speak(CancellationToken cancelToken)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            var textToSpeech = ttsInitializer.TextToSpeech;

            if (language.HasValue && !string.IsNullOrWhiteSpace(language.Value.Language))
            {
                Java.Util.Locale locale = null;
                if (!string.IsNullOrWhiteSpace(language.Value.Country))
                {
                    locale = new Java.Util.Locale(language.Value.Language, language.Value.Country);
                }
                else
                {
                    locale = new Java.Util.Locale(language.Value.Language);
                }

                var result = textToSpeech.IsLanguageAvailable(locale);
                if (result == LanguageAvailableResult.CountryAvailable)
                {
                    textToSpeech.SetLanguage(locale);
                }
                else
                {
                    Console.WriteLine("Locale: " + locale + " was not valid, setting to default.");
                    SetDefaultLanguage();
                }
            }
            else
            {
                SetDefaultLanguage();
            }

            var tcs = new TaskCompletionSource <object>();

            textToSpeech.SetPitch(pitch);
            textToSpeech.SetSpeechRate(speakRate);
            textToSpeech.SetOnUtteranceProgressListener(new TtsProgressListener(tcs));

#pragma warning disable CS0618 // Type or member is obsolete
            count++;
            var map = new Dictionary <string, string>
            {
                [global::Android.Speech.Tts.TextToSpeech.Engine.KeyParamUtteranceId] = count.ToString()
            };
            textToSpeech.Speak(text, QueueMode.Flush, map);
#pragma warning restore CS0618 // Type or member is obsolete

            void OnCancel()
            {
                textToSpeech.Stop();
                tcs.TrySetCanceled();
            }

            using (cancelToken.Register(OnCancel))
            {
                await tcs.Task;
            }
        }
Exemple #34
0
        public override View GetSampleContent(Context con1)
        {
            context = con = con1;
            InitialMethod();
            HeaderLabel();

            // principalAmountNumericTextBox
            LinearLayout principalStack = new LinearLayout(con);
            TextView     principalLabel = new TextView(con);

            principalLabel.LayoutParameters                          = new ViewGroup.LayoutParams(width / 2, numerHeight);
            principalLabel.Text                                      = "Principal";
            principalLabel.TextSize                                  = 20;
            principalAmountNumericTextBox                            = new SfNumericTextBox(con);
            principalAmountNumericTextBox.FormatString               = "C";
            principalAmountNumericTextBox.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, numerHeight);
            principalAmountNumericTextBox.Value                      = 1000;
            principalAmountNumericTextBox.AllowNull                  = true;
            principalAmountNumericTextBox.Watermark                  = "Principal Amount";
            principalAmountNumericTextBox.MaximumNumberDecimalDigits = 2;
            principalAmountNumericTextBox.FocusChange               += PrincipalAmountNumericTextBox_FocusChange;
            var culture = new Java.Util.Locale("en", "US");

            principalAmountNumericTextBox.CultureInfo     = culture;
            principalAmountNumericTextBox.ValueChangeMode = ValueChangeMode.OnKeyFocus;
            principalStack.Orientation = Orientation.Horizontal;
            principalStack.AddView(principalLabel);
            principalStack.AddView(principalAmountNumericTextBox);
            mainLayout.AddView(principalStack);
            TextView principalStackSpacing = new TextView(con);

            mainLayout.AddView(principalStackSpacing);

            //interestNumericTextBox
            LinearLayout InterestcalStack = new LinearLayout(con);
            TextView     interestLabel    = new TextView(con);

            interestLabel.LayoutParameters                    = new ViewGroup.LayoutParams(width / 2, numerHeight);
            interestLabel.Text                                = "Interest Rate";
            interestLabel.TextSize                            = 20;
            interestNumericTextBox                            = new SfNumericTextBox(con);
            interestNumericTextBox.FormatString               = "P";
            interestNumericTextBox.Value                      = 0.1;
            interestNumericTextBox.PercentDisplayMode         = PercentDisplayMode.Compute;
            interestNumericTextBox.MaximumNumberDecimalDigits = 2;
            interestNumericTextBox.ValueChangeMode            = ValueChangeMode.OnKeyFocus;
            interestNumericTextBox.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, numerHeight);
            interestNumericTextBox.Watermark                  = "Rate of Interest";
            interestNumericTextBox.AllowNull                  = true;
            interestNumericTextBox.CultureInfo                = culture;
            interestNumericTextBox.FocusChange               += InterestNumericTextBox_FocusChange;
            InterestcalStack.Orientation                      = Orientation.Horizontal;
            InterestcalStack.AddView(interestLabel);
            InterestcalStack.AddView(interestNumericTextBox);
            mainLayout.AddView(InterestcalStack);
            TextView InterestcalStackSpacing = new TextView(con);

            mainLayout.AddView(InterestcalStackSpacing);

            //periodValueNumericTextBox
            LinearLayout periodStack = new LinearLayout(con);
            TextView     period      = new TextView(con);

            period.LayoutParameters   = new ViewGroup.LayoutParams(width / 2, numerHeight);
            period.Text               = "Term";
            period.TextSize           = 20;
            periodValueNumericTextBox = new SfNumericTextBox(con);
            periodValueNumericTextBox.FormatString = " years";
            periodValueNumericTextBox.Value        = 20;
            periodValueNumericTextBox.MaximumNumberDecimalDigits = 0;
            periodValueNumericTextBox.LayoutParameters           = new ViewGroup.LayoutParams(width / 2, numerHeight);
            periodValueNumericTextBox.Watermark       = "Period (in years)";
            periodValueNumericTextBox.ValueChangeMode = ValueChangeMode.OnKeyFocus;
            periodValueNumericTextBox.CultureInfo     = culture;
            periodValueNumericTextBox.AllowNull       = true;
            periodValueNumericTextBox.FocusChange    += PeriodValueNumericTextBox_FocusChange;
            periodStack.Orientation = Orientation.Horizontal;
            periodStack.AddView(period);
            periodStack.AddView(periodValueNumericTextBox);
            mainLayout.AddView(periodStack);

            //outputNumberTextBox
            LinearLayout outputStack = new LinearLayout(con);
            TextView     outputLabel = new TextView(con);

            outputLabel.LayoutParameters = new ViewGroup.LayoutParams(width / 2, numerHeight);
            outputLabel.Text             = "Interest";
            outputLabel.TextSize         = 20;
            outputLabel.SetTextColor(Color.ParseColor("#66BB6A"));
            outputNumberTextBox = new SfNumericTextBox(con);
            outputNumberTextBox.FormatString = "c";
            outputNumberTextBox.MaximumNumberDecimalDigits = 0;
            outputNumberTextBox.AllowNull        = true;
            outputNumberTextBox.CultureInfo      = culture;
            outputNumberTextBox.Watermark        = "Enter Values";
            outputNumberTextBox.Clickable        = false;
            outputNumberTextBox.Value            = (float)(1000 * 0.1 * 20);
            outputNumberTextBox.Enabled          = false;
            outputNumberTextBox.LayoutParameters = new ViewGroup.LayoutParams(width / 2, numerHeight);
            outputNumberTextBox.ValueChangeMode  = ValueChangeMode.OnLostFocus;
            outputStack.Orientation = Orientation.Horizontal;
            outputStack.AddView(outputLabel);
            if (con.Resources.DisplayMetrics.Density > 1.5)
            {
                outputStack.SetY(60);
            }
            outputStack.AddView(outputNumberTextBox);
            mainLayout.AddView(outputStack);
            TextView outputStackSpacing = new TextView(con);

            mainLayout.AddView(outputStackSpacing);

            ValueChangeListener();

            return(frame);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            FacebookSdk.SdkInitialize(this.ApplicationContext);
            textToSpeech = new TextToSpeech(this, this);
            locale       = new Java.Util.Locale("pt", "BR");

            SetContentView(Resource.Layout.PagInicCliente);

            historico = Facade.GetPesquisas();

            // Facebook
            LoginButton loginbutton = FindViewById <LoginButton>(Resource.Id.login_button);

            loginbutton.SetReadPermissions("user_friends");

            mCallBackManager = CallbackManagerFactory.Create();

            loginbutton.RegisterCallback(mCallBackManager, this);

            PackageInfo info = this.PackageManager.GetPackageInfo("com.uminhomieili4.pick_a_prato", PackageInfoFlags.Signatures);

            foreach (Android.Content.PM.Signature signature in info.Signatures)
            {
                MessageDigest md = MessageDigest.GetInstance("SHA");
                md.Update(signature.ToByteArray());

                string keyhash = Convert.ToBase64String(md.Digest());
                Console.WriteLine("KeyHash: " + keyhash);
            }

            var imageuser = FindViewById <ImageView>(Resource.Id.foto);

            byte[] a = Convert.FromBase64String(Facade.atualUserC.Foto);
            Bitmap b = BitmapFactory.DecodeByteArray(a, 0, a.Length);

            imageuser.SetImageBitmap(b);

            var preferenciasButtom = FindViewById <Button>(Resource.Id.pref);

            preferenciasButtom.Click += (sender, e) => {
                StartActivity(typeof(EditarPreferencias));
            };

            var switchpref = FindViewById <Switch>(Resource.Id.switchpref);

            switchpref.Checked = true;

            Button guardadosbottom = FindViewById <Button>(Resource.Id.selecoes);

            guardadosbottom.Click += (sender, e) => {
                ListaPratos.pratoList = Facade.GetPratosGuardados();
                StartActivity(typeof(ListaPratos));
            };

            var gobottom = FindViewById <ImageView>(Resource.Id.go);

            textView        = FindViewById <AutoCompleteTextView>(Resource.Id.autocomplete_prato);
            textView.Click += (sender, e) => {
                textView.Text = "";
            };
            var adapter = new ArrayAdapter <String>(this, Resource.Layout.ListItem, historico);

            textView.Adapter = adapter;
            gobottom.Click  += (sender, e) => {
                if (textView.Text.Length != 0)
                {
                    List <Prato> pratos;
                    if (switchpref.Checked == true)
                    {
                        pratos = Facade.PesquisaPrato(textView.Text, true);
                    }
                    else
                    {
                        pratos = Facade.PesquisaPrato(textView.Text, false);
                    }
                    if (pratos.Count == 0)
                    {
                        textToSpeech.Speak("Não encontrei " + textView.Text, QueueMode.Flush, null, null);
                    }
                    else
                    {
                        ListaPratos.pratoList = pratos;
                        ListaPratos.pesquisa  = textView.Text;
                        StartActivity(typeof(ListaPratos));
                    }
                }
            };

            recButton        = FindViewById <ImageView>(Resource.Id.rec);
            recButton.Click += delegate {
                var voiceIntent = new Intent(RecognizerIntent.ActionRecognizeSpeech);
                voiceIntent.PutExtra(RecognizerIntent.ExtraLanguageModel, "pr-BR");
                voiceIntent.PutExtra(RecognizerIntent.ExtraPrompt, "Fale agora");
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputPossiblyCompleteSilenceLengthMillis, 1500);
                voiceIntent.PutExtra(RecognizerIntent.ExtraSpeechInputMinimumLengthMillis, 15000);
                voiceIntent.PutExtra(RecognizerIntent.ExtraMaxResults, 1);
                StartActivityForResult(voiceIntent, VOICE);
            };
        }
Exemple #36
0
        protected async override void OnCreate(Bundle savedInstanceState)
        {
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense("OTg5ODlAMzEzNzJlMzEyZTMwUG5ONWFZZmdORDJldFd2ZUFIM0QzVWxjWWdGSFlkWW9TMTBZTytvbElzND0=");


            ISharedPreferences       prefs  = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            ISharedPreferencesEditor editor = prefs.Edit();

            if (prefs.GetString("locale", "") == "")
            {
                editor.PutString("locale", "en");
                editor.Apply();
            }
            string loc    = prefs.GetString("locale", "");
            var    locale = new Java.Util.Locale(loc);

            Java.Util.Locale.Default = locale;

            var config = new Android.Content.Res.Configuration {
                Locale = locale
            };

#pragma warning disable CS0618 // Type or member is obsolete
            BaseContext.Resources.UpdateConfiguration(config, metrics: BaseContext.Resources.DisplayMetrics);
#pragma warning restore CS0618 // Type or member is obsolete

            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.activity_main);
            Android.Support.V7.Widget.Toolbar toolbar = FindViewById <Android.Support.V7.Widget.Toolbar>(Resource.Id.toolbar);
            SetSupportActionBar(toolbar);

            FloatingActionButton fab = FindViewById <FloatingActionButton>(Resource.Id.fab);
            fab.Click += FabOnClick;

            //ObservableCollection<Client> lst =  await apiClient.GetClientsListAsync();

            DrawerLayout          drawer = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            ActionBarDrawerToggle toggle = new ActionBarDrawerToggle(this, drawer, toolbar, Resource.String.navigation_drawer_open, Resource.String.navigation_drawer_close);
            drawer.AddDrawerListener(toggle);
            toggle.SyncState();

            NavigationView navigationView = FindViewById <NavigationView>(Resource.Id.nav_view);
            navigationView.SetNavigationItemSelectedListener(this);

            //Button loginSendButton = FindViewById<Button>(Resource.Id.loginSendButton);

            //loginSendButton.Click += async (s, arg) =>
            //{
            //    CredentialsViewModel credentialViewModel = new CredentialsViewModel();

            //    var loginEditText = FindViewById<EditText>(Resource.Id.loginEditText);
            //    credentialViewModel.UserName = loginEditText.Text;

            //    var passwordEditText = FindViewById<EditText>(Resource.Id.passwordEditText);
            //    credentialViewModel.Password = passwordEditText.Text;

            //    apiClient = new APIClient();

            //    string token = await apiClient.Post2Async(credentialViewModel);

            //    ISharedPreferences prefs = PreferenceManager.GetDefaultSharedPreferences(Android.App.Application.Context);
            //    ISharedPreferencesEditor editor = prefs.Edit();
            //    editor.PutString("auth_token", token);
            //    editor.Apply();

            //    // var intent = new Intent(this, typeof(HomeActivity));
            //    //StartActivity(intent);
            //    TextView loginTextView = FindViewById<TextView>(Resource.Id.loginTextView);
            //    loginTextView.Text = token;


            //};
        }
Exemple #37
0
 /// <summary>
 /// Default ctor
 /// </summary>
 private CultureInfo(Locale locale, bool isInvariant = false)
 {
     this._locale    = locale;
     _numberFormat   = new LazyAndWeak <NumberFormatInfo>(() => new NumberFormatInfo(locale));
     _dateTimeFormat = new LazyAndWeak <DateTimeFormatInfo>(() => new DateTimeFormatInfo(locale, isInvariant));
 }