public void onTouch(Cell cell) {
    selectedCell = cell;
    mStateHolder.mSavedSelectedCell = cell;

    if (cell.getOvertime().equals("") && cell.getShift().equals("") && !cell.existsDailyNote()) {
      Toast.makeText(getApplicationContext(), R.string.long_press_help, Toast.LENGTH_SHORT).show();
      return;
    }
    Bundle data = new Bundle();
    Calendar c = Calendar.getInstance();
    c.set(Calendar.YEAR, mCalendarView.getYear());
    c.set(Calendar.MONTH, mCalendarView.getMonth());
    c.set(Calendar.DAY_OF_MONTH, cell.getDayOfMonth());
    data.putSerializable("date", df.format(c.getTime()));
    float totalHours = 0;
    if (!cell.getOvertime().equals("")) {
      mDatabase = mDatabase.open();
      long overtimeMinutes = mDatabase.getOvertime(c);
      mDatabase.close();
      data.putString("overtime", Helper.formatInterval(overtimeMinutes));
      totalHours += overtimeMinutes / 60f;
    } else {
      data.putString("overtime", getString(R.string.unknown));
    }
    if (cell.existsDailyNote()) {
      mDatabase = mDatabase.open();
      String dailyNotes = mDatabase.getDailyNote(c);
      mDatabase.close();
      data.putString("dailyNotes", dailyNotes);
    } else {
      data.putString("dailyNotes", getString(R.string.unknown));
    }
    if (!cell.getShift().equals("")) {
      Shift s = mShiftTable.get(selectedCell.getShift());
      if (s == null) {
        mDatabase = mDatabase.open();
        s = mDatabase.getShiftObject(c);
        mDatabase.close();
        data.putString("shift", selectedCell.getShift());
      }
      data.putString("shift", s.getName());
      totalHours += s.getHours();
    } else {
      data.putString("shift", getString(R.string.unknown));
    }
    String totalHoursString = Helper.formatInterval(totalHours);
    data.putString("hours", totalHoursString);
    showDialog(DIALOG_DAY_DETAIL, data);
  }
 @Override
 protected void onPrepareDialog(final int id, final Dialog dialog, Bundle bundle) {
   super.onPrepareDialog(id, dialog);
   switch (id) {
     case DIALOG_SET_WORK_SHIFT_ID:
       currentItems = (ArrayList<String>) dialogItems.clone();
       ListView dropdown = ((AlertDialog) dialog).getListView();
       if (selectedCell == null) break;
       boolean shiftSet = selectedCell.getShift().length() == 0 ? false : true;
       boolean overtimeSet = selectedCell.getOvertime().length() == 0 ? false : true;
       boolean dailyNotesSet = selectedCell.existsDailyNote();
       if (shiftSet) {
         currentItems.add(0, getString(R.string.change_shift));
         currentItems.add(getString(R.string.delete));
       }
       if (overtimeSet) {
         currentItems.add(getString(R.string.overtime_delete));
       }
       if (dailyNotesSet) {
         currentItems.add(getString(R.string.daily_notes_delete));
       }
       String[] itemArray = new String[currentItems.size()];
       itemArray = currentItems.toArray(itemArray);
       dropdown.setAdapter(
           new ArrayAdapter<CharSequence>(this, android.R.layout.select_dialog_item, itemArray));
       break;
     case DIALOG_CHANGE_WORK_SHIFT_ID:
       ListView dropdown2 = ((AlertDialog) dialog).getListView();
       dropdown2.setAdapter(
           new ArrayAdapter<CharSequence>(this, android.R.layout.select_dialog_item, changeItems));
       break;
     case DIALOG_DAILYNOTES_ID:
       EditText dailyNotesET = (EditText) dialog.findViewById(R.id.dailynotes_edit_text);
       if (bundle != null) {
         dailyNotesET.setText(bundle.getString("dailyNotes"));
       } else {
         dailyNotesET.setText("");
       }
       break;
     case DIALOG_DAY_DETAIL:
       dialog.setTitle(getString(R.string.detail) + ": " + bundle.getString("date"));
       TextView shiftTV = (TextView) dialog.findViewById(R.id.dialog_day_detail_workshift);
       TextView overtimeTV = (TextView) dialog.findViewById(R.id.dialog_day_detail_overtime);
       TextView totalHoursTV = (TextView) dialog.findViewById(R.id.dialog_day_detail_total_hours);
       TextView dailyNotesTV = (TextView) dialog.findViewById(R.id.dialog_day_detail_dailyNotes);
       shiftTV.setText(bundle.getString("shift"));
       overtimeTV.setText(bundle.getString("overtime"));
       totalHoursTV.setText(bundle.getString("hours"));
       dailyNotesTV.setText(bundle.getString("dailyNotes"));
       break;
   }
 }