Exemplo n.º 1
0
 @Override
 protected void restoreStateFromFreeze() {
   edSubject.setText(freeze.getString("subject"));
   chkAlarm.setChecked(freeze.getBoolean("alarm"));
   dateStart.setTimeInMillis(freeze.getLong("dateStart"));
   chkAllDay.setChecked(false);
   iRepeatType = freeze.getInt("repeatType");
   iRepeatEvery = freeze.getInt("repeatEvery");
   dateEndOn.setTimeInMillis(freeze.getLong("dateEndOn"));
 }
Exemplo n.º 2
0
  private void InitState() {
    // title
    String sSubTitle = utils.GetResStr(R.string.titleDefaultCourse);

    // date values
    dateStart = Calendar.getInstance();
    dateEndOn = Calendar.getInstance();

    dataRow.SetDuration(prefs.iMinutesDuration);

    // INSERT MODE
    if (GetStartMode() == StartMode.NEW) {
      sSubTitle = utils.GetResStr(R.string.titleNewCourse);
      btnDelete.setVisibility(View.INVISIBLE);

      // initialize data
      SetStartDateByAgendaView(dateStart);
      updateStartDateTimeForNewCourse(dateStart);
      SetStartTimeForDayAgendaView(dateStart);

      chkAllDay.setChecked(false);

      // repeat data
      iRepeatType = 0; // none
      iRepeatEvery = 1;
      dateEndOn.setTimeInMillis(0); // no end date
    }

    // EDIT MODE
    if (GetStartMode() == StartMode.EDIT) {
      sSubTitle = utils.GetResStr(R.string.titleEditCourse);

      dateStart.setTimeInMillis(dataRow.GetStartDate().getTimeInMillis());

      btnDelete.setVisibility(View.VISIBLE);
      edSubject.setText(dataRow.GetSubject());

      // repeat data
      iRepeatType = dataRow.GetRepeat().GetRepeatTypeAsInt();
      iRepeatEvery = dataRow.GetRepeat().GetEvery();
      dateEndOn.setTimeInMillis(dataRow.GetRepeat().GetEndOnDate().getTimeInMillis());
    }

    restoreStateFromFreezeIfRequired();

    SetActivityTitle(sSubTitle);
    UpdateStartDateTimeView();

    UpdateRepeatInfo();

    // set focus to subject
    edSubject.requestFocus();
    if (GetStartMode() == StartMode.EDIT) edSubject.setSelection(edSubject.length());
  }
Exemplo n.º 3
0
 @Override
 protected void onSaveInstanceState(Bundle outState) {
   super.onSaveInstanceState(outState);
   // save controls state
   outState.putString("subject", edSubject.getText().toString());
   outState.putBoolean("alarm", false);
   outState.putLong("dateStart", dateStart.getTimeInMillis());
   outState.putBoolean("allday", chkAllDay.isChecked());
   outState.putInt("repeatType", iRepeatType);
   outState.putInt("repeatEvery", iRepeatEvery);
   outState.putLong("dateEndOn", dateEndOn.getTimeInMillis());
 }
Exemplo n.º 4
0
 @Override
 public boolean DateValuesChanged(Bundle data) {
   super.DateValuesChanged(data);
   if (GetStartMode() == StartMode.EDIT) {
     if (dateStart.getTimeInMillis() != data.getLong("dateStart")) return true;
   }
   return false;
 }
Exemplo n.º 5
0
 private void SetStartTimeForDayAgendaView(Calendar calDate) {
   if (getIntent() != null) {
     Bundle extras = getIntent().getExtras();
     if (extras != null) {
       if (extras.containsKey(CommonActivity.bundleHourOfDay)) {
         int iView = extras.getInt(CommonActivity.bundleAgendaView);
         if (iView == 1) // day
         {
           int iHourOfDay = extras.getInt(CommonActivity.bundleHourOfDay);
           int iMinutes = extras.getInt(CommonActivity.bundleMinutes);
           calDate.set(Calendar.HOUR_OF_DAY, iHourOfDay);
           calDate.set(Calendar.MINUTE, iMinutes);
         }
       }
     }
   }
 }
Exemplo n.º 6
0
  @Override
  protected void onActivityResult(int requestCode, int resultCode, Intent data) {
    super.onActivityResult(requestCode, resultCode, data);

    Bundle extras = CommonActivity.getIntentExtras(data);
    if (extras != null) {
      // check for date widget edit request code
      if (requestCode == DateWidget.SELECT_DATE_REQUEST) {
        final long lDate =
            DateWidget.GetSelectedDateOnActivityResult(requestCode, resultCode, extras, dateStart);
        if (lDate != -1) {
          UpdateStartDateTimeView();
          return;
        }
      }

      // check for time widget edit request code
      if ((requestCode == TimeWidget.SELECT_TIME_REQUEST) && (resultCode == RESULT_OK)) {
        final int iHour =
            TimeWidget.GetSelectedTimeHourOnActivityResult(requestCode, resultCode, extras);
        final int iMinute =
            TimeWidget.GetSelectedTimeMinuteOnActivityResult(requestCode, resultCode, extras);
        dateStart.set(Calendar.HOUR_OF_DAY, iHour);
        dateStart.set(Calendar.MINUTE, iMinute);
        chkAllDay.setChecked(false);
        UpdateStartDateTimeView();
        return;
      }

      // get KeyboardWidget result
      if ((requestCode == KeyboardWidget.EDIT_TEXT_REQUEST) && (resultCode == RESULT_OK)) {
        String sText = KeyboardWidget.GetTextOnActivityResult(requestCode, resultCode, extras);
        edSubject.setText(sText);
        return;
      }
    }
  }
Exemplo n.º 7
0
 private void SetStartDateByAgendaView(Calendar calDate) {
   if (getIntent() != null) {
     Bundle extras = getIntent().getExtras();
     if (extras != null) {
       if (extras.containsKey(CommonActivity.bundleAgendaView)) {
         int iView = extras.getInt(CommonActivity.bundleAgendaView);
         if (iView == 1) // day
         {
           long lStartDate = extras.getLong(CommonActivity.bundleAgendaViewStartDate);
           calDate.setTimeInMillis(lStartDate);
         }
       }
     }
   }
 }
Exemplo n.º 8
0
  public void SaveData() {
    // check date if no repeat
    if ((iRepeatType == 0) && (DateBeforeNow(dateStart))) return;

    dataRow.SetSubject(edSubject.getText().toString());
    dataRow.SetStartDate(dateStart);
    dataRow.SetAllDay(false);
    dataRow.SetAlarm(false);

    // set repeat type
    RepeatData rd = dataRow.GetRepeat();
    rd.SetRepeatTypeAsInt(iRepeatType);
    rd.SetEvery(iRepeatEvery);
    rd.SetEndOnDate(dateEndOn.getTimeInMillis());

    if (SaveDataToTable(dataTable)) CloseActivity(dataTable);
  }
Exemplo n.º 9
0
  private void updateStartDateTimeForNewCourse(Calendar calDate) {
    int iHour = calDate.get(Calendar.HOUR_OF_DAY);
    int iMinute = calDate.get(Calendar.MINUTE);

    if (iHour < 23) iHour += 1;
    iMinute = 0;

    calDate.set(Calendar.HOUR_OF_DAY, iHour);
    calDate.set(Calendar.MINUTE, iMinute);
    calDate.set(Calendar.SECOND, 0);
    calDate.set(Calendar.MILLISECOND, 0);
  }
Exemplo n.º 10
0
 private String GetRepeatInfo() {
   String s = utils.GetResStr(R.string.strRepeatTypeNone);
   String sUntil = utils.GetResStr(R.string.strRepeatInfoUntil);
   String sEndDate =
       (dateEndOn.getTimeInMillis() == 0) ? "" : " " + sUntil + " " + utils.GetLongDate(dateEndOn);
   // daily
   if (iRepeatType == 1)
     s = String.format(utils.GetResStr(R.string.strRepeatInfoDaily), iRepeatEvery, sEndDate);
   // weekly
   if (iRepeatType == 2)
     s = String.format(utils.GetResStr(R.string.strRepeatInfoWeekly), iRepeatEvery, sEndDate);
   // monthly
   if (iRepeatType == 3)
     s = String.format(utils.GetResStr(R.string.strRepeatInfoMonthly), iRepeatEvery, sEndDate);
   // monthly
   if (iRepeatType == 4)
     s = String.format(utils.GetResStr(R.string.strRepeatInfoYearly), sEndDate);
   return s;
 }