Exemplo n.º 1
0
  void showDatePickerDialog() {
    final int tempYear = cYear;
    final int tempMonth = cMonth;
    final int tempDay = cDay;

    DatePickerDialog dialog =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {
              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                cYear = year;
                cMonth = monthOfYear + 1;
                cDay = dayOfMonth;
                loadDiary();
              }
            },
            cYear,
            cMonth - 1,
            cDay);

    dialog.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface arg0) {
            cYear = tempYear;
            cMonth = tempMonth;
            cDay = tempDay;
          }
        });

    dialog.setTitle("날짜 선택");

    dialog.show();
  }
Exemplo n.º 2
0
  @Override
  protected void onCreate(Bundle savedInstanceState) {

    final SharedPreferences sharedpreferences =
        getSharedPreferences("myPref", Context.MODE_PRIVATE);
    id = sharedpreferences.getInt("id", 0);
    Log.e("manual id", String.valueOf(id));

    super.onCreate(savedInstanceState);
    setContentView(R.layout.activity_manual_entry);

    tb1 = (Toolbar) findViewById(R.id.app_bar_manual);
    setSupportActionBar(tb1);

    date = (TextView) findViewById(R.id.date_manual);
    start1 = (EditText) findViewById(R.id.entry_time);
    exit1 = (EditText) findViewById(R.id.exit_time);
    break1_start1 = (EditText) findViewById(R.id.b1_start);
    break2_start1 = (EditText) findViewById(R.id.b2_start);
    break3_start1 = (EditText) findViewById(R.id.b3_start);

    break1_stop1 = (EditText) findViewById(R.id.b1_stop);
    break2_stop1 = (EditText) findViewById(R.id.b2_stop);
    break3_stop1 = (EditText) findViewById(R.id.b3_stop);

    edit = (Button) findViewById(R.id.edit);

    dbHelper = new DbHelper(getApplicationContext());
    try {
      dbHelper.openDataBase();
    } catch (SQLException e) {
      e.printStackTrace();
    }

    details = new String[8];

    final Calendar c = Calendar.getInstance();
    mYear = c.get(Calendar.YEAR);
    mMonth = c.get(Calendar.MONTH);
    mDay = c.get(Calendar.DAY_OF_MONTH);
    mHour = c.get(Calendar.HOUR_OF_DAY);
    mMinute = c.get(Calendar.MINUTE);

    DatePickerDialog dpd =
        new DatePickerDialog(
            this,
            new DatePickerDialog.OnDateSetListener() {

              @Override
              public void onDateSet(DatePicker view, int year, int monthOfYear, int dayOfMonth) {

                flag = 1;
                yearSelected = year;
                monthSelected = monthOfYear + 1;
                daySelected = dayOfMonth;

                if (daySelected >= mDay) {
                  Toast.makeText(
                          getApplication(), getString(R.string.manual_today), Toast.LENGTH_SHORT)
                      .show();
                  Intent intent = new Intent(getApplicationContext(), userHome.class);
                  finish();
                  startActivity(intent);
                }

                if (daySelected < 10 && monthSelected > 9) {
                  dates = "0" + daySelected + "-" + monthSelected + "-" + yearSelected;
                } else if (daySelected > 9 && monthSelected < 10) {
                  dates = daySelected + "-0" + monthSelected + "-" + yearSelected;
                } else if (daySelected < 10 && monthSelected < 10) {
                  dates = "0" + daySelected + "-0" + monthSelected + "-" + yearSelected;
                } else {
                  dates = daySelected + "-" + monthSelected + "-" + yearSelected;
                }

                date.setText(dates);
                details = dbHelper.getManualEntryDetails(id, dates);

                start1.setText(details[0]);
                break1_start1.setText(details[1]);
                break1_stop1.setText(details[2]);
                break2_start1.setText(details[3]);
                break2_stop1.setText(details[4]);
                break3_start1.setText(details[5]);
                break3_stop1.setText(details[6]);
                exit1.setText(details[7]);
              }
            },
            mYear,
            mMonth,
            mDay);
    dpd.setOnCancelListener(
        new DialogInterface.OnCancelListener() {
          @Override
          public void onCancel(DialogInterface dialog) {
            flag = 0;
            Intent intent = new Intent(getApplicationContext(), userHome.class);
            finish();
            startActivity(intent);
          }
        });
    dpd.show();

    start1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        entryhourSelected = hourOfDay;

                        entryminuteSelected = minute;

                        if (entryhourSelected < 10 && entryminuteSelected > 9) {
                          start1.setText("0" + entryhourSelected + ":" + entryminuteSelected);
                        } else if (entryhourSelected > 9 && entryminuteSelected < 10) {
                          start1.setText(entryhourSelected + ":0" + entryminuteSelected);
                        } else if (entryhourSelected < 10 && entryminuteSelected < 10) {
                          start1.setText("0" + entryhourSelected + ":0" + entryminuteSelected);
                        } else {
                          start1.setText(entryhourSelected + ":" + entryminuteSelected);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Enter Entry Time");
            timePickerDialog.show();
          }
        });

    break1_start1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        break1_hrs_start = hourOfDay;

                        break1_min_start = minute;

                        if (break1_hrs_start < 10 && break1_min_start > 9) {
                          break1_start1.setText("0" + break1_hrs_start + ":" + break1_min_start);
                        } else if (break1_hrs_start > 9 && break1_min_start < 10) {
                          break1_start1.setText(break1_hrs_start + ":0" + break1_min_start);
                        } else if (break1_hrs_start < 10 && break1_min_start < 10) {
                          break1_start1.setText("0" + break1_hrs_start + ":0" + break1_min_start);
                        } else {
                          break1_start1.setText(break1_hrs_start + ":" + break1_min_start);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Break1 Start");
            timePickerDialog.show();
          }
        });

    break1_stop1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        break1_hrs_stop = hourOfDay;

                        break1_min_stop = minute;

                        if (break1_hrs_stop < 10 && break1_min_stop > 9) {
                          break1_stop1.setText("0" + break1_hrs_stop + ":" + break1_min_stop);
                        } else if (break1_hrs_stop > 9 && break1_min_stop < 10) {
                          break1_stop1.setText(break1_hrs_stop + ":0" + break1_min_stop);
                        } else if (break1_hrs_stop < 10 && break1_min_stop < 10) {
                          break1_stop1.setText("0" + break1_hrs_stop + ":0" + break1_min_stop);
                        } else {
                          break1_stop1.setText(break1_hrs_stop + ":" + break1_min_stop);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Break1 Stop");
            timePickerDialog.show();
          }
        });

    break2_start1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        break2_hrs_start = hourOfDay;

                        break2_min_start = minute;

                        if (break2_hrs_start < 10 && break2_min_start > 9) {
                          break2_start1.setText("0" + break2_hrs_start + ":" + break2_min_start);
                        } else if (break2_hrs_start > 9 && break2_min_start < 10) {
                          break2_start1.setText(break2_hrs_start + ":0" + break2_min_start);
                        } else if (break2_hrs_start < 10 && break2_min_start < 10) {
                          break2_start1.setText("0" + break2_hrs_start + ":0" + break2_min_start);
                        } else {
                          break2_start1.setText(break2_hrs_start + ":" + break2_min_start);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Break2 Start");
            timePickerDialog.show();
          }
        });

    break2_stop1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        break2_hrs_stop = hourOfDay;

                        break2_min_stop = minute;

                        if (break2_hrs_stop < 10 && break2_min_stop > 9) {
                          break2_stop1.setText("0" + break2_hrs_stop + ":" + break2_min_stop);
                        } else if (break2_hrs_stop > 9 && break2_min_stop < 10) {
                          break2_stop1.setText(break2_hrs_stop + ":0" + break2_min_stop);
                        } else if (break2_hrs_stop < 10 && break2_min_start < 10) {
                          break2_stop1.setText("0" + break2_hrs_stop + ":0" + break2_min_stop);
                        } else {
                          break2_stop1.setText(break2_hrs_stop + ":" + break2_min_stop);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Break2 Stop");
            timePickerDialog.show();
          }
        });

    break3_start1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        break3_hrs_start = hourOfDay;

                        break3_min_start = minute;

                        if (break3_hrs_start < 10 && break3_min_start > 9) {
                          break3_start1.setText("0" + break3_hrs_start + ":" + break3_min_start);
                        } else if (break3_hrs_start > 9 && break3_min_start < 10) {
                          break3_start1.setText(break3_hrs_start + ":0" + break3_min_start);
                        } else if (break3_hrs_start < 10 && break3_min_start < 10) {
                          break3_start1.setText("0" + break3_hrs_start + ":0" + break3_min_start);
                        } else {
                          break3_start1.setText(break3_hrs_start + ":" + break3_min_start);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Break3 Start");
            timePickerDialog.show();
          }
        });

    break3_stop1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        break3_hrs_stop = hourOfDay;

                        break3_min_stop = minute;

                        if (break3_hrs_stop < 10 && break3_min_stop > 9) {
                          break3_stop1.setText("0" + break3_hrs_stop + ":" + break3_min_stop);
                        } else if (break3_hrs_stop > 9 && break3_min_stop < 10) {
                          break3_stop1.setText(break3_hrs_stop + ":0" + break3_min_stop);
                        } else if (break3_hrs_stop < 10 && break3_min_stop < 10) {
                          break3_stop1.setText("0" + break3_hrs_stop + ":0" + break3_min_stop);
                        } else {
                          break3_stop1.setText(break3_hrs_stop + ":" + break3_min_stop);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Break3 Stop");
            timePickerDialog.show();
          }
        });

    exit1.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {
            TimePickerDialog timePickerDialog;
            timePickerDialog =
                new TimePickerDialog(
                    manualEntry.this,
                    new TimePickerDialog.OnTimeSetListener() {
                      @Override
                      public void onTimeSet(TimePicker view, int hourOfDay, int minute) {

                        exithourSelected = hourOfDay;

                        exitminSelected = minute;

                        Log.e("Just to check", String.valueOf(exithourSelected));
                        if (exithourSelected < 10 && exitminSelected > 9) {
                          exit1.setText("0" + exithourSelected + ":" + exitminSelected);
                        } else if (exithourSelected > 9 && exitminSelected < 10) {
                          exit1.setText(exithourSelected + ":0" + exitminSelected);
                        } else if (exithourSelected < 10 && exitminSelected < 10) {
                          exit1.setText("0" + exithourSelected + ":0" + exitminSelected);
                        } else {
                          exit1.setText(exithourSelected + ":" + exitminSelected);
                        }
                      }
                    },
                    mHour,
                    mMinute,
                    true);
            timePickerDialog.setTitle("Enter Exit Time");
            timePickerDialog.show();
          }
        });

    edit.setOnClickListener(
        new View.OnClickListener() {
          @Override
          public void onClick(View v) {

            break3_stop = break3_stop1.getText().toString();
            break3_start = break3_start1.getText().toString();
            break1_start = break1_start1.getText().toString();
            break1_stop = break1_stop1.getText().toString();
            break2_stop = break2_stop1.getText().toString();
            break2_start = break2_start1.getText().toString();
            entry = start1.getText().toString();
            exit = exit1.getText().toString();

            if (entry.equals("")) {
              Toast.makeText(getApplicationContext(), "Entry Time not provided", Toast.LENGTH_SHORT)
                  .show();
            } else if ((!break2_start.equals("") && break2_stop.equals(""))
                || (!break1_start.equals("") && break1_stop.equals(""))
                || (!break3_start.equals("") && break3_stop.equals(""))) {

              Toast.makeText(
                      getApplicationContext(),
                      "Exit Time for break not Provided",
                      Toast.LENGTH_SHORT)
                  .show();
            } else if (exit.equals("")) {

              Toast.makeText(getApplicationContext(), "Exit Time not Provided", Toast.LENGTH_SHORT)
                  .show();
            } else {
              dbHelper.updateManualEntry(
                  id,
                  entry,
                  exit,
                  break1_start,
                  break2_start,
                  break3_start,
                  break1_stop,
                  break2_stop,
                  break3_stop,
                  dates);

              start1.setText("");
              exit1.setText("");
              break1_start1.setText("");
              break1_stop1.setText("");
              break2_start1.setText("");
              break2_stop1.setText("");
              break3_start1.setText("");
              break3_stop1.setText("");
              Toast.makeText(getApplication(), "UPDATE DONE", Toast.LENGTH_SHORT).show();

              edit.setEnabled(false);
              edit.setVisibility(View.INVISIBLE);
            }
          }
        });

    drawerLayout = (DrawerLayout) findViewById(R.id.drawlay_manual); /*Drawer*/
    nv1 = (NavigationView) findViewById(R.id.draw_manual);
    abdt =
        new ActionBarDrawerToggle(
            this, drawerLayout, tb1, R.string.drawer_open, R.string.drawer_close);
    drawerLayout.setDrawerListener(abdt);
    abdt.syncState();
    drawerLayout.post(
        new Runnable() {
          @Override
          public void run() {
            abdt.syncState();
          }
        });
    nv1.setNavigationItemSelectedListener(
        new NavigationView.OnNavigationItemSelectedListener() {
          @Override
          public boolean onNavigationItemSelected(MenuItem menuItem) {
            switch (menuItem.getItemId()) {
              case R.id.home:
                {
                  Intent home = new Intent(getApplicationContext(), userHome.class);
                  finish();
                  startActivity(home);
                  break;
                }
              case R.id.month:
                {
                  Intent month = new Intent(getApplicationContext(), MonthReport.class);
                  finish();
                  startActivity(month);
                  break;
                }

              case R.id.day:
                Intent intent1 = new Intent(getApplicationContext(), DayReport.class);
                finish();
                startActivity(intent1);
                break;

              case R.id.manual:
                Toast.makeText(getApplicationContext(), "This is Manual Entry", Toast.LENGTH_SHORT)
                    .show();
                break;
              case R.id.logout:
                final SharedPreferences sharedpreferences1 =
                    getSharedPreferences("Login", Context.MODE_PRIVATE);
                SharedPreferences.Editor editor = sharedpreferences1.edit();

                editor.remove("uname");
                editor.remove("pass");
                editor.commit();
                Intent logout = new Intent(getApplicationContext(), MainActivity.class);
                finish();
                startActivity(logout);
                break;
            }
            drawerLayout.closeDrawers();
            return true;
          }
        });
  }
Exemplo n.º 3
0
  /**
   * Called when a view has been clicked.
   *
   * @param v The view that was clicked.
   */
  @Override
  public void onClick(View v) {
    final DateFormat dateFormat =
        new SimpleDateFormat(editTaskScreen.getString(R.string.date_format));
    final DateFormat dateFormatInput =
        new SimpleDateFormat(editTaskScreen.getString(R.string.date_format_input));
    final View view = v;
    final Calendar c;

    switch (v.getId()) {
      case (R.id.button_save_task):
        // confirm task information button
        c = Calendar.getInstance();

        final String textTaskTittle = editTaskScreen.getTaskTittle().getText().toString();
        final String textTaskNotes = editTaskScreen.getTaskNote().getText().toString();

        final String textTaskDueDate = taskBundle.getString("Due Date", "");
        final String textPriority = taskBundle.getString("Parent");

        Log.v("Things.DO", "Confirm add task \"" + textTaskTittle + "\"");

        // load selected task information
        Intent resultTask = new Intent(editTaskScreen, MainScreen.class);

        resultTask.putExtra("Task ID", taskBundle.getInt("Task ID"));
        resultTask.putExtra("Google ID", taskBundle.getString("Google ID"));
        resultTask.putExtra("Tittle", textTaskTittle);
        resultTask.putExtra("Update Date", dateFormat.format(c.getTime()));
        resultTask.putExtra("Parent", textPriority);
        resultTask.putExtra("Notes", textTaskNotes);
        resultTask.putExtra("Status", "needsAction");
        resultTask.putExtra("Due Date", textTaskDueDate);
        resultTask.putExtra("Completed Date", "");
        resultTask.putExtra("Category", taskBundle.getString("Category"));

        String collaborators = "";
        for (int i = 0; i < editTaskScreen.getCollaborators().size(); i++) {
          collaborators += editTaskScreen.getCollaborators().get(i).exportForSQLite(i);
        }
        resultTask.putExtra("Collaborators", collaborators);

        if (taskBundle.getString("Old Category") != null) {
          resultTask.putExtra("Old Category", taskBundle.getString("Old Category"));
          resultTask.putExtra("Old Task Position", taskBundle.getInt("Old Task Position"));
        }

        editTaskScreen.setResult(Activity.RESULT_OK, resultTask);

        editTaskScreen.finish();
        break;

      case (R.id.button_task_due_date):
        // edit due date button
        final String oldDueDate = taskBundle.getString("Due Date");
        c = Calendar.getInstance();

        int mYear = c.get(Calendar.YEAR);
        int mMonth = c.get(Calendar.MONTH);
        int mDay = c.get(Calendar.DAY_OF_MONTH);

        // if task is not a new task and has a due date
        if (!taskBundle.getString("Due Date", "None").equals("None")) {
          try {
            Date oldDate = dateFormat.parse(taskBundle.getString("Due Date"));

            Calendar oldCalendar = Calendar.getInstance();
            oldCalendar.setTime(oldDate);

            mYear = oldCalendar.get(Calendar.YEAR);
            mMonth = oldCalendar.get(Calendar.MONTH);
            mDay = oldCalendar.get(Calendar.DAY_OF_MONTH);

          } catch (ParseException e) {
            e.printStackTrace();
          }
        }

        DatePickerDialog datePickerDialog =
            new DatePickerDialog(
                editTaskScreen,
                new DatePickerDialog.OnDateSetListener() {

                  @Override
                  public void onDateSet(
                      DatePicker view, int year, int monthOfYear, int dayOfMonth) {
                    Date pickedDate = Calendar.getInstance().getTime();

                    try {
                      pickedDate =
                          dateFormatInput.parse(
                              year + "/" + (monthOfYear + 1) + "/" + dayOfMonth + " 00:00:00.000");
                    } catch (ParseException e) {
                      e.printStackTrace();
                    }

                    Log.v("Things.DO", "Date chosen: " + dateFormat.format(pickedDate));
                    taskBundle.putString("Due Date", dateFormat.format(pickedDate));

                    String dueDate = taskBundle.getString("Due Date");

                    if (!dueDate.equals("None")) {
                      Date date = Calendar.getInstance().getTime();

                      try {
                        date =
                            (new SimpleDateFormat(editTaskScreen.getString(R.string.date_format)))
                                .parse(dueDate);
                      } catch (ParseException e) {
                        e.printStackTrace();
                      }

                      dueDate =
                          (new SimpleDateFormat(
                                  editTaskScreen.getString(R.string.date_format_display)))
                              .format(date);
                    }

                    editTaskScreen.getSetDueDate().setText(dueDate);
                  }
                },
                mYear,
                mMonth,
                mDay);

        datePickerDialog.setOnCancelListener(
            new DialogInterface.OnCancelListener() {
              @Override
              public void onCancel(DialogInterface dialog) {
                Log.v("Things.DO", "Date picker cancel");
                taskBundle.putString("Due Date", oldDueDate);

                String date = "None";
                if (!oldDueDate.equals("None")) {
                  try {
                    date =
                        (new SimpleDateFormat(
                                editTaskScreen.getString(R.string.date_format_display)))
                            .format(
                                (new SimpleDateFormat(
                                        editTaskScreen.getString(R.string.date_format)))
                                    .parse(oldDueDate));
                  } catch (ParseException e) {
                    e.printStackTrace();
                  }
                }

                editTaskScreen.getSetDueDate().setText(date);
              }
            });

        datePickerDialog.setCancelable(true);
        datePickerDialog.setCanceledOnTouchOutside(true);
        datePickerDialog.setMessage(editTaskScreen.getString(R.string.text_date_picker_question));

        datePickerDialog.show();
        break;

      case (R.id.button_task_priority):
        // edit priority button
        // get dialog builder
        AlertDialog.Builder builder = new AlertDialog.Builder(editTaskScreen);

        // priority options
        final String[] choice = {"Urgent", "High", "Medium", "Low"};

        // try to get task priority
        final String oldPriority = taskBundle.getString("Parent", "Medium");

        int currentChoiceIndex = 0;

        // set default choice
        for (int i = 0; i < choice.length; i++) {
          if (choice[i].equals(oldPriority)) {
            currentChoiceIndex = i;
            break;
          }
        }

        // display dialog
        builder
            .setIconAttribute(android.R.attr.alertDialogIcon)
            .setTitle(editTaskScreen.getString(R.string.text_priority_tittle))
            .setSingleChoiceItems(
                choice,
                currentChoiceIndex,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    Log.v("Things.DO", "Choice: " + choice[whichButton]);
                    taskBundle.putString("Parent", choice[whichButton]);

                    editTaskScreen.getSetTaskPriority().setText(choice[whichButton]);

                    if (choice[whichButton].equals("Urgent")) {
                      ((Button) view)
                          .setCompoundDrawablesWithIntrinsicBounds(
                              null,
                              editTaskScreen
                                  .getResources()
                                  .getDrawable(R.drawable.ic_priority_urgent),
                              null,
                              null);
                    } else {
                      ((Button) view)
                          .setCompoundDrawablesWithIntrinsicBounds(
                              null,
                              editTaskScreen.getResources().getDrawable(R.drawable.ic_priority),
                              null,
                              null);
                    }
                  }
                })
            .setPositiveButton(
                "OK",
                new DialogInterface.OnClickListener() {
                  /**
                   * This method will be invoked when a button in the dialog is clicked.
                   *
                   * @param dialog The dialog that received the click.
                   * @param which The button that was clicked (e.g. {@link
                   *     android.content.DialogInterface#BUTTON1}) or the position
                   */
                  @Override
                  public void onClick(DialogInterface dialog, int which) {}
                })
            .setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  /**
                   * This method will be invoked when a button in the dialog is clicked.
                   *
                   * @param dialog The dialog that received the click.
                   * @param which The button that was clicked (e.g. {@link
                   *     android.content.DialogInterface#BUTTON1}) or the position
                   */
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    taskBundle.putString("Parent", oldPriority);

                    editTaskScreen.getSetTaskPriority().setText(oldPriority);
                  }
                })
            .create();

        builder.show();
        break;

      case (R.id.button_task_category):
        // edit category
        // get dialog builder
        builder = new AlertDialog.Builder(editTaskScreen);

        // category options
        final String[] categories = taskBundle.getStringArray("Category List");

        // try to get task priority
        final String oldCategory = taskBundle.getString("Category", "Personal");

        currentChoiceIndex = 0;

        // set default choice
        for (int i = 0; i < categories.length; i++) {
          if (categories[i].equals(oldCategory)) {
            currentChoiceIndex = i;
            break;
          }
        }

        // display dialog
        builder
            .setIconAttribute(android.R.attr.alertDialogIcon)
            .setTitle(editTaskScreen.getString(R.string.text_priority_tittle))
            .setSingleChoiceItems(
                categories,
                currentChoiceIndex,
                new DialogInterface.OnClickListener() {
                  public void onClick(DialogInterface dialog, int whichButton) {
                    Log.v("Things.DO", "Choice: " + categories[whichButton]);
                    taskBundle.putString("Category", categories[whichButton]);

                    editTaskScreen.getSetTaskCategory().setText(categories[whichButton]);
                  }
                })
            .setPositiveButton(
                "OK",
                new DialogInterface.OnClickListener() {
                  /**
                   * This method will be invoked when a button in the dialog is clicked.
                   *
                   * @param dialog The dialog that received the click.
                   * @param which The button that was clicked (e.g. {@link
                   *     android.content.DialogInterface#BUTTON1}) or the position
                   */
                  @Override
                  public void onClick(DialogInterface dialog, int which) {}
                })
            .setNegativeButton(
                "Cancel",
                new DialogInterface.OnClickListener() {
                  /**
                   * This method will be invoked when a button in the dialog is clicked.
                   *
                   * @param dialog The dialog that received the click.
                   * @param which The button that was clicked (e.g. {@link
                   *     android.content.DialogInterface#BUTTON1}) or the position
                   */
                  @Override
                  public void onClick(DialogInterface dialog, int which) {
                    taskBundle.putString("Category", oldCategory);

                    editTaskScreen.getSetTaskCategory().setText(oldCategory);
                  }
                })
            .create();

        builder.show();
        break;

      case (R.id.button_task_add_collaborator):
        editTaskScreen.showContactPicker();

        break;
    }
  }