Ejemplo n.º 1
0
            protected override void Rebind()
            {
                var color = Color.ParseColor(Model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.SetText(Resource.String.ProjectsNewProject);
            }
Ejemplo n.º 2
0
            protected override void Rebind()
            {
                if (Model == null)
                {
                    ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility   = ViewStates.Gone;
                    TasksFrameLayout.Visibility = ViewStates.Gone;
                    return;
                }

                var color = Color.ParseColor(Model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.Text = Model.Name;
                if (Model.Client != null)
                {
                    ClientTextView.Text       = Model.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                TasksFrameLayout.Visibility = DataSource.Tasks.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                var expanded = dataView.AreProjectTasksVisible(Model);

                TasksTextView.Visibility  = expanded ? ViewStates.Invisible : ViewStates.Visible;
                TasksImageView.Visibility = !expanded ? ViewStates.Invisible : ViewStates.Visible;
            }
Ejemplo n.º 3
0
            public void Bind(ProjectsCollection.SuperProjectData projectData, bool showClient)
            {
                this.projectData = projectData;

                if (projectData.IsEmpty)
                {
                    var emptyColor = ColorView.Resources.GetColor(Resource.Color.dark_gray_text);
                    ColorView.SetBackgroundColor(emptyColor);
                    ProjectTextView.SetTextColor(emptyColor);
                    ClientTextView.SetTextColor(emptyColor);

                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility = ViewStates.Gone;
                    TasksButton.Visibility    = ViewStates.Gone;
                    return;
                }

                var color = Color.ParseColor(ProjectModel.HexColors [projectData.Color % ProjectModel.HexColors.Length]);

                ColorView.SetBackgroundColor(color);
                ProjectTextView.SetTextColor(color);
                ClientTextView.SetTextColor(color);

                ProjectTextView.Text      = projectData.Name;
                ClientTextView.Text       = projectData.ClientName;
                ClientTextView.Visibility = showClient ? ViewStates.Visible : ViewStates.Gone;
                TasksButton.Visibility    = projectData.TaskNumber > 0 ? ViewStates.Visible : ViewStates.Gone;
                TasksButton.Selected      = false;
            }
            private void RebindProjectTextView(Context ctx)
            {
                String text;
                int    projectLength = 0;
                int    clientLength  = 0;
                var    mode          = SpanTypes.InclusiveExclusive;

                if (DataSource.Project != null)
                {
                    var projectName = DataSource.Project.Name;
                    if (String.IsNullOrWhiteSpace(projectName))
                    {
                        projectName = ctx.GetString(Resource.String.RecentTimeEntryNamelessProject);
                    }

                    projectLength = projectName.Length;
                    if (DataSource.Project.Client != null && !String.IsNullOrWhiteSpace(DataSource.Project.Client.Name))
                    {
                        clientLength = DataSource.Project.Client.Name.Length;
                        text         = String.Concat(projectName, "   ", DataSource.Project.Client.Name);
                    }
                    else
                    {
                        text = projectName;
                    }
                }
                else
                {
                    text          = ctx.GetString(Resource.String.RecentTimeEntryNoProject);
                    projectLength = text.Length;
                }

                var start = 0;
                var end   = start + projectLength;

                var spannable = new SpannableString(text);

                spannable.SetSpan(new FontSpan(Font.Roboto), start, end, mode);
                spannable.SetSpan(new AbsoluteSizeSpan(18, true), start, end, mode);
                if (clientLength > 0)
                {
                    start = projectLength + 3;
                    end   = start + clientLength;

                    spannable.SetSpan(new FontSpan(Font.RobotoLight), start, end, mode);
                    spannable.SetSpan(new AbsoluteSizeSpan(14, true), start, end, mode);
                }
                ProjectTextView.SetText(spannable, TextView.BufferType.Spannable);
            }
Ejemplo n.º 5
0
            protected async override void Rebind()
            {
                // Protect against Java side being GCed
                if (Handle == IntPtr.Zero)
                {
                    return;
                }

                model = null;
                if (DataSource != null)
                {
                    model = (ProjectModel)DataSource.Data;
                }

                if (model == null)
                {
                    ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility = ViewStates.Gone;
                    TasksButton.Visibility    = ViewStates.Gone;
                    return;
                }

                await model.LoadAsync();

                var color = Color.ParseColor(model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.SetTextColor(color);
                ClientTextView.SetTextColor(color);

                ProjectTextView.Text = model.Name;
                if (model.Client != null)
                {
                    ClientTextView.Text       = model.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                TasksButton.Visibility = DataSource.Tasks.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                TasksButton.Selected   = false;
            }
            protected override void Rebind()
            {
                // Protect against Java side being GCed
                if (Handle == IntPtr.Zero)
                {
                    return;
                }

                ResetTrackedObservables();

                if (model == null)
                {
                    ColorView.SetBackgroundColor(ColorView.Resources.GetColor(Resource.Color.dark_gray_text));
                    ProjectTextView.SetText(Resource.String.ProjectsNoProject);
                    ClientTextView.Visibility   = ViewStates.Gone;
                    TasksFrameLayout.Visibility = ViewStates.Gone;
                    return;
                }

                var color = Color.ParseColor(model.GetHexColor());

                ColorView.SetBackgroundColor(color);
                ProjectTextView.Text = model.Name;
                if (model.Client != null)
                {
                    ClientTextView.Text       = model.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                TasksFrameLayout.Visibility = DataSource.Tasks.Count == 0 ? ViewStates.Gone : ViewStates.Visible;
                var expanded = dataView.AreProjectTasksVisible(model.Id);

                TasksTextView.Visibility  = expanded ? ViewStates.Invisible : ViewStates.Visible;
                TasksImageView.Visibility = !expanded ? ViewStates.Invisible : ViewStates.Visible;
            }
Ejemplo n.º 7
0
            protected override void Rebind()
            {
                // Protect against Java side being GCed
                if (Handle == IntPtr.Zero)
                {
                    return;
                }

                ResetTrackedObservables();

                if (DataSource == null)
                {
                    return;
                }

                var ctx = ServiceContainer.Resolve <Context> ();

                if (DataSource.Project != null && DataSource.Project.Client != null)
                {
                    ClientTextView.Text       = DataSource.Project.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                if (DataSource.Task != null)
                {
                    TaskTextView.Text       = DataSource.Task.Name;
                    TaskTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    TaskTextView.Text       = String.Empty;
                    TaskTextView.Visibility = ViewStates.Gone;
                }

                var color = Color.Transparent;

                if (DataSource.Project != null)
                {
                    color = Color.ParseColor(DataSource.Project.GetHexColor());
                    ProjectTextView.SetTextColor(color);
                    if (String.IsNullOrWhiteSpace(DataSource.Project.Name))
                    {
                        ProjectTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNamelessProject);
                    }
                    else
                    {
                        ProjectTextView.Text = DataSource.Project.Name;
                    }
                }
                else
                {
                    ProjectTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNoProject);
                    ProjectTextView.SetTextColor(ctx.Resources.GetColor(Resource.Color.dark_gray_text));
                }

                var shape = ColorView.Background as GradientDrawable;

                if (shape != null)
                {
                    shape.SetColor(color);
                }

                if (String.IsNullOrWhiteSpace(DataSource.Description))
                {
                    if (DataSource.Task == null)
                    {
                        DescriptionTextView.Text       = ctx.GetString(Resource.String.RecentTimeEntryNoDescription);
                        DescriptionTextView.Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        DescriptionTextView.Visibility = ViewStates.Gone;
                    }
                }
                else
                {
                    DescriptionTextView.Text       = DataSource.Description;
                    DescriptionTextView.Visibility = ViewStates.Visible;
                }
            }
Ejemplo n.º 8
0
            public void Bind(TimeEntryHolder datasource)
            {
                DataSource = datasource;

                if (DataSource == null || Handle == IntPtr.Zero)
                {
                    return;
                }

                var color = Color.Transparent;
                var ctx   = ServiceContainer.Resolve <Context> ();

                if (!String.IsNullOrWhiteSpace(DataSource.ProjectName))
                {
                    color = Color.ParseColor(ProjectModel.HexColors [DataSource.Color % ProjectModel.HexColors.Length]);
                    ProjectTextView.SetTextColor(color);
                    ProjectTextView.Text = DataSource.ProjectName;
                }
                else
                {
                    ProjectTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNoProject);
                    ProjectTextView.SetTextColor(ctx.Resources.GetColor(Resource.Color.dark_gray_text));
                }

                if (String.IsNullOrWhiteSpace(DataSource.ClientName))
                {
                    ClientTextView.Text       = String.Empty;
                    ClientTextView.Visibility = ViewStates.Gone;
                }
                else
                {
                    ClientTextView.Text       = String.Format("{0} • ", DataSource.ClientName);
                    ClientTextView.Visibility = ViewStates.Visible;
                }

                if (String.IsNullOrWhiteSpace(DataSource.TaskName))
                {
                    TaskTextView.Text       = String.Empty;
                    TaskTextView.Visibility = ViewStates.Gone;
                }
                else
                {
                    TaskTextView.Text       = String.Format("{0} • ", DataSource.TaskName);
                    TaskTextView.Visibility = ViewStates.Visible;
                }

                if (String.IsNullOrWhiteSpace(DataSource.Description))
                {
                    DescriptionTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNoDescription);
                }
                else
                {
                    DescriptionTextView.Text = DataSource.Description;
                }

                BillableView.Visibility = DataSource.IsBillable ? ViewStates.Visible : ViewStates.Gone;


                var shape = ColorView.Background as GradientDrawable;

                if (shape != null)
                {
                    shape.SetColor(color);
                }

                RebindTags();
                RebindDuration();
            }
Ejemplo n.º 9
0
            public void Bind(ITimeEntryHolder datasource)
            {
                if (datasource == null || Handle == IntPtr.Zero)
                {
                    return;
                }

                var color = Color.Transparent;
                var ctx   = ServiceContainer.Resolve <Context> ();

                var authManager = ServiceContainer.Resolve <AuthManager> ();

                if (authManager.OfflineMode || (datasource.Data.RemoteId.HasValue && !datasource.Data.IsDirty))
                {
                    NotSyncedView.Visibility = ViewStates.Gone;
                }
                else
                {
                    NotSyncedView.Visibility = ViewStates.Visible;
                }
                var notSyncedShape = NotSyncedView.Background as GradientDrawable;

                if (datasource.Data.IsDirty && datasource.Data.RemoteId.HasValue)
                {
                    notSyncedShape.SetColor(ctx.Resources.GetColor(Resource.Color.light_gray));
                }
                else
                {
                    notSyncedShape.SetColor(ctx.Resources.GetColor(Resource.Color.material_red));
                }

                var info = datasource.Info;

                if (!string.IsNullOrWhiteSpace(info.ProjectData.Name))
                {
                    color = Color.ParseColor(ProjectModel.HexColors [info.Color % ProjectModel.HexColors.Length]);
                    ProjectTextView.SetTextColor(color);
                    ProjectTextView.Text = info.ProjectData.Name;
                }
                else
                {
                    ProjectTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNoProject);
                    ProjectTextView.SetTextColor(ctx.Resources.GetColor(Resource.Color.dark_gray_text));
                }

                if (string.IsNullOrWhiteSpace(info.ClientData.Name))
                {
                    ClientTextView.Text       = string.Empty;
                    ClientTextView.Visibility = ViewStates.Gone;
                }
                else
                {
                    ClientTextView.Text       = string.Format("{0} • ", info.ClientData.Name);
                    ClientTextView.Visibility = ViewStates.Visible;
                }

                if (string.IsNullOrWhiteSpace(info.TaskData.Name))
                {
                    TaskTextView.Text       = string.Empty;
                    TaskTextView.Visibility = ViewStates.Gone;
                }
                else
                {
                    TaskTextView.Text       = string.Format("{0} • ", info.TaskData.Name);
                    TaskTextView.Visibility = ViewStates.Visible;
                }

                if (string.IsNullOrWhiteSpace(info.Description))
                {
                    DescriptionTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNoDescription);
                }
                else
                {
                    DescriptionTextView.Text = info.Description;
                }

                BillableView.Visibility = info.IsBillable ? ViewStates.Visible : ViewStates.Gone;

                var shape = ColorView.Background as GradientDrawable;

                if (shape != null)
                {
                    shape.SetColor(color);
                }

                // Show start/stop btn
                if (datasource.Data.State == TimeEntryState.Running)
                {
                    ContinueImageButton.SetImageResource(Resource.Drawable.IcStop);
                }
                else
                {
                    ContinueImageButton.SetImageResource(Resource.Drawable.IcPlayArrowGrey);
                }

                // Set tag number
                var numberOfTags = datasource.Info.NumberOfTags;

                TagsView.BubbleCount = numberOfTags;
                TagsView.Visibility  = numberOfTags > 0 ? ViewStates.Visible : ViewStates.Gone;

                // Set duration
                duration  = datasource.GetDuration();
                isRunning = datasource.Data.State == TimeEntryState.Running;
                RebindDuration();
            }
Ejemplo n.º 10
0
            protected override void Rebind()
            {
                if (Model == null)
                {
                    return;
                }

                var ctx = ServiceContainer.Resolve <Context> ();

                if (Model.Project != null && Model.Project.Client != null)
                {
                    ClientTextView.Text       = Model.Project.Client.Name;
                    ClientTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    ClientTextView.Visibility = ViewStates.Gone;
                }

                if (Model.Task != null)
                {
                    TaskTextView.Text       = Model.Task.Name;
                    TaskTextView.Visibility = ViewStates.Visible;
                }
                else
                {
                    TaskTextView.Visibility = ViewStates.Gone;
                }

                var color = Color.Transparent;

                if (Model.Project != null)
                {
                    color = Color.ParseColor(Model.Project.GetHexColor());
                    ProjectTextView.SetTextColor(color);
                    if (String.IsNullOrWhiteSpace(Model.Project.Name))
                    {
                        ProjectTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNamelessProject);
                    }
                    else
                    {
                        ProjectTextView.Text = Model.Project.Name;
                    }
                }
                else
                {
                    ProjectTextView.Text = ctx.GetString(Resource.String.RecentTimeEntryNoProject);
                    ProjectTextView.SetTextColor(ctx.Resources.GetColor(Resource.Color.dark_gray_text));
                }

                var shape = ColorView.Background as GradientDrawable;

                if (shape != null)
                {
                    shape.SetColor(color);
                }

                if (String.IsNullOrWhiteSpace(Model.Description))
                {
                    if (Model.Task == null)
                    {
                        DescriptionTextView.Text       = ctx.GetString(Resource.String.RecentTimeEntryNoDescription);
                        DescriptionTextView.Visibility = ViewStates.Visible;
                    }
                    else
                    {
                        DescriptionTextView.Visibility = ViewStates.Gone;
                    }
                }
                else
                {
                    DescriptionTextView.Text       = Model.Description;
                    DescriptionTextView.Visibility = ViewStates.Visible;
                }
            }