예제 #1
0
        private async void LoadLanguages()
        {
            RelativeLayout loadingLayout = FindViewById <RelativeLayout>(Resource.Id.loadingLayout);

            loadingLayout.Visibility = ViewStates.Visible;

            languageChoices = await LanguageChoiceManager.GetLanguageChoices();

            if (languageChoices == null || languageChoices.Count == 0)
            {
                new Android.Support.V7.App.AlertDialog.Builder(this)
                .SetTitle(StringResources.common_comms_error)
                .SetMessage(StringResources.common_comms_error_server)
                .SetPositiveButton(StringResources.common_comms_retry, (a, b) =>
                {
                    LoadLanguages();
                })
                .SetNegativeButton(StringResources.common_comms_cancel, (a, b) => { Finish(); })
                .Show();
            }
            else
            {
                loadingLayout.Visibility = ViewStates.Gone;

                List <string> langNames = languageChoices.Select(lang => lang.Endonym).ToList();
                langNames.Insert(0, StringResources.common_ui_forms_language_default);

                ArrayAdapter spinnerAdapter = new ArrayAdapter(this, Resource.Layout.spinner_row, langNames);
                languageSpinner.Adapter = spinnerAdapter;
            }
        }
예제 #2
0
        private async Task GetLangData()
        {
            SupportedLanguages = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();

            // First time users logs in, set the language to their culture if we support it, or English.
            if (Session.ActiveUser.AppLang == 0)
            {
                var currentMobileLang = Localise.GetCurrentCultureInfo().TwoLetterISOLanguageName;
                var isSupportedLang   = SupportedLanguages.FirstOrDefault((lang) => lang.Code == currentMobileLang);
                Session.ActiveUser.AppLang = isSupportedLang != null ? isSupportedLang.Id : 1;
                // This will save the choice for future: reopening app, other activities, etc.
                Queries.SaveActiveUser();
            }

            var found = SupportedLanguages.Find((lang) => lang.Id == Session.ActiveUser.AppLang);

            StringResources.Culture = new CultureInfo(found.Code);
            Localise.SetLocale(StringResources.Culture);

            SetLayoutDirection();

            nav = FindViewById <BottomNavigationView>(Resource.Id.bottom_navigation);
            LoadNavigationTitles();
            nav.NavigationItemSelected += NavigationItemSelected;

            LanguageChoiceManager.RefreshIfNeeded();
        }
예제 #3
0
 public async override void ViewDidLoad()
 {
     base.ViewDidLoad();
     SupportedLanguages = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();
     Title = StringResources.common_menu_settings;
     TabBarController.Title   = StringResources.common_menu_settings;
     SettingsTableView.Source = new SettingsTableViewSource(ReCreateSettings(), this, RowSelected);
     // Required to show the data ...
     SettingsTableView.ReloadData();
 }
예제 #4
0
        private async void LoadLanguages()
        {
            List <LanguageChoice> languages = await LanguageChoiceManager.GetLanguageChoices();

            if (languages != null && languages.Count > 0)
            {
                pickerModel          = new LanguagePickerViewModel(languages, PickerSelected);
                LanguagePicker.Model = pickerModel;
                pickerModel.SelectById(LanguagePicker, Session.ActiveUser.Lang);
            }
        }
        private async void LoadLanguages()
        {
            List <LanguageChoice> languages = await LanguageChoiceManager.GetLanguageChoices();

            if (languages != null && languages.Count > 0)
            {
                pickerModel          = new LanguagePickerViewModel(languages);
                LanguagePicker.Model = pickerModel;
                LoadingOverlay.Alpha = 0;
            }
        }
예제 #6
0
        public override async void OnCreatePreferences(Bundle savedInstanceState, string rootKey)
        {
            AddPreferencesFromResource(Resource.Xml.preferences);

            allLangs = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();

            string[] langIds   = allLangs.Select((lang) => lang.Id.ToString()).ToArray();
            string[] langNames = allLangs.Select((lang) => lang.Endonym).ToArray();

            CultureInfo currentCulture = StringResources.Culture ?? Localise.GetCurrentCultureInfo();

            int appCurrentLangVal = allLangs.FindIndex((obj) => obj.Code == currentCulture.TwoLetterISOLanguageName);

            if (appCurrentLangVal == -1)
            {
                appCurrentLangVal = 1;
            }

            ListPreference appLangPref = (ListPreference)FindPreference("appLanguagePref");

            appLangPref.Title = StringResources.settings_chooseAppLanguage;
            appLangPref.SetEntries(langNames);
            appLangPref.SetEntryValues(langIds);
            appLangPref.SetValueIndex(appCurrentLangVal);
            appLangPref.PreferenceChange += AppLangPrefChanged;

            int convoDefaultVal = allLangs.FindIndex((obj) => obj.Id == Session.ActiveUser.Lang);

            ListPreference convoLangPref = (ListPreference)FindPreference("convoLanguagePref");

            convoLangPref.Title = StringResources.settings_chooseConvoLanguage;
            convoLangPref.SetEntries(langNames);
            convoLangPref.SetEntryValues(langIds);
            convoLangPref.SetValueIndex(convoDefaultVal);
            convoLangPref.PreferenceChange += ConvoLangPrefChanged;

            Preference logOutPref = FindPreference("logOutPref");

            logOutPref.Title            = StringResources.settings_logout;
            logOutPref.PreferenceClick += LogOutPref_PreferenceClick;
        }
예제 #7
0
        public async override void ViewDidLoad()
        {
            base.ViewDidLoad();
            var SupportedLanguages = (await LanguageChoiceManager.GetLanguageChoices()).OrderBy((lang) => lang.Code).ToList();

            TableView.RegisterNibForCellReuse(ProjectTableViewHeader.Nib, ProjectTableViewHeader.CellID);
            TableView.RowHeight          = UITableView.AutomaticDimension;
            TableView.EstimatedRowHeight = 250;

            if (Session.ActiveUser == null)
            {
                var email   = NSUserDefaults.StandardUserDefaults.StringForKey("username");
                var user    = Queries.UserByEmail(email);
                var _tokens = NSUserDefaults.StandardUserDefaults.StringForKey("tokens");
                var tokens  = JsonConvert.DeserializeObject <JWToken>(_tokens);
                Queries.SetActiveUser(new DataUserTokens {
                    User = user, Tokens = tokens
                });
                Firebase.Analytics.Analytics.SetUserId(Session.ActiveUser.Id.ToString());
                // If the user has set the preference or is was determined below, we want to apply it
                Session.ActiveUser.AppLang = user.AppLang;
            }

            var currentMobileLang = Localize.GetCurrentCultureInfo().TwoLetterISOLanguageName;
            var isSupportedLang   = SupportedLanguages.FindIndex((lang) => lang.Code == currentMobileLang);

            // If the user has logged in for the first time, then
            // and their mobile language is one we support, then we must choose that.
            if (isSupportedLang != -1 && Session.ActiveUser.AppLang == 0)
            {
                Session.ActiveUser.AppLang = SupportedLanguages.First((lang) => lang.Code == currentMobileLang).Id;
            }
            // Otherwise, the user who logged in, may not have their phone in a lang we do not support
            else if (isSupportedLang == -1 && Session.ActiveUser.AppLang == 0)
            {
                Session.ActiveUser.AppLang = 1;
            }
            Queries.SaveActiveUser();

            var languages = SupportedLanguages.FirstOrDefault((lang) => lang.Id == Session.ActiveUser.AppLang);

            StringResources.Culture = new CultureInfo(languages.Code);
            Localize.SetLayoutDirectionByPreference();

            SetStringResources();

            projects = Queries.AllProjects();

            refreshControl = new UIRefreshControl
            {
                AttributedTitle = new NSAttributedString(StringResources.projects_ui_fetching),
                TintColor       = UIColor.FromCGColor(Application.MainColour)
            };

            refreshControl.AddTarget(delegate
            {
                Logger.LOG_EVENT_WITH_ACTION("SWIPE_REFRESH", projects.Count.ToString(), "PROJECT_COUNT");
                var suppress = RefreshData();
            }, UIControlEvent.AllEvents);

            ProjectsTableViewSource source = new ProjectsTableViewSource(projects, LaunchProject, HandleExpansion);

            TableView.Source         = source;
            TableView.RefreshControl = refreshControl;
            TableView.ReloadData();

            var suppressAsync = RefreshData();

            SendFCMToken();
        }