Exemplo n.º 1
0
        public static ChangeDateTimeDialogFragment NewInstance(DateTime initialTime, string dialogTitle)
        {
            var fragment = new ChangeDateTimeDialogFragment();

            var args = new Bundle();

            // Save time without second or millisecond component
            // cause neither of this components will be edited.
            args.PutLong(InitialTimeArgument, GetTrunkedTime(initialTime).Ticks);
            args.PutString(DialogTitleArgument, dialogTitle);
            fragment.Arguments = args;

            return(fragment);
        }
        public static ChangeDateTimeDialogFragment NewInstance (DateTime initialTime, string dialogTitle)
        {
            var fragment = new ChangeDateTimeDialogFragment ();

            var args = new Bundle ();

            // Save time without second or millisecond component
            // cause neither of this components will be edited.
            args.PutLong (InitialTimeArgument, GetTrunkedTime (initialTime).Ticks);
            args.PutString (DialogTitleArgument, dialogTitle);
            fragment.Arguments = args;

            return fragment;
        }
Exemplo n.º 3
0
        public async override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            ViewModel = await EditTimeEntryViewModel.Init(TimeEntryId);

            // TODO: in theory, this event could be binded but
            // the event "CheckedChange" isn't found when
            // the app is compiled for release. Investigate!
            BillableCheckBox.CheckedChange += (sender, e) => {
                ViewModel.ChangeBillable(BillableCheckBox.Checked);
            };

            DescriptionField.TextField.TextChanged += (sender, e) => {
                ViewModel.ChangeDescription(DescriptionField.TextField.Text);
            };

            DurationTextView.Click += (sender, e) => {
                // TODO: Don't edit duration if Time entry is running?
                if (ViewModel.IsRunning)
                {
                    return;
                }
                ChangeTimeEntryDurationDialogFragment.NewInstance(ViewModel.StopDate, ViewModel.StartDate)
                .SetChangeDurationHandler(this)
                .Show(FragmentManager, "duration_dialog");
            };

            StartTimeEditText.Click += (sender, e) => {
                var title = GetString(Resource.String.ChangeTimeEntryStartTimeDialogTitle);
                ChangeDateTimeDialogFragment.NewInstance(ViewModel.StartDate, title)
                .SetOnChangeTimeHandler(this)
                .Show(FragmentManager, "start_time_dialog");
            };

            StopTimeEditText.Click += (sender, e) => {
                var title = GetString(Resource.String.ChangeTimeEntryStopTimeDialogTitle);
                ChangeDateTimeDialogFragment.NewInstance(ViewModel.StopDate, title)
                .SetOnChangeTimeHandler(this)
                .Show(FragmentManager, "stop_time_dialog");
            };

            ProjectField.TextField.Click += (sender, e) => OpenProjectListActivity();
            ProjectField.Click           += (sender, e) => OpenProjectListActivity();
            TagsField.OnPressTagField    += OnTagsEditTextClick;

            durationBinding  = this.SetBinding(() => ViewModel.Duration, () => DurationTextView.Text);
            startTimeBinding = this.SetBinding(() => ViewModel.StartDate, () => StartTimeEditText.Text)
                               .ConvertSourceToTarget(dateTime => dateTime.ToDeviceTimeString());
            stopTimeBinding = this.SetBinding(() => ViewModel.StopDate, () => StopTimeEditText.Text)
                              .ConvertSourceToTarget(dateTime => dateTime.ToDeviceTimeString());
            projectBinding = this.SetBinding(() => ViewModel.ProjectName, () => ProjectField.TextField.Text);
            clientBinding  = this.SetBinding(() => ViewModel.ClientName, () => ProjectField.AssistViewTitle);
            tagBinding     = this.SetBinding(() => ViewModel.TagList, () => TagsField.TagNames)
                             .ConvertSourceToTarget(tagList => tagList.Select(tag => tag.Name).ToList());
            descriptionBinding = this.SetBinding(() => ViewModel.Description, () => DescriptionField.TextField.Text);
            isPremiumBinding   = this.SetBinding(() => ViewModel.IsPremium, () => BillableCheckBox.Visibility)
                                 .ConvertSourceToTarget(isVisible => isVisible ? ViewStates.Visible : ViewStates.Gone);
            isRunningBinding = this.SetBinding(() => ViewModel.IsRunning).WhenSourceChanges(() => {
                StopTimeEditText.Visibility  = ViewModel.IsRunning ? ViewStates.Gone : ViewStates.Visible;
                stopTimeEditLabel.Visibility = ViewModel.IsRunning ? ViewStates.Gone : ViewStates.Visible;
            });
            isBillableBinding = this.SetBinding(() => ViewModel.IsBillable, () => BillableCheckBox.Checked);
            billableBinding   = this.SetBinding(() => ViewModel.IsBillable)
                                .WhenSourceChanges(() => {
                var label             = ViewModel.IsBillable ? GetString(Resource.String.CurrentTimeEntryEditBillableChecked) : GetString(Resource.String.CurrentTimeEntryEditBillableUnchecked);
                BillableCheckBox.Text = label;
            });

            // If project list needs to be opened?
            var settingsStore = ServiceContainer.Resolve <SettingsStore> ();

            if (settingsStore.ChooseProjectForNew && LogTimeEntriesListFragment.NewTimeEntry)
            {
                OpenProjectListActivity();
            }
            else if (LogTimeEntriesListFragment.NewTimeEntry)
            {
                DescriptionField.RequestFocus();
                ((EditTimeEntryActivity)Activity).ShowSoftKeyboard(DescriptionField.TextField, false);
                LogTimeEntriesListFragment.NewTimeEntry = false;
            }
            else
            {
                DescriptionField.ClearFocus();
            }

            // Finally set content visible.
            editTimeEntryContent.Visibility     = ViewStates.Visible;
            editTimeEntryProgressBar.Visibility = ViewStates.Gone;
        }
Exemplo n.º 4
0
        public async override void OnViewCreated(View view, Bundle savedInstanceState)
        {
            base.OnViewCreated(view, savedInstanceState);
            ViewModel = await EditTimeEntryViewModel.Init(TimeEntryId);

            // TODO: in theory, this event could be binded but
            // the event "CheckedChange" isn't found when
            // the app is compiled for release. Investigate!
            BillableCheckBox.CheckedChange += (sender, e) => {
                ViewModel.IsBillable = BillableCheckBox.Checked;
            };

            DurationTextView.Click += (sender, e) =>
                                      ChangeTimeEntryDurationDialogFragment.NewInstance(ViewModel.StopDate, ViewModel.StartDate)
                                      .SetChangeDurationHandler(this)
                                      .Show(FragmentManager, "duration_dialog");

            StartTimeEditText.Click += (sender, e) => {
                var title = GetString(Resource.String.ChangeTimeEntryStartTimeDialogTitle);
                ChangeDateTimeDialogFragment.NewInstance(ViewModel.StartDate, title)
                .SetOnChangeTimeHandler(this)
                .Show(FragmentManager, "start_time_dialog");
            };

            StopTimeEditText.Click += (sender, e) => {
                var title = GetString(Resource.String.ChangeTimeEntryStopTimeDialogTitle);
                ChangeDateTimeDialogFragment.NewInstance(ViewModel.StopDate, title)
                .SetOnChangeTimeHandler(this)
                .Show(FragmentManager, "stop_time_dialog");
            };

            ProjectField.TextField.Click += (sender, e) => OpenProjectListActivity();
            ProjectField.Click           += (sender, e) => OpenProjectListActivity();
            TagsField.OnPressTagField    += OnTagsEditTextClick;

            durationBinding  = this.SetBinding(() => ViewModel.Duration, () => DurationTextView.Text);
            startTimeBinding = this.SetBinding(() => ViewModel.StartDate, () => StartTimeEditText.Text)
                               .ConvertSourceToTarget(dateTime => dateTime.ToDeviceTimeString());
            stopTimeBinding = this.SetBinding(() => ViewModel.StopDate, () => StopTimeEditText.Text)
                              .ConvertSourceToTarget(dateTime => dateTime.ToDeviceTimeString());
            projectBinding = this.SetBinding(() => ViewModel.ProjectName, () => ProjectField.TextField.Text);
            clientBinding  = this.SetBinding(() => ViewModel.ClientName, () => ProjectField.AssistViewTitle);
            tagBinding     = this.SetBinding(() => ViewModel.TagList, () => TagsField.TagNames)
                             .ConvertSourceToTarget(tagList => tagList.Select(tag => tag.Name).ToList());
            descriptionBinding = this.SetBinding(() => ViewModel.Description, () => DescriptionField.TextField.Text, BindingMode.TwoWay);
            isPremiumBinding   = this.SetBinding(() => ViewModel.IsPremium, () => BillableCheckBox.Visibility)
                                 .ConvertSourceToTarget(isVisible => isVisible ? ViewStates.Visible : ViewStates.Gone);
            isRunningBinding = this.SetBinding(() => ViewModel.IsRunning).WhenSourceChanges(() => {
                StopTimeEditText.Visibility  = ViewModel.IsRunning ? ViewStates.Gone : ViewStates.Visible;
                stopTimeEditLabel.Visibility = ViewModel.IsRunning ? ViewStates.Gone : ViewStates.Visible;
            });
            isBillableBinding = this.SetBinding(() => ViewModel.IsBillable, () => BillableCheckBox.Checked);
            billableBinding   = this.SetBinding(() => ViewModel.IsBillable)
                                .WhenSourceChanges(() => {
                var label             = ViewModel.IsBillable ? GetString(Resource.String.CurrentTimeEntryEditBillableChecked) : GetString(Resource.String.CurrentTimeEntryEditBillableUnchecked);
                BillableCheckBox.Text = label;
            });
            saveMenuBinding = this.SetBinding(() => ViewModel.IsManual)
                              .WhenSourceChanges(() => {
                if (SaveMenuItem != null)
                {
                    SaveMenuItem.SetVisible(ViewModel.IsManual);
                }
            });

            // Configure option menu.
            ConfigureOptionMenu();

            // If project list needs to be opened?
            var settingsStore = ServiceContainer.Resolve <SettingsStore> ();

            if (settingsStore.ChooseProjectForNew && LogTimeEntriesListFragment.NewTimeEntryStartedByFAB)
            {
                LogTimeEntriesListFragment.NewTimeEntryStartedByFAB = false;
                OpenProjectListActivity();
            }
        }