public void SetMemberShipsLayout() { foreach (var membership in memberships) { RelativeLayout LLMemberShip = new RelativeLayout(this); RelativeLayout.LayoutParams lpForLLMemberShip = new RelativeLayout.LayoutParams(-1, -2); lpForLLMemberShip.SetMargins(0, 5, 0, 0); LLMemberShip.SetBackgroundResource(Resource.Color.colorBackgroundCard); LinearLayout LLRole = new LinearLayout(this); LLRole.SetPadding(10, 0, 0, 0); LLRole.Orientation = Orientation.Horizontal; TextView TVUsername = new TextView(this); TVUsername.SetTextColor(Android.Graphics.Color.Black); TVUsername.Text = membership.user.name + " - "; LLRole.AddView(TVUsername); TextView TVRoles = new TextView(this); TVRoles.SetTextColor(Resources.GetColor(Resource.Color.colorPrimary)); foreach (var role in membership.roles) { TVRoles.Text += role.name; } LLRole.AddView(TVRoles); LLMemberShip.AddView(LLRole); ImageView BDelete = new ImageView(this); RelativeLayout.LayoutParams lpForBDelete = new RelativeLayout.LayoutParams(-2, -2); lpForBDelete.AddRule(LayoutRules.AlignParentRight); lpForBDelete.RightMargin = 5; BDelete.SetImageResource(Resource.Drawable.ic_delete_black_18dp); BDelete.Click += delegate { RedMineManager.Delete("/memberships/" + membership.id + ".json"); memberships.Remove(membership); Recreate(); }; LLMemberShip.AddView(BDelete, lpForBDelete); LLRoot.AddView(LLMemberShip, lpForLLMemberShip); } }
public View SetIssueView(Issue currIssue) { Issue issue = RedMineManager.Get <Issue>("/issues/" + currIssue.id + ".json?include=changesheets,journals", "issue"); LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService); View v = inflater.Inflate(Resource.Layout.issue_fragment, null); LinearLayout root = v.FindViewById <LinearLayout>(Resource.Id.root); TextView TVProjectTitle = v.FindViewById <TextView>(Resource.Id.project_title); TVProjectTitle.Text = issue.project.name; ProgressBar PBProgress = v.FindViewById <ProgressBar>(Resource.Id.issue_progress); PBProgress.Max = 100; PBProgress.Progress = issue.done_ratio; TextView TVProgress = v.FindViewById <TextView>(Resource.Id.issue_progress_value); TVProgress.Text = issue.done_ratio.ToString(); TextView TVTracker = v.FindViewById <TextView>(Resource.Id.tracker); TVTracker.Text = issue.tracker.name; TextView TVStatus = v.FindViewById <TextView>(Resource.Id.status); TVStatus.Text = issue.status.name; TextView TVAuthor = v.FindViewById <TextView>(Resource.Id.author); TVAuthor.SetMinLines(2); TVAuthor.Text = issue.author.name; TextView TVAssignedTo = v.FindViewById <TextView>(Resource.Id.assigned_to); if (issue.assigned_to != null) { TVAssignedTo.Text = issue.assigned_to.name; } TextView TVPriority = v.FindViewById <TextView>(Resource.Id.priority); TVPriority.Text = issue.priority.name; TextView TVStartDate = v.FindViewById <TextView>(Resource.Id.start_date); if (issue.start_date != null) { TVStartDate.Text = issue.start_date; } TextView TVDueDate = v.FindViewById <TextView>(Resource.Id.due_date); if (issue.due_date != null) { TVDueDate.Text = issue.due_date; } TextView TVCreatedOn = v.FindViewById <TextView>(Resource.Id.created_on); TVCreatedOn.Text = issue.created_on; TextView TVUpdatedOn = v.FindViewById <TextView>(Resource.Id.updated_on); TVUpdatedOn.Text = issue.updated_on; TextView TVSubjectLabel = v.FindViewById <TextView>(Resource.Id.subject_label); TextView TVSubject = v.FindViewById <TextView>(Resource.Id.subject); TVSubject.Text = issue.subject; TextView TVDescriptionLabel = v.FindViewById <TextView>(Resource.Id.description_label); TextView TVDescription = v.FindViewById <TextView>(Resource.Id.description); TVDescription.Text = issue.description; TextView TVNotesLabel = v.FindViewById <TextView>(Resource.Id.notes_label); TVNotesLabel.Visibility = ViewStates.Gone; TextView TVNotes = v.FindViewById <TextView>(Resource.Id.notes); TVNotes.Visibility = ViewStates.Gone; if (issue.journals != null) { foreach (var journal in issue.journals) { TVNotes.Text += journal.notes; if (journal.notes != "") { TVNotes.Text += "\n\n"; } } } TextView Expander = v.FindViewById <TextView>(Resource.Id.expander); ImageView BEdit = v.FindViewById <ImageView>(Resource.Id.edit); ImageView BDelete = v.FindViewById <ImageView>(Resource.Id.delete); Expander.Click += delegate { if (TVSubject.Visibility == ViewStates.Gone) { TVSubjectLabel.Visibility = ViewStates.Visible; TVSubject.Visibility = ViewStates.Visible; TVDescriptionLabel.Visibility = ViewStates.Visible; TVDescription.Visibility = ViewStates.Visible; TVNotesLabel.Visibility = ViewStates.Visible; TVNotes.Visibility = ViewStates.Visible; Expander.Text = Resources.GetString(Resource.String.Collapse); } else { TVSubjectLabel.Visibility = ViewStates.Gone; TVSubject.Visibility = ViewStates.Gone; TVDescriptionLabel.Visibility = ViewStates.Gone; TVDescription.Visibility = ViewStates.Gone; TVNotesLabel.Visibility = ViewStates.Gone; TVNotes.Visibility = ViewStates.Gone; Expander.Text = Resources.GetString(Resource.String.Expand); } }; BEdit.Click += delegate { if (!(RedMineManager.ValidateUserForAction(issue.project.id).Contains(6) || RedMineManager.ValidateUserForAction(issue.project.id).Contains(4) || RedMineManager.currUser.status == 1)) { Toast.MakeText(this, Resources.GetString(Resource.String.PermissionError), ToastLength.Short).Show(); return; } Intent i = new Intent(this, typeof(IssueEditorActivity)); //i.PutExtra("ID", issue.id); i.PutExtra("ID", issue.id); StartActivityForResult(i, 0); }; BDelete.Click += delegate { if (!(RedMineManager.ValidateUserForAction(issue.project.id).Contains(6) || RedMineManager.currUser.status == 1)) { Toast.MakeText(this, Resources.GetString(Resource.String.PermissionError), ToastLength.Short).Show(); return; } var alert = new AlertDialog.Builder(this); alert.SetMessage(Resources.GetString(Resource.String.IssueDeleteConfirmation)); alert.SetPositiveButton(Resources.GetString(Resource.String.Ok), (s, arg) => { RedMineManager.Delete("/issues/" + issue.id + ".json"); }); alert.SetNegativeButton(Resources.GetString(Resource.String.Cancel), (s, arg) => { }); RunOnUiThread(() => { alert.Show(); }); this.Recreate(); }; ImageView BTimePlay = v.FindViewById <ImageView>(Resource.Id.play); TVTimeEntry = v.FindViewById <TextView>(Resource.Id.time_entry); BTimePlay.Click += (s, arg) => { Intent i = new Intent(this, typeof(TimeEntryActivity)); i.PutExtra("IssueID", issue.id); StartActivity(i); }; return(v); }