public override View GetGroupView(int groupPosition, bool isExpanded, View convertView, ViewGroup parent) { ProjectParentViewHolder viewHolder = (ProjectParentViewHolder)convertView?.Tag; if (viewHolder == null) { viewHolder = new ProjectParentViewHolder(); convertView = LayoutInflater.From(parent.Context) .Inflate(Resource.Layout.project_headercell, parent, false); viewHolder.Title = convertView.FindViewById <TextView>(Resource.Id.project_title); viewHolder.Image = convertView.FindViewById <ImageViewAsync>(Resource.Id.project_icon); convertView.Tag = viewHolder; } var project = projects[groupPosition]; viewHolder.Title.Text = LanguageChoiceManager.ContentByLanguage(project).Title; ImageService.Instance.LoadCompiledResource("ic_launcher").Transform(new CircleTransformation()).Into(viewHolder.Image); if (!string.IsNullOrWhiteSpace(project.image)) { ImageService.Instance.LoadUrl(project.image).Transform(new CircleTransformation()).Into(viewHolder.Image); } return(convertView); }
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; } }
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(); }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = StringResources.consent_research_toolbar_title; int SelectedProjectID = Convert.ToInt32(NSUserDefaults.StandardUserDefaults.IntForKey("SelectedProjectID")); var SelectedProject = Queries.ProjectById(SelectedProjectID); var contentOh = LanguageChoiceManager.ContentByLanguage(SelectedProject); var IsOrg = SelectedProject.Organisation.Name.ToLower() == "individual"; var org = IsOrg ? SelectedProject.Creator.Name : SelectedProject.Organisation.Name; var content = string.Format(StringResources.consent_research_body, org, contentOh.Title); ResearchConsentDesc.Text = content; ResearchConsentFormDetails.Text = StringResources.consent_research_form; MoreDetailsButton.SetTitle(StringResources.consent_research_details_button, UIControlState.Normal); ResearchConsentSubmit.SetTitle(StringResources.consent_research_submit, UIControlState.Normal); ResearchConsentSubmit.Layer.BorderWidth = 1.0f; ResearchConsentSubmit.Layer.BorderColor = Application.MainColour; ResearchConsentSubmit.Enabled = false; MoreDetailsButton.Layer.BorderWidth = ResearchConsentSubmit.Layer.BorderWidth; MoreDetailsButton.Layer.BorderColor = ResearchConsentSubmit.Layer.BorderColor; MoreDetailsButton.TouchUpInside += (sender, e) => { UIApplication.SharedApplication.OpenUrl(new NSUrl(Config.ABOUT_DATA_PAGE)); }; ResearchConsentFormSwitch.ValueChanged += delegate { ResearchConsentSubmit.Enabled = ResearchConsentFormSwitch.On; }; }
public override UITableViewCell GetCell(UITableView tableView, NSIndexPath indexPath) { var project = Rows[indexPath.Section]; var content = LanguageChoiceManager.ContentByLanguage(project); if (indexPath.Row == 0) { // Description cell var descCell = (ProjectTableViewDescriptionCell)tableView.DequeueReusableCell( ProjectTableViewDescriptionCell.CellID, indexPath); descCell.UpdateContent(content.Description); return(descCell); } int promptInd = indexPath.Row - 1; var activeTopics = content.Topics.Where((t) => t.IsActive).ToList(); if (promptInd < activeTopics.Count) { // A prompt var promptCell = (ProjectTableViewPromptCell)tableView.DequeueReusableCell( ProjectTableViewPromptCell.CellID, indexPath); promptCell.UpdateContent(activeTopics[promptInd].Text); return(promptCell); } else { // last cell is the 'Get Started' button var buttonCell = (ProjectTableViewButtonCell)tableView.DequeueReusableCell(ProjectTableViewButtonCell.CellID, indexPath); buttonCell.UpdateContent(project.ID, StartProject); return(buttonCell); } }
public override nint RowsInSection(UITableView tableview, nint section) { var project = Rows[(int)section]; var content = LanguageChoiceManager.ContentByLanguage(project); var activeTopics = content.Topics.Where((t) => t.IsActive).ToList(); return((project.IsExpanded) ? activeTopics.Count + 2 : 0); }
private void LaunchProject(Project chosenProj) { var content = LanguageChoiceManager.ContentByLanguage(chosenProj); Logger.LOG_EVENT_WITH_ACTION("PROJECT_SELECTED", content.Title, "PROJECT"); NSUserDefaults.StandardUserDefaults.SetInt(chosenProj.ID, "SelectedProjectID"); PerformSegue("OpenProjectSegue", this); }
private void LOG_SELECTED_PROJECT(int position) { var bundle = new Bundle(); var project = LanguageChoiceManager.ContentByLanguage(_projects[position]); bundle.PutString("PROJECT", project.Title); bundle.PutString("USER", Session.ActiveUser.Email); firebaseAnalytics.LogEvent("PROJECT_SELECTED", bundle); }
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(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Localise.SetLayoutDirectionByPreference(this); SetContentView(Resource.Layout.consent_research); SupportActionBar.Title = StringResources.consent_research_toolbar_title; SupportActionBar.SetDisplayHomeAsUpEnabled(true); var researchConsentTitle = FindViewById <TextView>(Resource.Id.researchConsentTitle); researchConsentTitle.Text = StringResources.consent_research_title; var _prefs = Android.Preferences.PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); var SelectedProjectID = _prefs.GetInt("SelectedProjectID", 0); var selectedProject = Queries.ProjectById(SelectedProjectID); // If there is no organisation then the project was created by an individual. var IsOrg = selectedProject.Organisation.Name.ToLower() == "individual"; var org = IsOrg ? selectedProject.Creator.Name : selectedProject.Organisation.Name; var researchConsentDesc = FindViewById <TextView>(Resource.Id.researchConsentDesc); var title = LanguageChoiceManager.ContentByLanguage(selectedProject).Title; researchConsentDesc.Text = string.Format(StringResources.consent_research_body, org, title); var researchConsentForm = FindViewById <TextView>(Resource.Id.researchConsentForm); researchConsentForm.Text = StringResources.consent_research_form; AppCompatButton moreInfoBtn = FindViewById <AppCompatButton>(Resource.Id.consentInfoButton); moreInfoBtn.Text = StringResources.consent_research_details_button; moreInfoBtn.Click += ViewConsentDetails; var submit = FindViewById <AppCompatButton>(Resource.Id.researchConsentSubmit); submit.Text = StringResources.consent_research_submit; submit.Enabled = false; submit.Click += (s, e) => { StartActivity(new Intent(this, typeof(ConversationConsent))); }; var isConsented = FindViewById <CheckBox>(Resource.Id.researchConsentProvided); isConsented.Click += (s, e) => { submit.Enabled = isConsented.Checked; }; var form = FindViewById <LinearLayout>(Resource.Id.researchConsentFormLayout); form.Click += (s, e) => { isConsented.Toggle(); submit.Enabled = isConsented.Checked; }; }
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; } }
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); } }
public override async void OnBindViewHolder(RecyclerView.ViewHolder holder, int position) { var mholder = holder as SessionViewHolder; var session = Sessions[position]; mholder.UploadProgress.Visibility = session.IsUploading ? ViewStates.Visible : ViewStates.Gone; mholder.Participants.Text = BuildParticipantsNames(session.Participants); mholder.DateCreated.Text = session.CreatedAt.ToLocalTime().ToString("MM/dd, HH:mm", CultureInfo.InvariantCulture); mholder.Length.Text = Queries.FormatFromSeconds(session.Prompts[session.Prompts.Count - 1].End); mholder.ProjectTitle.Text = LanguageChoiceManager.ContentByLanguage(Queries.ProjectById(Sessions[position].ProjectID)).Title; }
public override View GetChildView(int groupPosition, int childPosition, bool isLastChild, View convertView, ViewGroup parent) { int viewType = GetChildType(groupPosition, childPosition); ProjectChildViewHolder viewHolder = (ProjectChildViewHolder)convertView?.Tag; if (viewHolder == null) { viewHolder = new ProjectChildViewHolder(); convertView = LayoutInflater.From(parent.Context).Inflate(Resource.Layout.project_descriptionCell, parent, false); viewHolder.DescriptionText = convertView.FindViewById <TextView>(Resource.Id.project_description); viewHolder.PromptLayout = convertView.FindViewById <LinearLayout>(Resource.Id.project_topics); viewHolder.Button = convertView.FindViewById <Button>(Resource.Id.project_startBtn); convertView.FindViewById <TextView>(Resource.Id.topics_tease).Text = StringResources.projects_ui_topics; convertView.Tag = viewHolder; } var content = LanguageChoiceManager.ContentByLanguage(projects[groupPosition]); viewHolder.DescriptionText.Text = content.Description; viewHolder.PromptLayout.RemoveAllViews(); // Content should be filtered to content.topics var activeTopics = content.Topics.Where((p) => p.IsActive).ToList(); foreach (var topic in activeTopics) { TextView textView = new TextView(context); LinearLayout.LayoutParams layoutParams = new LinearLayout.LayoutParams( ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent); layoutParams.SetMargins(0, 1, 0, 1); textView.LayoutParameters = layoutParams; textView.SetMinHeight(100); textView.SetPadding(15, 15, 15, 15); textView.SetBackgroundColor(Color.WhiteSmoke); textView.Gravity = GravityFlags.Center; textView.Text += topic.Text; viewHolder.PromptLayout.AddView(textView); } viewHolder.SetUpButton(OnProjectClick, groupPosition); return(convertView); }
protected override void OnCreate(Bundle savedInstanceState) { firebaseAnalytics = FirebaseAnalytics.GetInstance(ApplicationContext); base.OnCreate(savedInstanceState); Localise.SetLayoutDirectionByPreference(this); SetContentView(Resource.Layout.record); SupportActionBar.Title = StringResources.recording_ui_title; SupportActionBar.SetDisplayHomeAsUpEnabled(true); var instructionsHeader = FindViewById <TextView>(Resource.Id.recordInstructionsHeader); instructionsHeader.Text = StringResources.recording_ui_instructions_header; InterviewSessionID = Guid.NewGuid().ToString(); var _prefs = Android.Preferences.PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); ConsentType = _prefs.GetString("SESSION_CONSENT", ""); SelectedProjectID = _prefs.GetInt("SelectedProjectID", 0); langId = _prefs.GetInt("SESSION_LANG", 1); var selectedProject = Queries.ProjectById(SelectedProjectID); RecyclerView promptRecyclerView = FindViewById <RecyclerView>(Resource.Id.prompts); promptRecyclerView.SetLayoutManager(new GridLayoutManager(this, 1)); Content project = LanguageChoiceManager.ContentByLanguage(selectedProject, langId); List <Topic> activeTopics = project.Topics.Where((p) => p.IsActive).ToList(); themes = activeTopics; adapter = new TopicAdapter(themes); adapter.ProjectClicked += CheckRecPerm; promptRecyclerView.SetAdapter(adapter); record = FindViewById <FloatingActionButton>(Resource.Id.start); FindViewById <TextView>(Resource.Id.themeTitle).Text = project.Title; Color highlightColor = new Color(ContextCompat.GetColor(this, Resource.Color.colorControlHighlight)); ViewCompat.SetBackgroundTintList(record, Android.Content.Res.ColorStateList.ValueOf(highlightColor)); record.Enabled = false; timer = FindViewById <TextView>(Resource.Id.timer); timer.SetTextColor(highlightColor); record.Click += HandleRecordClick; }
public void UpdateContent(InterviewSession session) { var content = LanguageChoiceManager.ContentByLanguage(Queries.ProjectById(session.ProjectID)); SessionProjectTitle.Text = content.Title; SessionLength.Text = Queries.FormatFromSeconds(session.Prompts[session.Prompts.Count - 1].End); SessionParticipants.Text = BuildParticipantsNames(session.Participants); SessionCreateDate.Text = session.CreatedAt.ToString("MM/dd, HH:mm", CultureInfo.InvariantCulture); if (session.IsUploading) { SessionContainerView.BackgroundColor = UIColor.LightGray; SessionIsUploadedIndicator.StartAnimating(); } else { SessionContainerView.BackgroundColor = UIColor.White; SessionIsUploadedIndicator.StopAnimating(); } }
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; }
public void UpdateContent(Project project, Action <nint> tappedCallback, nint index) { TitleLabel.Text = LanguageChoiceManager.ContentByLanguage(project).Title; TappedCallback = tappedCallback; thisIndex = index; CGAffineTransform rotatedTrans = CGAffineTransform.MakeRotation(3.14159f * 90 / 180f); if (ArrowLabel.Transform != rotatedTrans && project.IsExpanded) { ArrowLabel.Transform = rotatedTrans; } else if (ArrowLabel.Transform == rotatedTrans && !project.IsExpanded) { ArrowLabel.Transform = CGAffineTransform.MakeIdentity(); } ImageService.Instance.LoadCompiledResource("Logo").Transform(new CircleTransformation()).Into(ProjectIcon); if (!string.IsNullOrWhiteSpace(project.image)) { ImageService.Instance.LoadUrl(project.image).Transform(new CircleTransformation()).Into(ProjectIcon); } }
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(); }
protected override void OnCreate(Bundle savedInstanceState) { base.OnCreate(savedInstanceState); Localise.SetLayoutDirectionByPreference(this); SetContentView(Resource.Layout.consent_conversation); SupportActionBar.Title = StringResources.consent_gabber_toolbar_title; SupportActionBar.SetDisplayHomeAsUpEnabled(true); ISharedPreferences _prefs = PreferenceManager.GetDefaultSharedPreferences(ApplicationContext); Project selectedProject = Queries.ProjectById(_prefs.GetInt("SelectedProjectID", 0)); FindViewById <TextView>(Resource.Id.GabberConsentDecisionTitle).Text = StringResources.consent_gabber_title_decision; FindViewById <TextView>(Resource.Id.GabberConsentDecisionDesc).Text = string.Format(StringResources.consent_gabber_body_decision, Config.PRINT_URL); FindViewById <TextView>(Resource.Id.chooseLanguageTitle).Text = StringResources.conversation_language_prompt; RadioButton consentTypePublic = FindViewById <RadioButton>(Resource.Id.GabberConsentTypePublic); consentTypePublic.Text = StringResources.consent_gabber_consent_type_public_brief; FindViewById <TextView>(Resource.Id.GabberConsentTypePublicFull).Text = StringResources.consent_gabber_consent_type_public_full; RadioButton consentTypeMembers = FindViewById <RadioButton>(Resource.Id.GabberConsentTypeMembers); var title = LanguageChoiceManager.ContentByLanguage(selectedProject).Title; consentTypeMembers.Text = string.Format(StringResources.consent_gabber_consent_type_members_brief, title); TextView consentTypeMembersFull = FindViewById <TextView>(Resource.Id.GabberConsentTypeMembersFull); consentTypeMembersFull.Text = string.Format(StringResources.consent_gabber_consent_type_members_full, selectedProject.Members.Count, (selectedProject.Members.Count > 1) ? StringResources.consent_gabber_consent_type_members_full_plural : StringResources.consent_gabber_consent_type_members_full_singular); if (selectedProject.IsPublic) { consentTypeMembers.Visibility = ViewStates.Gone; consentTypeMembersFull.Visibility = ViewStates.Gone; } var consentTypePrivate = FindViewById <RadioButton>(Resource.Id.GabberConsentTypePrivate); consentTypePrivate.Text = StringResources.consent_gabber_consent_type_private_brief; var consentTypePrivateFull = FindViewById <TextView>(Resource.Id.GabberConsentTypePrivateFull); var participants = BuildParticipants(Queries.SelectedParticipants().ToList()); consentTypePrivateFull.TextFormatted = Html.FromHtml(string.Format(StringResources.consent_gabber_consent_type_private_full, participants)); var isConsented = FindViewById <RadioGroup>(Resource.Id.GabberConsentProvided); submitButton = FindViewById <AppCompatButton>(Resource.Id.GabberConsentSubmit); submitButton.Text = StringResources.consent_gabber_submit; submitButton.Enabled = false; submitButton.Click += (s, e) => { var consent = ""; if (consentTypePublic.Checked) { consent = "public"; } if (consentTypeMembers.Checked) { consent = "members"; } if (consentTypePrivate.Checked) { consent = "private"; } // This is used then deleted when saving the recording session _prefs.Edit().PutString("SESSION_CONSENT", consent).Commit(); LanguageChoice chosenLang = languageChoices.FirstOrDefault((arg) => arg.Endonym == selectedLanguage); _prefs.Edit().PutInt("SESSION_LANG", chosenLang.Id).Commit(); StartActivity(new Intent(this, typeof(RecordStoryActivity))); }; isConsented.CheckedChange += (s, e) => { consentChecked = true; CheckIfCanSubmit(); }; languageSpinner = FindViewById <Spinner>(Resource.Id.chooseLanguageSpinner); languageSpinner.ItemSelected += LanguageSpinner_ItemSelected; LoadLanguages(); }
public override void ViewDidLoad() { Title = StringResources.recording_ui_title; TopicsInstructions.Text = StringResources.recording_ui_instructions_header; var es = new CoreGraphics.CGSize(UIScreen.MainScreen.Bounds.Width - 36, 70); (TopicsCollectionView.CollectionViewLayout as UICollectionViewFlowLayout).EstimatedItemSize = es; RequestAudioRecordPermission(); if (CheckAccess().Contains("denied")) { ConfigureMicrophoneAccessDialog(); return; } NavigationItem.LeftBarButtonItem = new UIBarButtonItem(UIImage.FromBundle("BackButton"), UIBarButtonItemStyle.Plain, (sender, args) => { if (AudioRecorder.IsRecording()) { var doDeleteRecording = UIAlertController.Create( StringResources.recording_ui_dialog_back_title, StringResources.recording_ui_dialog_back_body, UIAlertControllerStyle.Alert); doDeleteRecording.AddAction( UIAlertAction.Create( StringResources.recording_ui_dialog_back_negative, UIAlertActionStyle.Cancel, (_) => { } ) ); doDeleteRecording.AddAction( UIAlertAction.Create( StringResources.recording_ui_dialog_back_positive, UIAlertActionStyle.Default, (_) => { NavigationController.PopViewController(false); })); PresentViewController(doDeleteRecording, true, null); } NavigationController.PopViewController(false); }) { TintColor = UIColor.FromCGColor(Application.MainColour) }; // As we can record, enable it all. AudioRecorder = new AudioRecorder(); InterviewSessionID = Guid.NewGuid().ToString(); SelectedProjectID = Convert.ToInt32(NSUserDefaults.StandardUserDefaults.IntForKey("SelectedProjectID")); var lang = Convert.ToInt32(NSUserDefaults.StandardUserDefaults.IntForKey("SESSION_LANG")); var SelectedProject = LanguageChoiceManager.ContentByLanguage(Queries.ProjectById(SelectedProjectID), lang); var activeTopics = SelectedProject.Topics.Where((t) => t.IsActive).ToList(); ThemeTitleLabel.Text = SelectedProject.Title; Topics = activeTopics; TopicsCollectionView.Source = new TopicsCollectionViewSource { Rows = Topics, AddAnnotation = AddAnnotation }; }
public override void ViewDidLoad() { base.ViewDidLoad(); Title = StringResources.consent_gabber_toolbar_title; int SelectedProjectID = Convert.ToInt32(NSUserDefaults.StandardUserDefaults.IntForKey("SelectedProjectID")); var SelectedProject = Queries.ProjectById(SelectedProjectID); var content = LanguageChoiceManager.ContentByLanguage(SelectedProject); ConversationDecisionDes.Text = string.Format(StringResources.consent_gabber_body_decision, Config.PRINT_URL); ChooseLanguageTitle.Text = StringResources.conversation_language_prompt; List <User> participants = Queries.SelectedParticipants().ToList(); string inConversation = StringResources.consent_gabber_consent_type_private_full_you; for (int i = 0; i < participants.Count; i++) { User p = participants[i]; if (p.Id == Session.ActiveUser.Id) { continue; } inConversation += ", " + p.Name; } int inProject = SelectedProject.Members.Count; var membersContent = string.Format( StringResources.consent_gabber_consent_type_members_full, inProject, (inProject > 1) ? StringResources.consent_gabber_consent_type_members_full_plural : StringResources.consent_gabber_consent_type_members_full_singular); var privateContent = string.Format(StringResources.consent_gabber_consent_type_private_full, inConversation); var items = new List <Consent> { new Consent { Title = StringResources.consent_gabber_consent_type_public_brief, Subtitle = StringResources.consent_gabber_consent_type_public_full }, new Consent { Title = string.Format(StringResources.consent_gabber_consent_type_members_brief, content.Title), Subtitle = membersContent }, new Consent { Title = StringResources.consent_gabber_consent_type_private_brief, Subtitle = privateContent } }; // Only show members if the project is private if (SelectedProject.IsPublic) { items.RemoveAt(1); } var consentVSource = new ConsentViewSource(items); consentVSource.ConsentSelected += (int selectedIndex) => { var consentOptions = new string[] { "public", "members", "private" }; ConsentType = consentOptions[selectedIndex]; CheckSubmitEnabled(); }; ConversationConsentTableView.Source = consentVSource; ConversationConsentTableView.RowHeight = UITableView.AutomaticDimension; ConversationConsentTableView.EstimatedRowHeight = 86f; ConversationConsentSubmit.SetTitle(StringResources.consent_gabber_submit, UIControlState.Normal); ConversationConsentSubmit.Layer.BorderWidth = 1.0f; ConversationConsentSubmit.Layer.BorderColor = Application.MainColour; ConversationConsentSubmit.Enabled = false; ConversationConsentSubmit.TouchUpInside += delegate { NSUserDefaults.StandardUserDefaults.SetString(ConsentType, "SESSION_CONSENT"); NSUserDefaults.StandardUserDefaults.SetInt(pickerModel.GetChoice(LanguagePicker).Id, "SESSION_LANG"); }; LoadLanguages(); }
private async void Submit_Click(object sender, System.EventArgs e) { AppCompatEditText fname = FindViewById <AppCompatEditText>(Resource.Id.name); AppCompatEditText email = FindViewById <AppCompatEditText>(Resource.Id.email); AppCompatEditText passw = FindViewById <AppCompatEditText>(Resource.Id.password); AppCompatEditText confPass = FindViewById <AppCompatEditText>(Resource.Id.confirmPassword); if (string.IsNullOrWhiteSpace(fname.Text)) { fname.Error = StringResources.register_ui_fullname_validate_empty; fname.RequestFocus(); } else if (string.IsNullOrWhiteSpace(email.Text)) { email.Error = StringResources.common_ui_forms_email_validate_empty; email.RequestFocus(); } else if (string.IsNullOrWhiteSpace(passw.Text)) { passw.Error = StringResources.common_ui_forms_password_validate_empty; passw.RequestFocus(); } else if (passw.Text != confPass.Text) { confPass.Error = StringResources.common_ui_forms_password_validate_mismatch; confPass.RequestFocus(); } else if (!Android.Util.Patterns.EmailAddress.Matcher(email.Text).Matches()) { email.Error = StringResources.common_ui_forms_email_validate_invalid; email.RequestFocus(); } else if (string.IsNullOrWhiteSpace(selectedLanguage) || selectedLanguage == StringResources.common_ui_forms_language_default) { new Android.Support.V7.App.AlertDialog.Builder(this) .SetMessage(StringResources.common_ui_forms_language_error) .SetPositiveButton(StringResources.common_comms_ok, (a, b) => { }) .Show(); } else { FindViewById <RelativeLayout>(Resource.Id.loadingLayout).Visibility = ViewStates.Visible; FindViewById <AppCompatButton>(Resource.Id.submit).Enabled = false; LanguageChoice chosenLang = languageChoices.FirstOrDefault((arg) => arg.Endonym == selectedLanguage); LOG_EVENT_WITH_ACTION("REGISTER", "ATTEMPT"); CultureInfo currentCulture = StringResources.Culture ?? Localise.GetCurrentCultureInfo(); string currentLang = currentCulture.TwoLetterISOLanguageName; LanguageChoice matchingLanguage = await LanguageChoiceManager.GetLanguageFromCode(currentLang); //default to English at registration if no matching language int langId = (matchingLanguage != null)? matchingLanguage.Id : 1; var response = await RestClient.Register(fname.Text, email.Text.ToLower(), passw.Text, langId); if (response.Meta.Success) { LOG_EVENT_WITH_ACTION("REGISTER", "SUCCESS"); var intent = new Intent(this, typeof(Activities.RegisterVerification)); intent.PutExtra("EMAIL_USED_TO_REGISTER", email.Text); intent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.ClearTask | ActivityFlags.NewTask); StartActivity(intent); Finish(); } else { RunOnUiThread(() => { if (response.Meta.Messages.Count > 0) { LOG_EVENT_WITH_ACTION("REGISTER", "ERROR"); response.Meta.Messages.ForEach(MakeError); } FindViewById <AppCompatButton>(Resource.Id.submit).Enabled = true; FindViewById <RelativeLayout>(Resource.Id.loadingLayout).Visibility = ViewStates.Gone; fname.RequestFocus(); }); } } }