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); }
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); } }
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); }
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 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); }
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; }; }
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 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 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(); }
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(); }