Exemple #1
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");
         }
     }
 }
Exemple #2
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();
            };
        }
Exemple #3
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();
            };
        }