async Task Speak(CancellationToken cancelToken)
        {
            if (string.IsNullOrWhiteSpace(text))
            {
                return;
            }

            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;
            }
        }
 public void setLocale(Java.Util.Locale locale)
 {
     if (locale == null)
     {
         throw new IllegalArgumentException("Locale cannot be null");
     }
     this.locale = locale;
 }
        private void CultureLayout()
        {
            /***********
            **Culture**
            ***********/
            culturetxt          = new TextView(context);
            culturetxt.TextSize = 20;
            culturetxt.Text     = "Culture";

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

            cultureList.Add("Chinese");
            cultureList.Add("Spanish");
            cultureList.Add("English");
            cultureList.Add("French");

            //Data Adapter
            dataAdapter = new ArrayAdapter <String>(context, Android.Resource.Layout.SimpleSpinnerItem, cultureList);
            dataAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            //Culture Spinner
            cultureSpinner         = new Spinner(context, SpinnerMode.Dialog);
            cultureSpinner.Adapter = dataAdapter;

            //Culture Item Selected Listener
            cultureSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                String selectedItem = dataAdapter.GetItem(e.Position);
                if (selectedItem.Equals("Chinese"))
                {
                    localinfo = Java.Util.Locale.China; //new Java.Util.Locale("en","US");
                }

                if (selectedItem.Equals("Spanish"))
                {
                    localinfo = new Java.Util.Locale("es", "AR");
                }

                if (selectedItem.Equals("English"))
                {
                    localinfo = Java.Util.Locale.Us;
                }

                if (selectedItem.Equals("French"))
                {
                    localinfo = Java.Util.Locale.France;
                }
            };

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

            //Layout Params
            layoutParams1 = new LinearLayout.LayoutParams(width * 2, 5);
            layoutParams1.SetMargins(0, 20, 0, 0);
        }
Exemplo n.º 4
0
            public ScientificFormat(string format, Java.Util.Locale locale)
            {
                DecimalFormatSymbols symbols = new DecimalFormatSymbols(locale)
                {
                    Infinity = "Infinity"
                };

                _format = new DecimalFormat(format, symbols);
            }
Exemplo n.º 5
0
        public static string VoiceFromLocale(Java.Util.Locale locale)
        {
            string voice = Locale2String(locale);

            voice = AdjustVoiceString(voice);

            Console.WriteLine("--> VoiceFromLocale: {0} --> {1}", locale, voice);
            return(voice);
        }
        public void Dispose()
        {
            if (calendar != null)
            {
                calendar.Dispose();
                calendar = null;
            }

            if (mainView != null)
            {
                mainView.Dispose();
                mainView = null;
            }

            if (culturetxt != null)
            {
                culturetxt.Dispose();
                culturetxt = null;
            }

            if (cultureSpinner != null)
            {
                cultureSpinner.Dispose();
                cultureSpinner = null;
            }

            if (layoutParams1 != null)
            {
                layoutParams1.Dispose();
                layoutParams1 = null;
            }

            if (separate != null)
            {
                separate.Dispose();
                separate = null;
            }

            if (propertylayout != null)
            {
                propertylayout.Dispose();
                propertylayout = null;
            }

            if (dataAdapter != null)
            {
                dataAdapter.Dispose();
                dataAdapter = null;
            }

            if (localinfo != null)
            {
                localinfo.Dispose();
                localinfo = null;
            }
        }
Exemplo n.º 7
0
        protected override async void OnCreate(Bundle bundle)
        {
            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(bundle);
            SetContentView(Resource.Layout.activity_sceduler);

            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();
            schedulerCollection = await apiClient.GetScheduleAsync(1);

            schedulerList = schedulerCollection.OrderBy(x => x.Start_date).ToList();

            CreateNotificationChannel();

            schedule = new SfSchedule(this);
            CreateAppointments();
            schedule.ItemsSource  = Orders;
            schedule.ScheduleView = ScheduleView.WeekView;
            schedule.CellTapped  += schedule_ScheduleCellTapped;
            LinearLayout linearLayout = FindViewById <LinearLayout>(Resource.Id.scheduler_p);
            linearLayout.AddView(schedule);
            PushNotif();
        }
        protected override void OnCreate(Bundle bundle)
        {
            //Locale locale = new Locale("ar");


            var languageIso = "ar";
            var locale      = new Java.Util.Locale(languageIso);// languageIso is locale string

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

            BaseContext.Resources.UpdateConfiguration(config, BaseContext.Resources.DisplayMetrics);


            base.OnCreate(bundle);

            SetContentView(Resource.Layout.Main);



            fa = this;

            int currentapiVersion = (int)(Build.VERSION.SdkInt);

            AppPreferences hh = new AppPreferences(this);



            if (currentapiVersion >= 19)
            {
                if (hh.getAccessKey("PREFERENCE_WEBVIEW_TYPE", "null").Equals("null"))
                {
                    getdiag(hh);
                }
                else
                {
                    if (hh.getAccessKey("PREFERENCE_WEBVIEW_TYPE", "null").Equals("notCross"))
                    {
                        StartActivity(new Intent(Application.Context, typeof(WvActivity)).AddFlags(ActivityFlags.NoAnimation));
                    }
                    else
                    {
                        StartActivity(new Intent(Application.Context, typeof(CrossActivity)).AddFlags(ActivityFlags.NoAnimation));
                    }
                }
            }
            else
            {
                StartActivity(new Intent(Application.Context, typeof(CrossActivity)).AddFlags(ActivityFlags.NoAnimation));
            }
        }
Exemplo n.º 9
0
        public static string Locale2String(Java.Util.Locale locale)
        {
            string voice = "";

            if (Android.OS.Build.VERSION.SdkInt >= Android.OS.BuildVersionCodes.Lollipop)
            {
                voice = locale.ToLanguageTag();
            }
            else // Older Android version (< 5.0)
            {
                voice = locale.ToString();
            }

            return(voice.Replace('-', '_').Replace("__", "_"));
        }
Exemplo n.º 10
0
        public override bool OnOptionsItemSelected(IMenuItem item)
        {
            int id = item.ItemId;

            if (id == Resource.Id.menu_save)
            {
                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_common_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));
        }
Exemplo n.º 11
0
        private static DateFormatResult CreateFormat(string format, IFormatProvider provider)
        {
            if (format == null || format.Length == 1)
            {
                var ret = GetStandardFormat(format == null ? 'G' : format[0], provider);
                if (ret != null)
                {
                    return(ret);
                }
            }

            bool   useInvariant, foundK, useUtc;
            string javaFormat = DateTimeFormatting.ToJavaFormatString(format, provider, DateTimeKind.Unspecified, false, out useInvariant, out foundK, out useUtc);

            Java.Util.Locale locale = useInvariant ? CultureInfo.InvariantCulture.Locale : provider.ToLocale();

            DateFormat formatter = new SimpleDateFormat(javaFormat, locale);

            return(new DateFormatResult(formatter, foundK, useUtc));
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.Layout_SpeechRecognizingActivity);
            // Create your application here
            Button btn_tts = (Button)FindViewById(Resource.Id.btn_start);

            spinLanguages = (Spinner)FindViewById(Resource.Id.spinLanguage);
            txt_input     = (EditText)FindViewById(Resource.Id.txt_input);
            textToSpeech  = new TextToSpeech(this, this, "com.google.android.tts");

            btn_tts.Click += async delegate {
                string txt = txt_input.Text;
                await StartTTS(txt);
            };
            spinLanguages.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) =>
            {
                lang = Java.Util.Locale.GetAvailableLocales().FirstOrDefault(t => t.DisplayLanguage == langAvailable[(int)e.Id]);
                SetLangTTs(lang);
            };
        }
Exemplo n.º 13
0
        protected override void OnCreate(Bundle bundle)
        {
            base.OnCreate(bundle);
            SetContentView(Resource.Layout.Main);
            rBundle = bundle;

            tgConnect = FindViewById <ToggleButton>(Resource.Id.toggleButton1);
            //Result = FindViewById<TextView>(Resource.Id.textView1);
            //videoView = FindViewById<VideoView> (Resource.Id.SampleVideoView);

            if (mTts == null)
            {
                mTts = new TextToSpeech(this, this);
                Locale l = new Java.Util.Locale("pt-BR");
                mTts.SetLanguage(l);
            }

            tgConnect.CheckedChange += tgConnect_HandleCheckedChange;
            // status do bluetooth

            CheckBt();
        }
Exemplo n.º 14
0
        private void CultureLayout(Context context)
        {
            //Culture Text
            TextView cultureLabel = new TextView(context);

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

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

            cultureList.Add("Chinese");
            cultureList.Add("Spanish");
            cultureList.Add("English");
            cultureList.Add("French");
            //Data Adapter
            dataAdapter = new ArrayAdapter <String>
                              (context, Android.Resource.Layout.SimpleSpinnerItem, cultureList);
            dataAdapter.SetDropDownViewResource
                (Android.Resource.Layout.SimpleSpinnerDropDownItem);

            //cultureSpinner
            cultureSpinner.Adapter = dataAdapter;
            cultureSpinner.SetSelection(cultureSpinnerPosition);

            //Culture Item Selected Listener
            cultureSpinner.ItemSelected += (object sender, AdapterView.ItemSelectedEventArgs e) => {
                String selectedItem = dataAdapter.GetItem(e.Position);
                cultureSpinnerPosition = e.Position;
                if (selectedItem.Equals("Chinese"))
                {
                    localinfo = Java.Util.Locale.China; //new Java.Util.Locale("en","US");
                }
                if (selectedItem.Equals("Spanish"))
                {
                    localinfo = new Java.Util.Locale("es", "AR");
                }
                if (selectedItem.Equals("English"))
                {
                    localinfo = Java.Util.Locale.Us;
                }
                if (selectedItem.Equals("French"))
                {
                    localinfo = Java.Util.Locale.France;
                }
                ApplyChanges();
            };

            //cultureLayout
            LinearLayout cultureLayout = new LinearLayout(context);

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

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

            spaceText2.LayoutParameters = new FrameLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, 60, GravityFlags.Center);
            proprtyOptionsLayout.AddView(spaceText2);

            TextView spaceLabel = new TextView(context);

            spaceLabel.LayoutParameters = new FrameLayout.LayoutParams((int)(totalWidth * 0.167), ViewGroup.LayoutParams.WrapContent);

            //layout1
            LinearLayout layout1 = new LinearLayout(context);

            layout1.Orientation = Android.Widget.Orientation.Horizontal;
            layout1.AddView(spaceLabel);
            layout1.AddView(proprtyOptionsLayout);

            //propertylayout
            propertylayout.AddView(topProperty);
            propertylayout.AddView(layout1);
        }
Exemplo n.º 15
0
 public void setLocale(Java.Util.Locale locale)
 {
     compactCalendarController.setLocale(locale);
     Invalidate();
 }
Exemplo n.º 16
0
        public static string CodeFromLocale(Java.Util.Locale locale)
        {
            string voice = VoiceFromLocale(locale);

            return(voice.Substring(0, 2));
        }
Exemplo n.º 17
0
 void SetLangTTs(Java.Util.Locale loc)
 {
     textToSpeech.SetLanguage(loc);
 }