Exemplo n.º 1
0
 public void SetData()
 {
     projectsContainer = RedMineManager.Get <ProjectsContainer>("/projects.json");
     projectsGroups    = ProjectsContainer.GetProjectsGroupId();
     projectsItems     = ProjectsContainer.GetProjectsItemsId(projectsContainer);
     mAdapter          = new ExpandableListViewAdapter(this, projectsGroups, projectsItems, projectsContainer.projects);
     RunOnUiThread(() => LVProjects.SetAdapter(mAdapter));
 }
Exemplo n.º 2
0
        public static List <int> GetProjectsGroupId()
        {
            var query = from r in RedMineManager.Get <ProjectsContainer>("/projects.json").projects
                        where r.parent == null
                        select r.id;
            var result = query.ToList();

            return(result);
        }
Exemplo n.º 3
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.set_membership_layout);
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            ImageView    BSave      = new ImageView(this);
            LinearLayout LLControls = FindViewById <LinearLayout>(Resource.Id.right_controls);

            BSave.SetImageResource(Resource.Drawable.ic_save_white_18dp);
            LLControls.AddView(BSave);
            SetSupportActionBar(toolbar);

            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_arrow_back_white_18dp);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            LLRoot = FindViewById <LinearLayout>(Resource.Id.root);

            usersContainer = RedMineManager.Get <UsersContainer>("/users.json?limit=100&nometa=1");

            Spinner SUser = FindViewById <Spinner>(Resource.Id.user);
            var     query = from r in usersContainer.users
                            select r.firstname + " " + r.lastname;
            ArrayAdapter assigneeAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, query.ToList());

            assigneeAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
            SUser.Adapter = assigneeAdapter;

            Spinner SRole         = FindViewById <Spinner>(Resource.Id.role);
            var     statusAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, Enum.GetNames(typeof(RedMineManager.UserRoles)));

            SRole.Adapter = statusAdapter;
            statusAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);

            Button BAdd = FindViewById <Button>(Resource.Id.add);

            BAdd.Click += delegate
            {
                int role      = (int)Enum.Parse(typeof(RedMineManager.UserRoles), SRole.SelectedItem.ToString());
                var queryUser = from r in usersContainer.users
                                where r.firstname + " " + r.lastname == SUser.SelectedItem.ToString()
                                select r.id;
                RedMineManager.PostMemberShip("/projects/" + Intent.GetIntExtra("ProjectId", 0) + "/memberships.json", new
                {
                    membership = new
                    {
                        user_id  = queryUser.SingleOrDefault(),
                        role_ids = new int[] { role }
                    }
                });
                Recreate();
            };

            memberships = RedMineManager.Get <List <Membership> >("/projects/" + Intent.GetIntExtra("ProjectId", 0).ToString() + "/memberships.json?nometa=1", "memberships");
            SetMemberShipsLayout();
        }
Exemplo n.º 4
0
 public static UsersContainer GetUsers(RedMineManager.GETPROPERTIES property, ProgressDialog pd, out bool isAdmin)
 {
     try
     {
         UsersContainer result;
         result  = RedMineManager.Get <UsersContainer>("/users.json?limit=100");
         isAdmin = true;
         return(result);
     }
     catch
     {
         isAdmin = false;
         return(null);
     }
 }
Exemplo n.º 5
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.new_project_layout);
            projects = RedMineManager.Get <ProjectsContainer>("/projects.json");

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.NewProject);
            SetSupportActionBar(toolbar);

            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_arrow_back_white_18dp);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            ImageView BSubmit = new ImageView(this);

            BSubmit.SetImageResource(Resource.Drawable.ic_save_white_18dp);

            LinearLayout LLControls = FindViewById <LinearLayout>(Resource.Id.right_controls);

            LLControls.AddView(BSubmit);

            ETName         = FindViewById <EditText>(Resource.Id.name);
            ETIdentifier   = FindViewById <EditText>(Resource.Id.identifier);
            ETHomePage     = FindViewById <EditText>(Resource.Id.home_page);
            CBIsPublic     = FindViewById <CheckBox>(Resource.Id.is_public);
            SParent        = FindViewById <Spinner>(Resource.Id.parent);
            ETDescrtiption = FindViewById <EditText>(Resource.Id.description);

            BSubmit.Click += BSubmit_Click;

            var query = from r in projects.projects
                        select r.name;

            List <string> parents = new List <string> {
                "None"
            };

            parents.AddRange(query.ToList());

            var parentAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, parents);

            SParent.Adapter = parentAdapter;
            SParent.SetSelection(parentAdapter.GetPosition("None"));
        }
Exemplo n.º 6
0
 public void GetIssuesByFilters(bool includeClosed, bool myIssues = false, int projectId = 0)
 {
     if (includeClosed && projectId == 0)
     {
         if (myIssues)
         {
             issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&assigned_to_id=me&status_id=*");
         }
         else
         {
             issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&status_id=*");
         }
     }
     else if (projectId != 0)
     {
         if (includeClosed)
         {
             issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&project_id=" + projectId + "&status_id=*");
         }
         else
         {
             issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&project_id=" + projectId);
         }
     }
     else
     {
         if (myIssues)
         {
             issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&assigned_to_id=me");
         }
         else
         {
             issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1");
         }
     }
 }
Exemplo n.º 7
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);

            SetContentView(Resource.Layout.issue_layout);
            rnd           = new System.Random();
            includeClosed = false;
            if (Intent.GetStringExtra("Kind") == "Project Issues")
            {
                myIssues = false;
            }
            else
            {
                myIssues = true;
            }
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.Issues);
            if (myIssues)
            {
                toolbar.SetTitle(Resource.String.MyIssues);
            }
            SetSupportActionBar(toolbar);

            //Enable support action bar to display hamburger
            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_menu_white_18dp);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            drawerLayout        = FindViewById <DrawerLayout>(Resource.Id.drawer_layout);
            navigationView      = FindViewById <NavigationView>(Resource.Id.nav_view);
            rightNavigationView = FindViewById <NavigationView>(Resource.Id.right_nav_view);

            LayoutInflater inflater = (LayoutInflater)this.GetSystemService(Context.LayoutInflaterService);
            View           v        = inflater.Inflate(Resource.Layout.drawer_header, null);

            TVUserFullName = v.FindViewById <TextView>(Resource.Id.user_full_name);
            TVUserFullName.SetBackgroundColor(Android.Graphics.Color.Argb(200, rnd.Next(0, 255), rnd.Next(0, 255), rnd.Next(0, 255)));

            TVUserFullName.Text = RedMineManager.currUser.firstname + " " + RedMineManager.currUser.lastname ?? "Firstname Lastname";
            navigationView.AddHeaderView(v);
            navigationView.NavigationItemSelected += (sender, e) =>
            {
                e.MenuItem.SetChecked(true);
                switch (e.MenuItem.ItemId)
                {
                case Resource.Id.nav_my_issues:
                    Intent i0 = new Intent(this, typeof(IssueActivity));
                    i0.PutExtra("Kind", "My Issues");
                    StartActivity(i0);
                    break;

                case Resource.Id.nav_projects:
                    if (RedMineManager.currUser.status == 1)
                    {
                        Intent i4 = new Intent(this, typeof(MainActivity.MainActivity));
                        StartActivity(i4);
                    }
                    else
                    {
                        Toast.MakeText(this, Resources.GetString(Resource.String.PermissionError), ToastLength.Short).Show();
                    }
                    break;

                case Resource.Id.settings:
                    Intent i = new Intent(this, typeof(SettingsActivity.SettingsActivity));
                    i.PutExtra("Domen", RedMineManager.client.BaseUrl.ToString());
                    StartActivity(i);
                    break;

                case Resource.Id.administration:
                    if (RedMineManager.currUser.status == 1)
                    {
                        Intent i2 = new Intent(this, typeof(VerifiedUserActivity));
                        StartActivity(i2);
                    }
                    else
                    {
                        Toast.MakeText(this, Resources.GetString(Resource.String.PermissionError), ToastLength.Short).Show();
                    }
                    break;

                case Resource.Id.log_out:
                    LoginActivity.CredentialsStore.Delete();
                    Intent i3 = new Intent(this, typeof(LoginActivity.LoginActivity));
                    Finish();
                    StartActivity(i3);
                    break;

                case Resource.Id.exit:
                    Finish();
                    break;
                }
                drawerLayout.CloseDrawers();
            };

            BNew = new ImageView(this);
            LinearLayout LLControls = FindViewById <LinearLayout>(Resource.Id.right_controls);

            BNew.SetImageResource(Resource.Drawable.ic_add_white_18dp);
            LLControls.AddView(BNew);
            BNew.Click += delegate
            {
                Intent i = new Intent(this, typeof(IssueEditorActivity));
                i.PutExtra("IsNew", true);
                i.PutExtra("Issue", Newtonsoft.Json.JsonConvert.SerializeObject(new Issue {
                    tracker = new Tracker(), assigned_to = new AssignedTo(), author = new Author(), priority = new Priority(), status = new Status(), project = new IssuesContainer.Project()
                }));
                i.PutExtra("ProjectId", Intent.GetIntExtra("ProjectId", 0));
                StartActivityForResult(i, 0);
            };
            int g = Intent.GetIntExtra("ProjectId", 0);

            issues          = RedMineManager.Get <IssuesContainer>("/issues.json?assigned_to_id=me&nometa=1");
            BNew.Visibility = ViewStates.Gone;


            if (Intent.GetStringExtra("Kind") == "Project Issues")
            {
                issues          = RedMineManager.Get <IssuesContainer>("/projects/" + g + "/issues.json?nometa=1");
                BNew.Visibility = ViewStates.Visible;
            }

            SetLayout();
            SetRightNavPanel();

            refresh = FindViewById <SwipeRefreshLayout>(Resource.Id.swipe_refresh);
            refresh.SetDistanceToTriggerSync(1);
            refresh.SetColorSchemeResources(Resource.Color.colorAccent, Resource.Color.colorPrimary);
            refresh.Refresh += delegate
            {
                Thread t = new Thread(() =>
                {
                    GetIssuesByFilters(includeClosed, myIssues, Intent.GetIntExtra("ProjectId", 0));
                    RunOnUiThread(() =>
                    {
                        Recreate();
                        refresh.Refreshing = false;
                    });
                });
                t.Start();
            };
        }
Exemplo n.º 8
0
        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);
        }
Exemplo n.º 9
0
        public void SetRightNavPanel()
        {
            SFilterByStatus = FindViewById <Spinner>(Resource.Id.filter_by_status);
            SFilterByMonth  = FindViewById <Spinner>(Resource.Id.filter_by_month);
            CBClosed        = FindViewById <CheckBox>(Resource.Id.closed_filter);

            var valuesForStatusAdapter = new List <string>()
            {
                "None"
            };

            valuesForStatusAdapter.AddRange(Enum.GetNames(typeof(RedMineManager.IssueStatuses)));
            statusAdapter           = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, valuesForStatusAdapter);
            SFilterByStatus.Adapter = statusAdapter;

            dates = new List <DateTime>();
            DateTime currDate = DateTime.Now;

            for (int i = 0; i < 24; i++)
            {
                dates.Add(currDate.AddMonths(-i));
            }

            var monthQuery = from date in dates
                             select date.ToString(@"MMMM yyyy", CultureInfo.CurrentCulture);

            List <string> valuesFoMonthAdapter = new List <string>()
            {
                "None"
            };

            valuesFoMonthAdapter.AddRange(monthQuery.ToList());
            monthsAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, valuesForStatusAdapter);

            SFilterByMonth.Adapter = monthsAdapter;

            SFilterByStatus.ItemSelected += delegate
            {
                if (SFilterByStatus.SelectedItem.ToString() != "None")
                {
                    int statusId = (int)Enum.Parse(typeof(RedMineManager.IssueStatuses), SFilterByStatus.SelectedItem.ToString());
                    if (myIssues)
                    {
                        issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100&assigned_to_id=me&status_id=" + statusId);
                    }
                    else
                    {
                        issues = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100&project_id=" + Intent.GetIntExtra("ProjectId", 0) + "&status_id=" + statusId);
                    }
                    SetLayout();
                }
                else
                {
                    GetIssuesByFilters(includeClosed, myIssues, Intent.GetIntExtra("ProjectId", 0));
                }
            };

            SFilterByMonth.ItemSelected += delegate
            {
                if (SFilterByMonth.SelectedItem.ToString() != "None")
                {
                    string segmentUri = "/issues.xml?nometa=1&limit=100&created_on=%3E%3C";
                    var    dateQuery  = from date in dates
                                        where date.ToString(@"MMMM yyyy", CultureInfo.CurrentCulture) == SFilterByMonth.SelectedItem.ToString()
                                        select date;
                    DateTime.DaysInMonth(dateQuery.SingleOrDefault().Year, dateQuery.SingleOrDefault().Month);
                    DateTime endTime = dateQuery.SingleOrDefault();
                    segmentUri += endTime.ToString("yyyy-MM-dd") + "|";
                    endTime.AddDays(DateTime.DaysInMonth(dateQuery.SingleOrDefault().Year, dateQuery.SingleOrDefault().Month) - 1);
                    segmentUri += endTime.ToString("yyyy-MM-dd");
                    if (myIssues)
                    {
                        segmentUri += "&assigned_to_id=me";
                    }
                    else
                    {
                        segmentUri += "&project_id=" + Intent.GetIntExtra("ProjectId", 0);
                    }
                    issues = RedMineManager.Get <IssuesContainer>(segmentUri);
                    SetLayout();
                }
            };
            CBClosed.CheckedChange += delegate
            {
                includeClosed = CBClosed.Checked;
                GetIssuesByFilters(includeClosed, myIssues, Intent.GetIntExtra("ProjectId", 0));
                SetLayout();
            };
        }
Exemplo n.º 10
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.one_project_layout);

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.Project);
            SetSupportActionBar(toolbar);

            SupportActionBar.SetHomeAsUpIndicator(Resource.Drawable.ic_arrow_back_white_18dp);
            SupportActionBar.SetDisplayHomeAsUpEnabled(true);

            LLRootRoles = FindViewById <LinearLayout>(Resource.Id.root_roles);

            memberships = RedMineManager.Get <List <Membership> >("/projects/" + Intent.GetIntExtra("ProjectId", 0) + "/memberships.json?nometa=1", "memberships");

            foreach (var membership in memberships)
            {
                LinearLayout LLMemberShip = new LinearLayout(this);
                LLMemberShip.Orientation = Orientation.Horizontal;

                TextView TVUser = new TextView(this);
                if (membership.user != null)
                {
                    TVUser.Text = membership.user.name + " - " ?? "";
                }
                TVUser.SetTextColor(Android.Content.Res.ColorStateList.ValueOf(Android.Graphics.Color.Black));
                LLMemberShip.AddView(TVUser);

                TextView TVRole = new TextView(this);
                foreach (var role in membership.roles)
                {
                    TVRole.SetTextColor(Resources.GetColor(Resource.Color.colorPrimary));
                    TVRole.Text += role.name + " ";
                }
                LLMemberShip.AddView(TVRole);
                LLRootRoles.AddView(LLMemberShip);
            }

            Button BSetChange = new Button(this);

            BSetChange.Text   = Resources.GetString(Resource.String.SetChange);
            BSetChange.Click += delegate
            {
                Intent i = new Intent(this, typeof(SetMembershipActivity));
                i.PutExtra("ProjectId", Intent.GetIntExtra("ProjectId", 0));
                StartActivityForResult(i, 0);
            };
            LLRootRoles.AddView(BSetChange);
            RelativeLayout RLIssues = FindViewById <RelativeLayout>(Resource.Id.issues);

            RLIssues.Click += delegate
            {
                Intent i = new Intent(this, typeof(IssueActivity.IssueActivity));
                i.PutExtra("Kind", "Project Issues");
                i.PutExtra("ProjectId", Intent.GetIntExtra("ProjectId", 0));
                StartActivity(i);
            };
            TextView TVCountOfIssues = FindViewById <TextView>(Resource.Id.count_of_issues);

            TVCountOfIssues.Text = RedMineManager.Get <IssuesContainer>("/issues.json?project_id=" + Intent.GetIntExtra("ProjectId", 0)).total_count.ToString();
        }
Exemplo n.º 11
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.issue_editor_layout);
            if (RedMineManager.Get <MainActivity.User>("/users/current.json", "user").status != 0)
            {
                isAdmin = true;
            }
            usersContainer = RedMineManager.Get <UsersContainer>("/users.json?limit=100&nometa=1");

            if (!Intent.GetBooleanExtra("IsNew", false))
            {
                currIssue = RedMineManager.Get <IssuesContainer.Issue>("/issues/" + Intent.GetIntExtra("ID", 0) + ".json?include=journals&nometa=1", "issue");
            }
            BSave        = new Button(this);
            BSave.Text   = Resources.GetString(Resource.String.Save);
            BSave.Click += BSave_Click;

            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.EditIssue);
            toolbar.AddView(BSave);
            SetSupportActionBar(toolbar);

            LLRoot   = FindViewById <LinearLayout>(Resource.Id.root);
            STracker = FindViewById <Spinner>(Resource.Id.tracker);
            ArrayAdapter trackerAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, Enum.GetNames(typeof(RedMineManager.Trackers)));

            STracker.Adapter = trackerAdapter;
            trackerAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);

            SPriority = FindViewById <Spinner>(Resource.Id.priority);
            var priorityAdapter = ArrayAdapter.CreateFromResource(this, Resource.Array.priorities_array, Android.Resource.Layout.SimpleDropDownItem1Line);

            priorityAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
            SPriority.Adapter = priorityAdapter;

            SAssignee = FindViewById <Spinner>(Resource.Id.assigned_to);
            var query = from r in usersContainer.users
                        select r.firstname + " " + r.lastname;
            ArrayAdapter assigneeAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, query.ToList());

            assigneeAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);
            SAssignee.Adapter = assigneeAdapter;
            if (!isAdmin)
            {
                SAssignee.Enabled = false;
            }

            SStatus = FindViewById <Spinner>(Resource.Id.status);
            var statusAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, Enum.GetNames(typeof(RedMineManager.IssueStatuses)));

            SStatus.Adapter = statusAdapter;
            if (!isAdmin)
            {
                SStatus.Enabled = false;
            }
            statusAdapter.SetDropDownViewResource(Android.Resource.Layout.SimpleDropDownItem1Line);


            BStartDate        = FindViewById <ImageButton>(Resource.Id.start_date);
            BStartDate.Click += ChangeDateClick;

            ETStartDate = FindViewById <EditText>(Resource.Id.txt_start_date);

            BDueDate        = FindViewById <ImageButton>(Resource.Id.due_date);
            BDueDate.Click += DueDateClick;

            ETDueDate = FindViewById <EditText>(Resource.Id.txt_due_date);

            ETEstimatedHours = FindViewById <EditText>(Resource.Id.estimated_hours);

            ETProgress = FindViewById <EditText>(Resource.Id.done_ratio);
            if (Intent.GetBooleanExtra("IsNew", false))
            {
                ETProgress.Enabled = false;
            }


            ETDescription = FindViewById <EditText>(Resource.Id.description);

            ETSubject = FindViewById <EditText>(Resource.Id.subject);


            LLNotesRoot    = FindViewById <LinearLayout>(Resource.Id.notes_root);
            ETNewNote      = new EditText(this);
            ETNewNote.Hint = Resources.GetString(Resource.String.NewNote);
            LLNotesRoot.AddView(ETNewNote);
            SetNotesLayout();



            if (currIssue != null)
            {
                SStatus.SetSelection(statusAdapter.GetPosition(currIssue.status.name));
                ETSubject.Text        = currIssue.subject;
                ETDescription.Text    = currIssue.description;
                ETEstimatedHours.Text = currIssue.estimated_hours.ToString();
                ETProgress.Text       = currIssue.done_ratio.ToString();
                ETEstimatedHours.Text = currIssue.estimated_hours.ToString();
                if (currIssue.assigned_to != null)
                {
                    SAssignee.SetSelection(assigneeAdapter.GetPosition(currIssue.assigned_to.name));
                }
                if (currIssue.tracker != null)
                {
                    STracker.SetSelection(trackerAdapter.GetPosition(currIssue.tracker.name));
                }
                if (currIssue.priority != null)
                {
                    SPriority.SetSelection(priorityAdapter.GetPosition(currIssue.priority.name));
                }
                ETStartDate.Text = currIssue.start_date;
                ETDueDate.Text   = currIssue.due_date;
            }
            else
            {
                currIssue = new IssuesContainer.Issue {
                    project = new IssuesContainer.Project {
                        id = Intent.GetIntExtra("ProjectId", 0)
                    }
                }
            };

            if (Intent.GetBooleanExtra("IsNew", false))
            {
                ClearIssueFields();
            }
        }
Exemplo n.º 12
0
        protected override void OnCreate(Bundle savedInstanceState)
        {
            base.OnCreate(savedInstanceState);
            SetContentView(Resource.Layout.time_entry_layout);
            toolbar = FindViewById <Toolbar>(Resource.Id.toolbar);
            toolbar.SetTitle(Resource.String.TimeEntries);
            SetSupportActionBar(toolbar);
            pd                = new ProgressDialog(this);
            issue             = RedMineManager.Get <IssuesContainer.Issue>("/issues/" + Intent.GetIntExtra("IssueID", 0) + ".json", "issue");
            issue.timeEntries = RedMineManager.Get <List <IssuesContainer.TimeEntry> >("/issues/" + Intent.GetIntExtra("IssueID", 0) + "/time_entries.json?nometa=1", "time_entries");

            PBProgress      = FindViewById <ProgressBar>(Resource.Id.progress);
            TVSpentTime     = FindViewById <TextView>(Resource.Id.spent_time);
            TVEstimatedTime = FindViewById <TextView>(Resource.Id.estimated_time);
            BPlay           = FindViewById <ImageView>(Resource.Id.play);
            BStop           = FindViewById <ImageView>(Resource.Id.stop);
            BPause          = FindViewById <ImageView>(Resource.Id.pause);
            LLRoot          = FindViewById <LinearLayout>(Resource.Id.root);

            RLConfirm            = FindViewById <RelativeLayout>(Resource.Id.confirm);
            RLConfirm.Visibility = ViewStates.Gone;
            ETComment            = FindViewById <EditText>(Resource.Id.comment);
            BSubmit = FindViewById <Button>(Resource.Id.submit);

            spentTime    = TimeSpan.FromHours(issue.spent_hours);
            newSpentTime = new TimeSpan();

            estimatedTime = TimeSpan.FromHours(issue.estimated_hours);

            float r = (float)spentTime.Ticks / (float)estimatedTime.Ticks;

            PBProgress.Progress = Convert.ToInt32((float)r * (float)100);

            ShowTimeEntries();

            progress = new Thread(() =>
            {
                HandleSpentTime();
            });

            BPlay.Click += delegate
            {
                progress.Start();
                BPlay.Visibility = ViewStates.Gone;
                BStop.Visibility = ViewStates.Visible;
            };

            BPause.Click += delegate
            {
                if (progress.IsAlive)
                {
                    progress.Suspend();
                }
                else
                {
                    progress.Resume();
                }
            };

            BStop.Click += delegate
            {
                RLConfirm.Visibility = ViewStates.Visible;
                progress.Abort();
            };

            BSubmit.Click += delegate
            {
                IssuesContainer.TimeEntry t = new IssuesContainer.TimeEntry();
                t.issue    = issue;
                t.comments = ETComment.Text;
                t.hours    = newSpentTime.TotalHours;

                BPlay.Visibility = ViewStates.Visible;
                BStop.Visibility = ViewStates.Gone;

                Toast.MakeText(this, RedMineManager.PutPostTimeEntry(t, true), ToastLength.Short).Show();

                Recreate();
            };

            TVSpentTime.Text     = spentTime.ToString();
            TVEstimatedTime.Text = estimatedTime.ToString();
        }
Exemplo n.º 13
0
        public void SettingUpViews()
        {
            PDLoading = new ProgressDialog(this);
            PDLoading.SetTitle(Resources.GetString(Resource.String.LoadingAllRequiredData));
            PDLoading.SetMessage(Resources.GetString(Resource.String.PleaseWait));
            PDLoading.Show();
            Thread loadAllData = new Thread(() =>
            {
                usersContainer    = RedMineManager.Get <UsersContainer>("/users.json?nometa=1&limit=100");
                projectsContainer = RedMineManager.Get <ProjectsContainer>("/projects.json?nometa=1&limit=100");
                issuesContainer   = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100");
                foreach (var issue in issuesContainer.issues)
                {
                    issue.timeEntries = RedMineManager.Get <List <IssuesContainer.TimeEntry> >("/issues/" + issue.id + "/time_entries.json?nometa=1", "time_entries");
                    foreach (var timeEntry in issue.timeEntries)
                    {
                        issue.spent_hours += timeEntry.hours;
                    }
                }
                foreach (var project in projectsContainer.projects)
                {
                    project.memberships = RedMineManager.Get <List <Membership> >("/projects/" + project.id + "/memberships.json?nometa=1", "memberships");
                }
                //formating data for adapters and setting dates
                var usersQuery = from user in usersContainer.users
                                 select user.firstname + " " + user.lastname;
                List <string> usersForAdapter = new List <string>()
                {
                    "None"
                };
                usersForAdapter.AddRange(usersQuery.ToList());
                var projectsQuery = from project in projectsContainer.projects
                                    select project.name;
                List <string> projectsForAdapter = new List <string>()
                {
                    "None"
                };
                projectsForAdapter.AddRange(projectsQuery.ToList());
                var issuesQuery = from issue in issuesContainer.issues
                                  select issue.subject;
                List <string> issuesForAdapter = new List <string>()
                {
                    "None"
                };
                issuesForAdapter.AddRange(issuesQuery.ToList());
                dates             = new List <DateTime>();
                DateTime currDate = DateTime.Now;
                for (int i = 0; i < 24; i++)
                {
                    dates.Add(currDate.AddMonths(-i));
                }

                var monthQuery = from date in dates
                                 select date.ToString(@"MMMM yyyy", CultureInfo.CurrentCulture);
                List <string> monthsForAdapter = new List <string>()
                {
                    "None"
                };
                monthsForAdapter.AddRange(monthQuery.ToList());
                //creating adapters for spinners
                var userAdapter    = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, usersForAdapter);
                var monthAdapter   = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, monthsForAdapter);
                var projectAdapter = new ArrayAdapter(this, Android.Resource.Layout.SimpleDropDownItem1Line, projectsForAdapter);
                var issuesAdapter  = new ArrayAdapter(this, Android.Resource.Layout.SimpleSpinnerDropDownItem, issuesForAdapter);

                RunOnUiThread(() =>
                {
                    SFilterByUser.Adapter    = userAdapter;
                    SFilterByProject.Adapter = projectAdapter;
                    SFilterByMonth.Adapter   = monthAdapter;
                    SFilterByIssue.Adapter   = issuesAdapter;
                });
                //When project selected, set only this project`s issues for issue spinner
                SFilterByProject.ItemSelected += delegate
                {
                    var issueAdapterQuery = from issue in issuesContainer.issues
                                            where issue.project.name == SFilterByProject.SelectedItem.ToString()
                                            select issue.subject;
                    issuesAdapter.Clear();
                    issuesAdapter.Add("None");
                    issuesAdapter.AddAll(issueAdapterQuery.ToList());
                };
                SFilterByUser.ItemSelected += delegate
                {
                    if (SFilterByUser.SelectedItem.ToString() != "None")
                    {
                        //When user selected set only projects, which user involved
                        var projectQuery = from project in projectsContainer.projects
                                           from membership in project.memberships
                                           where membership?.user?.name == SFilterByUser.SelectedItem.ToString()
                                           select project.name;
                        projectAdapter.Clear();
                        projectAdapter.Add("None");
                        projectAdapter.AddAll(projectQuery.ToList());

                        //Also set issues, where user assigned to
                        var issueQuery = from issue in issuesContainer.issues
                                         where issue?.assigned_to?.name == SFilterByUser.SelectedItem.ToString()
                                         select issue.subject;
                        issuesAdapter.Clear();
                        issuesAdapter.Add("None");
                        issuesAdapter.AddAll(issueQuery.ToList());
                    }
                };

                CBClosed.CheckedChange += delegate
                {
                    RunOnUiThread(() => PDLoading.Show());
                    Thread innerThread = new Thread(() =>
                    {
                        if (CBClosed.Checked)
                        {
                            issuesContainer = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100&status_id=*");
                        }
                        else
                        {
                            issuesContainer = RedMineManager.Get <IssuesContainer>("/issues.json?nometa=1&limit=100");
                        }
                        var issueQuery = from issue in issuesContainer.issues
                                         select issue.subject;

                        foreach (var issue in issuesContainer.issues)
                        {
                            issue.timeEntries = RedMineManager.Get <List <IssuesContainer.TimeEntry> >("/issues/" + issue.id + "/time_entries.json?nometa=1", "time_entries");
                            foreach (var timeEntry in issue.timeEntries)
                            {
                                issue.spent_hours += timeEntry.hours;
                            }
                        }

                        RunOnUiThread(() =>
                        {
                            issuesAdapter.Clear();
                            issuesAdapter.Add("None");
                            issuesAdapter.AddAll(issueQuery.ToList());
                            PDLoading.Hide();
                        });
                    });
                    SFilterByIssue.SetSelection(0);
                    SFilterByMonth.SetSelection(0);
                    SFilterByProject.SetSelection(0);
                    SFilterByUser.SetSelection(0);
                    innerThread.Start();
                };

                //Click for applying filter
                BApplyFilter.Click += delegate
                {
                    if (SFilterByUser.SelectedItem.ToString() != "None")
                    {
                        var userQuery = from user in usersContainer.users
                                        where user.firstname + " " + user.lastname == SFilterByUser.SelectedItem.ToString()
                                        select user;
                        usersContainer.users = userQuery.ToList();
                        var projectQuery     = from project in projectsContainer.projects
                                               from membership in project.memberships
                                               where membership?.user?.name == SFilterByUser.SelectedItem.ToString()
                                               select project;
                        projectsContainer.projects = projectQuery.ToList();
                        var issueQuery             = from issue in issuesContainer.issues
                                                     where issue.assigned_to?.name == SFilterByUser.SelectedItem.ToString()
                                                     select issue;
                        issuesContainer.issues = issueQuery.ToList();
                    }
                    if (SFilterByMonth.SelectedItem.ToString() != "None")
                    {
                        var query = from date in dates
                                    where date.ToString(@"MMMM yyyy") == SFilterByMonth.SelectedItem.ToString()
                                    from issue in issuesContainer.issues
                                    where DateTime.Parse(issue.created_on).Month == date.Month
                                    select issue;
                        issuesContainer.issues = query.ToList();
                    }
                    if (SFilterByProject.SelectedItem.ToString() != "None")
                    {
                        var issueQuery = from issue in issuesContainer.issues
                                         where issue.project.name == SFilterByProject.SelectedItem.ToString()
                                         select issue;
                        issuesContainer.issues = issueQuery.ToList();
                        var projectQuery       = from project in projectsContainer.projects
                                                 where project.name == SFilterByProject.SelectedItem.ToString()
                                                 select project;
                        projectsContainer.projects = projectQuery.ToList();
                    }
                    if (SFilterByIssue.SelectedItem.ToString() != "None")
                    {
                        var query = from issue in issuesContainer.issues
                                    where issue.subject == SFilterByIssue.SelectedItem.ToString()
                                    select issue;
                        issuesContainer.issues = query.ToList();
                    }
                    SetView();
                };
                RunOnUiThread(() => PDLoading.Hide());
            });

            loadAllData.Start();
        }