Пример #1
0
 public static string GetDateFromDateTime(this DateTime?date, string dateFormat)
 {
     if (date != null)
     {
         DateTime    dateTime        = (DateTime)date;
         string      appLanguage     = LocalesService.GetLanguage();
         CultureInfo selectedCulture = CultureInfo.GetCultureInfo(appLanguage);
         // Due to a bug in C# string representation in nb culture, nn must be used
         CultureInfo defaultCulture          = CultureInfo.GetCultureInfo(Conf.DEFAULT_LANGUAGE);
         bool        shouldUseDefaultCulture = appLanguage == "ar" || appLanguage == "ur" || appLanguage == "ti" || appLanguage == "nb";
         string      dateString;
         DateTime    calenderDateTime = new DateTime(
             dateTime.Year,
             dateTime.Month,
             dateTime.Day,
             dateTime.Hour,
             dateTime.Minute,
             dateTime.Second,
             dateTime.Millisecond,
             new GregorianCalendar());
         dateString = calenderDateTime.ToString(dateFormat, shouldUseDefaultCulture ? defaultCulture : selectedCulture);
         return(dateString.Replace("-", "."));
     }
     else
     {
         return(string.Empty);
     }
 }
        public void GetLanguage_NotNullOrEmpty()
        {
            string language = LocalesService.GetLanguage();

            Assert.NotNull(language);
            Assert.NotEmpty(language);
        }
Пример #3
0
        private void SetLogoBasedOnAppLanguage()
        {
            string appLanguage = LocalesService.GetLanguage();

            AuthorityImageView.Image = appLanguage != null && appLanguage.ToLower() == "en"
                ? UIImage.FromBundle("logo_SFP_en")
                : UIImage.FromBundle("logo_SFP_da");
        }
Пример #4
0
        private void SetLogoBasedOnAppLanguage()
        {
            string appLanguage = LocalesService.GetLanguage();

            HealthAuthoritiesLogo.Image = appLanguage != null && appLanguage.ToLower() == "en"
                ? UIImage.FromBundle("HealthAuthoritiesLogo_En")
                : UIImage.FromBundle("HealthAuthoritiesLogo");
        }
Пример #5
0
        private void SetLogoBasedOnAppLanguage()
        {
            View   logo        = FindViewById <View>(Resource.Id.message_logo);
            string appLanguage = LocalesService.GetLanguage();

            logo?.SetBackgroundResource(appLanguage != null && appLanguage.ToLower() == "en"
                ? Resource.Drawable.patient_logo_en
                : Resource.Drawable.patient_logo_da);
        }
        public void GetLanguage_SupportedCulture_ReturnsCorrect(string culture)
        {
            CultureInfo initialCulture = CultureInfo.CurrentCulture;

            CultureInfo.CurrentCulture = new CultureInfo(culture);

            string language = LocalesService.GetLanguage();

            Assert.Equal(CultureInfo.CurrentCulture.TwoLetterISOLanguageName, language);

            CultureInfo.CurrentCulture = initialCulture;
        }
        public void GetLanguage_NotSupportedCulture_ReturnsDefault(string culture)
        {
            CultureInfo initialCulture = CultureInfo.CurrentCulture;

            CultureInfo.CurrentCulture = new CultureInfo(culture);

            string language = LocalesService.GetLanguage();

            Assert.Equal(Conf.DEFAULT_LANGUAGE, language);

            CultureInfo.CurrentCulture = initialCulture;
        }
Пример #8
0
        public string GetName()
        {
            string language = LocalesService.GetLanguage();

            switch (language)
            {
            case "nb":
                return(Name_NB);

            case "nn":
                return(Name_NN);

            case "en":
                return(Name_EN);

            default:
                return(Name_EN);
            }
        }
Пример #9
0
        private void Init()
        {
            Button backButton = FindViewById <Button>(Resource.Id.arrow_back_general);

            backButton.ContentDescription = SETTINGS_CHILD_PAGE_ACCESSIBILITY_BACK_BUTTON;

            TextView titleField       = FindViewById <TextView>(Resource.Id.settings_general_title);
            TextView explanationOne   = FindViewById <TextView>(Resource.Id.settings_general_explanation);
            TextView explanationTwo   = FindViewById <TextView>(Resource.Id.settings_general_explanation_two);
            TextView mobileDataHeader = FindViewById <TextView>(Resource.Id.settings_general_mobile_data_header);
            TextView mobileDataDesc   = FindViewById <TextView>(Resource.Id.settings_general_mobile_data_desc);
            TextView languageHeader   = FindViewById <TextView>(Resource.Id.settings_general_select_lang_header);
            TextView languageDesc     = FindViewById <TextView>(Resource.Id.settings_general_select_lang_desc_one);
            TextView languageLink     = FindViewById <TextView>(Resource.Id.settings_general_link);

            TextView linkLayout = FindViewById <TextView>(Resource.Id.settings_general_link);

            titleField.Text                 = SETTINGS_GENERAL_TITLE;
            explanationOne.Text             = SETTINGS_GENERAL_EXPLANATION_ONE;
            explanationTwo.Text             = SETTINGS_GENERAL_EXPLANATION_TWO;
            mobileDataHeader.Text           = SETTINGS_GENERAL_MOBILE_DATA_HEADER;
            mobileDataDesc.Text             = SETTINGS_GENERAL_MOBILE_DATA_DESC;
            languageHeader.Text             = SETTINGS_GENERAL_CHOOSE_LANGUAGE_HEADER;
            languageDesc.Text               = SETTINGS_GENERAL_RESTART_REQUIRED_TEXT;
            languageLink.Text               = SETTINGS_GENERAL_MORE_INFO_BUTTON_TEXT;
            languageLink.ContentDescription = SETTINGS_GENERAL_ACCESSIBILITY_MORE_INFO_BUTTON_TEXT;

            linkLayout.Click +=
                new StressUtils.SingleClick(
                    (o, args) => OpenSmitteStopLink()).Run;

            RadioGroup  radioGroup         = FindViewById <RadioGroup>(Resource.Id.settings_general_select_lang_radio_group);
            RadioButton englishRadioButton = FindViewById <RadioButton>(Resource.Id.settings_general_english);
            RadioButton bokmalRadioButton  = FindViewById <RadioButton>(Resource.Id.settings_general_bokmal);
            RadioButton nynorskRadioButton = FindViewById <RadioButton>(Resource.Id.settings_general_nynorsk);


            englishRadioButton.Text = SETTINGS_GENERAL_EN;
            bokmalRadioButton.Text  = SETTINGS_GENERAL_NB;
            nynorskRadioButton.Text = SETTINGS_GENERAL_NN;

            string appLanguage = LocalesService.GetLanguage();

            if (appLanguage == "en")
            {
                englishRadioButton.Checked = true;
            }
            else if (appLanguage == "nn")
            {
                nynorskRadioButton.Checked = true;
            }
            else
            {
                bokmalRadioButton.Checked = true;
            }

            radioGroup.SetOnCheckedChangeListener(new OnCheckedChangeListener(this));

            SwitchCompat switchButton = FindViewById <SwitchCompat>(Resource.Id.settings_general_switch);

            switchButton.Checked        = _viewModel.GetStoredCheckedState();
            switchButton.CheckedChange += OnCheckedChange;

            backButton.Click += new StressUtils.SingleClick((sender, args) => Finish()).Run;
        }
        private void Init()
        {
            ImageButton backButton = FindViewById <ImageButton>(Resource.Id.arrow_back_general);

            backButton.ContentDescription = BACK_BUTTON_ACCESSIBILITY_TEXT;

            TextView titleField       = FindViewById <TextView>(Resource.Id.settings_general_title);
            TextView explanationOne   = FindViewById <TextView>(Resource.Id.settings_general_explanation);
            TextView explanationTwo   = FindViewById <TextView>(Resource.Id.settings_general_explanation_two);
            TextView mobileDataHeader = FindViewById <TextView>(Resource.Id.settings_general_mobile_data_header);
            TextView mobileDataDesc   = FindViewById <TextView>(Resource.Id.settings_general_mobile_data_desc);
            TextView languageHeader   = FindViewById <TextView>(Resource.Id.settings_general_select_lang_header);
            TextView languageDesc     = FindViewById <TextView>(Resource.Id.settings_general_select_lang_desc_one);
            TextView languageLink     = FindViewById <TextView>(Resource.Id.settings_general_link);
            TextView linkLayout       = FindViewById <TextView>(Resource.Id.settings_general_link);

            titleField.Text                 = SETTINGS_GENERAL_TITLE;
            explanationOne.Text             = SETTINGS_GENERAL_EXPLANATION_ONE;
            explanationTwo.Text             = SETTINGS_GENERAL_EXPLANATION_TWO;
            mobileDataHeader.Text           = SETTINGS_GENERAL_MOBILE_DATA_HEADER;
            mobileDataDesc.Text             = SETTINGS_GENERAL_MOBILE_DATA_DESC;
            languageHeader.Text             = SETTINGS_GENERAL_CHOOSE_LANGUAGE_HEADER;
            languageDesc.Text               = SETTINGS_GENERAL_RESTART_REQUIRED_TEXT;
            languageLink.TextAlignment      = TextAlignment.ViewStart;
            languageLink.ContentDescription = SETTINGS_GENERAL_ACCESSIBILITY_MORE_INFO_BUTTON_TEXT;

            titleField.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());
            mobileDataHeader.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());
            languageHeader.SetAccessibilityDelegate(AccessibilityUtils.GetHeadingAccessibilityDelegate());

            languageLink.TextFormatted  = HtmlCompat.FromHtml($"<a href=\"{SETTINGS_GENERAL_MORE_INFO_LINK}\">{SETTINGS_GENERAL_MORE_INFO_BUTTON_TEXT}</a>", HtmlCompat.FromHtmlModeLegacy);
            languageLink.MovementMethod = new Android.Text.Method.LinkMovementMethod();

            RadioGroup  radioGroup            = FindViewById <RadioGroup>(Resource.Id.settings_general_select_lang_radio_group);
            RadioButton englishRadioButton    = FindViewById <RadioButton>(Resource.Id.settings_general_english);
            RadioButton bokmalRadioButton     = FindViewById <RadioButton>(Resource.Id.settings_general_bokmal);
            RadioButton nynorskRadioButton    = FindViewById <RadioButton>(Resource.Id.settings_general_nynorsk);
            RadioButton polishRadioButton     = FindViewById <RadioButton>(Resource.Id.settings_general_polish);
            RadioButton somaliRadioButton     = FindViewById <RadioButton>(Resource.Id.settings_general_somali);
            RadioButton tigrinyaRadioButton   = FindViewById <RadioButton>(Resource.Id.settings_general_tigrinya);
            RadioButton arabicRadioButton     = FindViewById <RadioButton>(Resource.Id.settings_general_arabic);
            RadioButton urduRadioButton       = FindViewById <RadioButton>(Resource.Id.settings_general_urdu);
            RadioButton lithuanianRadioButton = FindViewById <RadioButton>(Resource.Id.settings_general_lithuanian);



            englishRadioButton.Text    = SETTINGS_GENERAL_EN;
            bokmalRadioButton.Text     = SETTINGS_GENERAL_NB;
            nynorskRadioButton.Text    = SETTINGS_GENERAL_NN;
            polishRadioButton.Text     = SETTINGS_GENERAL_PL;
            somaliRadioButton.Text     = SETTINGS_GENERAL_SO;
            tigrinyaRadioButton.Text   = SETTINGS_GENERAL_TI;
            arabicRadioButton.Text     = SETTINGS_GENERAL_AR;
            urduRadioButton.Text       = SETTINGS_GENERAL_UR;
            lithuanianRadioButton.Text = SETTINGS_GENERAL_LT;

            string appLanguage = LocalesService.GetLanguage();

            switch (appLanguage)
            {
            case "en":
                englishRadioButton.Checked = true;
                break;

            case "nn":
                nynorskRadioButton.Checked = true;
                break;

            case "pl":
                polishRadioButton.Checked = true;
                break;

            case "so":
                somaliRadioButton.Checked = true;
                break;

            case "ti":
                tigrinyaRadioButton.Checked = true;
                break;

            case "ar":
                arabicRadioButton.Checked = true;
                break;

            case "ur":
                urduRadioButton.Checked = true;
                break;

            case "lt":
                lithuanianRadioButton.Checked = true;
                break;

            default:
                bokmalRadioButton.Checked = true;
                break;
            }

            radioGroup.SetOnCheckedChangeListener(new OnCheckedChangeListener(this));

            SwitchCompat switchButton = FindViewById <SwitchCompat>(Resource.Id.settings_general_switch);

            switchButton.Checked        = _viewModel.GetStoredCheckedState();
            switchButton.CheckedChange += OnCheckedChange;

            backButton.Click += new StressUtils.SingleClick((sender, args) => Finish()).Run;

            // Layout direction logic
            View rootView = Window.DecorView.RootView;

            rootView.LayoutDirection = LayoutUtils.GetLayoutDirection();
            backButton.SetBackgroundResource(LayoutUtils.GetBackArrow());
            languageLink.SetCompoundDrawablesRelativeWithIntrinsicBounds(null, null, ContextCompat.GetDrawable(this, LayoutUtils.GetForwardArrow()), null);
        }