Exemplo n.º 1
0
  private void changeStatus(int status) {
    task.setStatus(status);
    com.zavitz.mytasks.functions.PersistentUtils.save();

    this.status.setSelected(status);
    percent_complete.setTextQuiet(task.getPercentComplete() + "%");
  }
Exemplo n.º 2
0
  public TaskScreen(Task task) {
    super(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR);

    internalManager =
        new VerticalFieldManager(Manager.NO_VERTICAL_SCROLL | Manager.NO_VERTICAL_SCROLLBAR);
    super.add(internalManager);
    internalManager.add(new TitleField(TaskUtils.getPath(task)));

    manager = new VerticalFieldManager(Manager.VERTICAL_SCROLL | Manager.VERTICAL_SCROLLBAR);
    internalManager.add(manager);

    this.task = task;

    Font bold = getFont().derive(Font.BOLD);

    HeaderLabel name = new HeaderLabel(task.getName());
    name.setFont(bold);
    RichTextField description =
        new RichTextField(task.getDescription()) {
          public void paint(Graphics graphics) {
            graphics.setColor(0x00777777);
            super.paint(graphics);
          }
        };

    add(name);

    if (task.getPriority() != Task.NORMAL_PRIORITY) {
      BitmapInput priority =
          new BitmapInput(
              "Priority",
              task.getPriority() == Task.LOW_PRIORITY ? "low_priority.png" : "high_priority");
      priority.setEditable(false);
      priority.setSelected(task.getPriority());
      add(priority);
    }

    String statusRes = "";
    switch (task.getStatus()) {
      case Task.NOT_STARTED:
        statusRes = ("not_started.png");
        break;
      case Task.IN_PROGRESS:
        statusRes = ("progress.png");
        break;
      case Task.WAITING:
        statusRes = ("waiting.png");
        break;
      case Task.DEFERRED:
        statusRes = ("deferred.png");
        break;
      case Task.COMPLETED:
        statusRes = ("completed.png");
        break;
    }
    status = new BitmapInput("Status", statusRes);
    status.setEditable(false);
    status.setSelected(task.getStatus());
    add(status);

    percent_complete =
        new BitmapInput(
            "Percent Complete", task.getPercentComplete() + "% Complete", "percent_complete.png");
    percent_complete.setEditable(false);
    add(percent_complete);

    BitmapInput tags = new BitmapInput("Tags", "tags.png");
    tags.setTextQuiet(TaskUtils.getTags(task));
    tags.setEditable(false);
    add(tags);

    if (task.getDescription().length() > 0) add(description);

    Font header = getFont().derive(Font.BOLD, getFont().getHeight() - 4);
    HeaderLabel l_dr = new HeaderLabel("Due Date");
    l_dr.setFont(header);
    BitmapInput dueDate = new BitmapInput("Due Date", "soon.png");
    if (task.getDateDue() > 0) {
      dueDate.setTextQuiet(
          "Due date: "
              + new SimpleDateFormat(DateFormat.DATETIME_DEFAULT).formatLocal(task.getDateDue()));
      System.out.println("REMINDER: " + task.getDateDue());
    } else dueDate.setTextQuiet("No due date set.");
    dueDate.setEditable(false);
    BitmapInput reminder = new BitmapInput("Reminder", "reminder.png");
    if (task.getReminder() > 0) {
      reminder.setTextQuiet(
          "Reminder: "
              + new SimpleDateFormat(DateFormat.DATETIME_DEFAULT)
                  .formatLocal(task.getDateDue() - (task.getReminder() * 1000)));
      System.out.println("REMINDER: " + task.getReminder());
    } else reminder.setTextQuiet("No reminder set.");
    reminder.setEditable(false);
    add(l_dr);
    add(dueDate);
    add(reminder);
    if (task.getDateDue() > 0) {
      BitmapInput viewInCalendar = new BitmapInput("View in Calendar", "today.png");
      viewInCalendar.setTask(task);
      add(viewInCalendar);
    }

    HeaderLabel l_notes = new HeaderLabel("Notes");
    l_notes.setFont(header);
    notes = new NoteManager(task);
    add(l_notes);
    add(notes);
  }