|
|
|
@ -88,8 +88,8 @@ import com.timsu.astrid.widget.TimeDurationControlSet.TimeDurationType;
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* This activity is responsible for creating new tasks and editing existing
|
|
|
|
* This activity is responsible for creating new tasks and editing existing
|
|
|
|
* ones. It saves a task when it is paused (screen rotated, back button pressed)
|
|
|
|
* ones. It saves a task when it is paused (screen rotated, back button
|
|
|
|
* as long as the task has a title.
|
|
|
|
* pressed) as long as the task has a title.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @author timsu
|
|
|
|
* @author timsu
|
|
|
|
*
|
|
|
|
*
|
|
|
|
@ -192,11 +192,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
return controller.createNewTaskForEdit();
|
|
|
|
return controller.createNewTaskForEdit();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/* ======================================================================
|
|
|
|
* ======================================================================
|
|
|
|
|
|
|
|
* =============================================== model reading / saving
|
|
|
|
* =============================================== model reading / saving
|
|
|
|
* ======================================================================
|
|
|
|
* ====================================================================== */
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Populate UI component values from the model */
|
|
|
|
/** Populate UI component values from the model */
|
|
|
|
private void populateFields() {
|
|
|
|
private void populateFields() {
|
|
|
|
@ -216,8 +214,10 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(model.getName().length() > 0)
|
|
|
|
if(model.getName().length() > 0)
|
|
|
|
setTitle(new StringBuilder().append(r.getString(R.string.taskEdit_titlePrefix)).append(" ").append(
|
|
|
|
setTitle(new StringBuilder().
|
|
|
|
model.getName()));
|
|
|
|
append(r.getString(R.string.taskEdit_titlePrefix)).
|
|
|
|
|
|
|
|
append(" ").
|
|
|
|
|
|
|
|
append(model.getName()));
|
|
|
|
estimatedDuration.setTimeDuration(model.getEstimatedSeconds());
|
|
|
|
estimatedDuration.setTimeDuration(model.getEstimatedSeconds());
|
|
|
|
elapsedDuration.setTimeDuration(model.getElapsedSeconds());
|
|
|
|
elapsedDuration.setTimeDuration(model.getElapsedSeconds());
|
|
|
|
importance.setImportance(model.getImportance());
|
|
|
|
importance.setImportance(model.getImportance());
|
|
|
|
@ -241,7 +241,8 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
if(model.getTaskIdentifier() != null) {
|
|
|
|
if(model.getTaskIdentifier() != null) {
|
|
|
|
taskTags = tagController.getTaskTags(model.getTaskIdentifier());
|
|
|
|
taskTags = tagController.getTaskTags(model.getTaskIdentifier());
|
|
|
|
if(taskTags.size() > 0) {
|
|
|
|
if(taskTags.size() > 0) {
|
|
|
|
Map<TagIdentifier, TagModelForView> tagsMap = new HashMap<TagIdentifier, TagModelForView>();
|
|
|
|
Map<TagIdentifier, TagModelForView> tagsMap =
|
|
|
|
|
|
|
|
new HashMap<TagIdentifier, TagModelForView>();
|
|
|
|
for(TagModelForView tag : tags)
|
|
|
|
for(TagModelForView tag : tags)
|
|
|
|
tagsMap.put(tag.getTagIdentifier(), tag);
|
|
|
|
tagsMap.put(tag.getTagIdentifier(), tag);
|
|
|
|
for(TagIdentifier id : taskTags) {
|
|
|
|
for(TagIdentifier id : taskTags) {
|
|
|
|
@ -326,11 +327,8 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Displays a Toast reporting that the selected task has been saved and is
|
|
|
|
* Displays a Toast reporting that the selected task has been saved and is
|
|
|
|
* due in 'x' amount of time, to 2 time-units of precision (e.g. Days +
|
|
|
|
* due in 'x' amount of time, to 2 time-units of precision (e.g. Days + Hours).
|
|
|
|
* Hours).
|
|
|
|
* @param dueDate the Date when the task is due
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param dueDate
|
|
|
|
|
|
|
|
* the Date when the task is due
|
|
|
|
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void showSaveToast(Date dueDate) {
|
|
|
|
private void showSaveToast(Date dueDate) {
|
|
|
|
int stringResource;
|
|
|
|
int stringResource;
|
|
|
|
@ -338,19 +336,20 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
int timeInSeconds = (int)((dueDate.getTime() - System.currentTimeMillis())/1000L);
|
|
|
|
int timeInSeconds = (int)((dueDate.getTime() - System.currentTimeMillis())/1000L);
|
|
|
|
|
|
|
|
|
|
|
|
if (timeInSeconds < 0) {
|
|
|
|
if (timeInSeconds < 0) {
|
|
|
|
timeInSeconds *= -1; // DateUtilities.getDurationString() requires
|
|
|
|
timeInSeconds *= -1; // DateUtilities.getDurationString() requires positive integer
|
|
|
|
// positive integer
|
|
|
|
|
|
|
|
stringResource = R.string.taskEdit_onTaskSave_Overdue;
|
|
|
|
stringResource = R.string.taskEdit_onTaskSave_Overdue;
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
stringResource = R.string.taskEdit_onTaskSave_Due;
|
|
|
|
stringResource = R.string.taskEdit_onTaskSave_Due;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String formattedDate = DateUtilities.getDurationString(getResources(), timeInSeconds, 2);
|
|
|
|
String formattedDate = DateUtilities.getDurationString(getResources(), timeInSeconds, 2);
|
|
|
|
Toast.makeText(this, getResources().getString(stringResource, formattedDate), Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(this,
|
|
|
|
|
|
|
|
getResources().getString(stringResource, formattedDate),
|
|
|
|
|
|
|
|
Toast.LENGTH_SHORT).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* Displays a Toast reporting that the selected task has been saved. Use
|
|
|
|
* Displays a Toast reporting that the selected task has been saved.
|
|
|
|
* this version when no due Date has been set.
|
|
|
|
* Use this version when no due Date has been set.
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
private void showSaveToast() {
|
|
|
|
private void showSaveToast() {
|
|
|
|
Toast.makeText(this, R.string.taskEdit_onTaskSave_notDue, Toast.LENGTH_SHORT).show();
|
|
|
|
Toast.makeText(this, R.string.taskEdit_onTaskSave_notDue, Toast.LENGTH_SHORT).show();
|
|
|
|
@ -404,48 +403,53 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
alertController.removeAlerts(model.getTaskIdentifier());
|
|
|
|
alertController.removeAlerts(model.getTaskIdentifier());
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = 0; i < alertsContainer.getChildCount(); i++) {
|
|
|
|
for(int i = 0; i < alertsContainer.getChildCount(); i++) {
|
|
|
|
DateControlSet dateControlSet = (DateControlSet) alertsContainer.getChildAt(i).getTag();
|
|
|
|
DateControlSet dateControlSet = (DateControlSet)alertsContainer.
|
|
|
|
|
|
|
|
getChildAt(i).getTag();
|
|
|
|
Date date = dateControlSet.getDate();
|
|
|
|
Date date = dateControlSet.getDate();
|
|
|
|
alertController.addAlert(model.getTaskIdentifier(), date);
|
|
|
|
alertController.addAlert(model.getTaskIdentifier(), date);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/* ======================================================================
|
|
|
|
* ======================================================================
|
|
|
|
|
|
|
|
* ==================================================== UI initialization
|
|
|
|
* ==================================================== UI initialization
|
|
|
|
* ======================================================================
|
|
|
|
* ====================================================================== */
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Initialize UI components */
|
|
|
|
/** Initialize UI components */
|
|
|
|
private void setUpUIComponents() {
|
|
|
|
private void setUpUIComponents() {
|
|
|
|
Resources r = getResources();
|
|
|
|
Resources r = getResources();
|
|
|
|
setTitle(new StringBuilder().append(r.getString(R.string.taskEdit_titleGeneric)));
|
|
|
|
setTitle(new StringBuilder()
|
|
|
|
|
|
|
|
.append(r.getString(R.string.taskEdit_titleGeneric)));
|
|
|
|
|
|
|
|
|
|
|
|
// populate instance variables
|
|
|
|
// populate instance variables
|
|
|
|
name = (EditText)findViewById(R.id.name);
|
|
|
|
name = (EditText)findViewById(R.id.name);
|
|
|
|
importance = new ImportanceControlSet(R.id.importance_container);
|
|
|
|
importance = new ImportanceControlSet(R.id.importance_container);
|
|
|
|
tagsContainer = (LinearLayout)findViewById(R.id.tags_container);
|
|
|
|
tagsContainer = (LinearLayout)findViewById(R.id.tags_container);
|
|
|
|
estimatedDuration = new TimeDurationControlSet(this, R.id.estimatedDuration, 0, R.string.hour_minutes_dialog,
|
|
|
|
estimatedDuration = new TimeDurationControlSet(this,
|
|
|
|
|
|
|
|
R.id.estimatedDuration, 0, R.string.hour_minutes_dialog,
|
|
|
|
TimeDurationType.HOURS_MINUTES);
|
|
|
|
TimeDurationType.HOURS_MINUTES);
|
|
|
|
elapsedDuration = new TimeDurationControlSet(this, R.id.elapsedDuration, 0, R.string.hour_minutes_dialog,
|
|
|
|
elapsedDuration = new TimeDurationControlSet(this, R.id.elapsedDuration,
|
|
|
|
|
|
|
|
0, R.string.hour_minutes_dialog,
|
|
|
|
TimeDurationType.HOURS_MINUTES);
|
|
|
|
TimeDurationType.HOURS_MINUTES);
|
|
|
|
notification = new TimeDurationControlSet(this, R.id.notification, R.string.notification_prefix,
|
|
|
|
notification = new TimeDurationControlSet(this, R.id.notification,
|
|
|
|
R.string.notification_dialog, TimeDurationType.DAYS_HOURS);
|
|
|
|
R.string.notification_prefix, R.string.notification_dialog,
|
|
|
|
definiteDueDate = new DateWithNullControlSet(this, R.id.definiteDueDate_notnull, R.id.definiteDueDate_date,
|
|
|
|
TimeDurationType.DAYS_HOURS);
|
|
|
|
R.id.definiteDueDate_time);
|
|
|
|
definiteDueDate = new DateWithNullControlSet(this, R.id.definiteDueDate_notnull,
|
|
|
|
preferredDueDate = new DateWithNullControlSet(this, R.id.preferredDueDate_notnull, R.id.preferredDueDate_date,
|
|
|
|
R.id.definiteDueDate_date, R.id.definiteDueDate_time);
|
|
|
|
R.id.preferredDueDate_time);
|
|
|
|
preferredDueDate = new DateWithNullControlSet(this, R.id.preferredDueDate_notnull,
|
|
|
|
hiddenUntil = new DateWithNullControlSet(this, R.id.hiddenUntil_notnull, R.id.hiddenUntil_date,
|
|
|
|
R.id.preferredDueDate_date, R.id.preferredDueDate_time);
|
|
|
|
R.id.hiddenUntil_time);
|
|
|
|
hiddenUntil = new DateWithNullControlSet(this, R.id.hiddenUntil_notnull,
|
|
|
|
|
|
|
|
R.id.hiddenUntil_date, R.id.hiddenUntil_time);
|
|
|
|
notes = (EditText)findViewById(R.id.notes);
|
|
|
|
notes = (EditText)findViewById(R.id.notes);
|
|
|
|
flags = new NotifyFlagControlSet(R.id.flag_before, R.id.flag_during, R.id.flag_after, R.id.flag_nonstop);
|
|
|
|
flags = new NotifyFlagControlSet(R.id.flag_before,
|
|
|
|
|
|
|
|
R.id.flag_during, R.id.flag_after, R.id.flag_nonstop);
|
|
|
|
alertsContainer = (LinearLayout)findViewById(R.id.alert_container);
|
|
|
|
alertsContainer = (LinearLayout)findViewById(R.id.alert_container);
|
|
|
|
repeatInterval = (Spinner)findViewById(R.id.repeat_interval);
|
|
|
|
repeatInterval = (Spinner)findViewById(R.id.repeat_interval);
|
|
|
|
repeatValue = (Button)findViewById(R.id.repeat_value);
|
|
|
|
repeatValue = (Button)findViewById(R.id.repeat_value);
|
|
|
|
addToCalendar = (CheckBox)findViewById(R.id.add_to_calendar);
|
|
|
|
addToCalendar = (CheckBox)findViewById(R.id.add_to_calendar);
|
|
|
|
|
|
|
|
|
|
|
|
// individual ui component initialization
|
|
|
|
// individual ui component initialization
|
|
|
|
ArrayAdapter<String> repeatAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item,
|
|
|
|
ArrayAdapter<String> repeatAdapter = new ArrayAdapter<String>(
|
|
|
|
|
|
|
|
this, android.R.layout.simple_spinner_item,
|
|
|
|
RepeatInterval.getLabels(getResources()));
|
|
|
|
RepeatInterval.getLabels(getResources()));
|
|
|
|
repeatAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
repeatAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
|
|
|
|
repeatInterval.setAdapter(repeatAdapter);
|
|
|
|
repeatInterval.setAdapter(repeatAdapter);
|
|
|
|
@ -510,8 +514,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
private RepeatInfo getRepeatValue() {
|
|
|
|
private RepeatInfo getRepeatValue() {
|
|
|
|
if(repeatValue.getTag().equals(0))
|
|
|
|
if(repeatValue.getTag().equals(0))
|
|
|
|
return null;
|
|
|
|
return null;
|
|
|
|
return new RepeatInfo(RepeatInterval.values()[repeatInterval.getSelectedItemPosition()], (Integer) repeatValue
|
|
|
|
return new RepeatInfo(RepeatInterval.values()
|
|
|
|
.getTag());
|
|
|
|
[repeatInterval.getSelectedItemPosition()],
|
|
|
|
|
|
|
|
(Integer)repeatValue.getTag());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/** Adds an alert to the alert field */
|
|
|
|
/** Adds an alert to the alert field */
|
|
|
|
@ -523,8 +528,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
final View alertItem = inflater.inflate(R.layout.edit_alert_item, null);
|
|
|
|
final View alertItem = inflater.inflate(R.layout.edit_alert_item, null);
|
|
|
|
alertsContainer.addView(alertItem);
|
|
|
|
alertsContainer.addView(alertItem);
|
|
|
|
|
|
|
|
|
|
|
|
DateControlSet dcs = new DateControlSet(this, (Button) alertItem.findViewById(R.id.date), (Button) alertItem
|
|
|
|
DateControlSet dcs = new DateControlSet(this,
|
|
|
|
.findViewById(R.id.time));
|
|
|
|
(Button)alertItem.findViewById(R.id.date),
|
|
|
|
|
|
|
|
(Button)alertItem.findViewById(R.id.time));
|
|
|
|
dcs.setDate(alert);
|
|
|
|
dcs.setDate(alert);
|
|
|
|
alertItem.setTag(dcs);
|
|
|
|
alertItem.setTag(dcs);
|
|
|
|
|
|
|
|
|
|
|
|
@ -549,14 +555,18 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
final View tagItem = inflater.inflate(R.layout.edit_tag_item, null);
|
|
|
|
final View tagItem = inflater.inflate(R.layout.edit_tag_item, null);
|
|
|
|
tagsContainer.addView(tagItem);
|
|
|
|
tagsContainer.addView(tagItem);
|
|
|
|
|
|
|
|
|
|
|
|
AutoCompleteTextView textView = (AutoCompleteTextView) tagItem.findViewById(R.id.text1);
|
|
|
|
AutoCompleteTextView textView = (AutoCompleteTextView)tagItem.
|
|
|
|
|
|
|
|
findViewById(R.id.text1);
|
|
|
|
textView.setText(tagName);
|
|
|
|
textView.setText(tagName);
|
|
|
|
ArrayAdapter<TagModelForView> tagsAdapter = new ArrayAdapter<TagModelForView>(this,
|
|
|
|
ArrayAdapter<TagModelForView> tagsAdapter =
|
|
|
|
|
|
|
|
new ArrayAdapter<TagModelForView>(this,
|
|
|
|
android.R.layout.simple_dropdown_item_1line, tags);
|
|
|
|
android.R.layout.simple_dropdown_item_1line, tags);
|
|
|
|
textView.setAdapter(tagsAdapter);
|
|
|
|
textView.setAdapter(tagsAdapter);
|
|
|
|
textView.addTextChangedListener(new TextWatcher() {
|
|
|
|
textView.addTextChangedListener(new TextWatcher() {
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before, int count) {
|
|
|
|
public void onTextChanged(CharSequence s, int start, int before,
|
|
|
|
if (start == 0 && tagsContainer.getChildAt(tagsContainer.getChildCount() - 1) == tagItem) {
|
|
|
|
int count) {
|
|
|
|
|
|
|
|
if(start == 0 && tagsContainer.getChildAt(
|
|
|
|
|
|
|
|
tagsContainer.getChildCount()-1) == tagItem) {
|
|
|
|
addTag("");
|
|
|
|
addTag("");
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -565,7 +575,8 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count, int after) {
|
|
|
|
public void beforeTextChanged(CharSequence s, int start, int count,
|
|
|
|
|
|
|
|
int after) {
|
|
|
|
//
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
@ -581,11 +592,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
return true;
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/* ======================================================================
|
|
|
|
* ======================================================================
|
|
|
|
|
|
|
|
* ======================================================= event handlers
|
|
|
|
* ======================================================= event handlers
|
|
|
|
* ======================================================================
|
|
|
|
* ====================================================================== */
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onWindowFocusChanged(boolean hasFocus) {
|
|
|
|
public void onWindowFocusChanged(boolean hasFocus) {
|
|
|
|
@ -608,8 +617,11 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void deleteButtonClick() {
|
|
|
|
private void deleteButtonClick() {
|
|
|
|
new AlertDialog.Builder(this).setTitle(R.string.delete_title).setMessage(R.string.delete_this_task_title)
|
|
|
|
new AlertDialog.Builder(this)
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_alert).setPositiveButton(android.R.string.ok,
|
|
|
|
.setTitle(R.string.delete_title)
|
|
|
|
|
|
|
|
.setMessage(R.string.delete_this_task_title)
|
|
|
|
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_alert)
|
|
|
|
|
|
|
|
.setPositiveButton(android.R.string.ok,
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
// tell the task list to update itself
|
|
|
|
// tell the task list to update itself
|
|
|
|
@ -620,7 +632,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
setResult(Constants.RESULT_GO_HOME);
|
|
|
|
setResult(Constants.RESULT_GO_HOME);
|
|
|
|
finish();
|
|
|
|
finish();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).setNegativeButton(android.R.string.cancel, null).show();
|
|
|
|
})
|
|
|
|
|
|
|
|
.setNegativeButton(android.R.string.cancel, null)
|
|
|
|
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void repeatValueClick() {
|
|
|
|
private void repeatValueClick() {
|
|
|
|
@ -640,7 +654,8 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
public void onNumberPicked(NumberPicker view, int number) {
|
|
|
|
public void onNumberPicked(NumberPicker view, int number) {
|
|
|
|
setRepeatValue(number);
|
|
|
|
setRepeatValue(number);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}, getResources().getString(R.string.repeat_picker_title), dialogValue, 1, 0, 31).show();
|
|
|
|
}, getResources().getString(R.string.repeat_picker_title),
|
|
|
|
|
|
|
|
dialogValue, 1, 0, 31).show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
@ -649,18 +664,24 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
new AlertDialog.Builder(this).setTitle(R.string.repeat_help_dialog_title).setMessage(
|
|
|
|
new AlertDialog.Builder(this)
|
|
|
|
R.string.repeat_help_dialog).setIcon(android.R.drawable.ic_dialog_info).setPositiveButton(
|
|
|
|
.setTitle(R.string.repeat_help_dialog_title)
|
|
|
|
android.R.string.ok, new DialogInterface.OnClickListener() {
|
|
|
|
.setMessage(R.string.repeat_help_dialog)
|
|
|
|
|
|
|
|
.setIcon(android.R.drawable.ic_dialog_info)
|
|
|
|
|
|
|
|
.setPositiveButton(android.R.string.ok,
|
|
|
|
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
openDialogRunnable.run();
|
|
|
|
openDialogRunnable.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).setNeutralButton(R.string.repeat_help_hide, new DialogInterface.OnClickListener() {
|
|
|
|
})
|
|
|
|
|
|
|
|
.setNeutralButton(R.string.repeat_help_hide,
|
|
|
|
|
|
|
|
new DialogInterface.OnClickListener() {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
public void onClick(DialogInterface dialog, int which) {
|
|
|
|
Preferences.setShowRepeatHelp(TaskEdit.this, false);
|
|
|
|
Preferences.setShowRepeatHelp(TaskEdit.this, false);
|
|
|
|
openDialogRunnable.run();
|
|
|
|
openDialogRunnable.run();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}).show();
|
|
|
|
})
|
|
|
|
|
|
|
|
.show();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -709,23 +730,20 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
// save the tag name token for when we rotate the screen
|
|
|
|
// save the tag name token for when we rotate the screen
|
|
|
|
Bundle extras = getIntent().getExtras();
|
|
|
|
Bundle extras = getIntent().getExtras();
|
|
|
|
if(extras != null && extras.containsKey(TAG_NAME_TOKEN))
|
|
|
|
if(extras != null && extras.containsKey(TAG_NAME_TOKEN))
|
|
|
|
outState.putString(TAG_NAME_TOKEN, extras.getString(TAG_NAME_TOKEN));
|
|
|
|
outState.putString(TAG_NAME_TOKEN,
|
|
|
|
|
|
|
|
extras.getString(TAG_NAME_TOKEN));
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/** Take the values from the model and set the calendar start and end times
|
|
|
|
* Take the values from the model and set the calendar start and end times
|
|
|
|
|
|
|
|
* based on these. Sets keys 'dtstart' and 'dtend'.
|
|
|
|
* based on these. Sets keys 'dtstart' and 'dtend'.
|
|
|
|
*
|
|
|
|
*
|
|
|
|
* @param preferred
|
|
|
|
* @param preferred preferred due date or null
|
|
|
|
* preferred due date or null
|
|
|
|
* @param definite definite due date or null
|
|
|
|
* @param definite
|
|
|
|
* @param estimatedSeconds estimated duration or null
|
|
|
|
* definite due date or null
|
|
|
|
|
|
|
|
* @param estimatedSeconds
|
|
|
|
|
|
|
|
* estimated duration or null
|
|
|
|
|
|
|
|
* @param values
|
|
|
|
* @param values
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public static void createCalendarStartEndTimes(Date preferred, Date definite, Integer estimatedSeconds,
|
|
|
|
public static void createCalendarStartEndTimes(Date preferred, Date definite,
|
|
|
|
ContentValues values) {
|
|
|
|
Integer estimatedSeconds, ContentValues values) {
|
|
|
|
FlurryAgent.onEvent("create-calendar-event");
|
|
|
|
FlurryAgent.onEvent("create-calendar-event");
|
|
|
|
|
|
|
|
|
|
|
|
Long deadlineDate = null;
|
|
|
|
Long deadlineDate = null;
|
|
|
|
@ -759,8 +777,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
values.put("transparency", 0);
|
|
|
|
values.put("transparency", 0);
|
|
|
|
values.put("visibility", 0);
|
|
|
|
values.put("visibility", 0);
|
|
|
|
|
|
|
|
|
|
|
|
createCalendarStartEndTimes(model.getPreferredDueDate(), model.getDefiniteDueDate(), model
|
|
|
|
createCalendarStartEndTimes(model.getPreferredDueDate(),
|
|
|
|
.getEstimatedSeconds(), values);
|
|
|
|
model.getDefiniteDueDate(), model.getEstimatedSeconds(),
|
|
|
|
|
|
|
|
values);
|
|
|
|
|
|
|
|
|
|
|
|
Uri result = cr.insert(uri, values);
|
|
|
|
Uri result = cr.insert(uri, values);
|
|
|
|
if(result != null)
|
|
|
|
if(result != null)
|
|
|
|
@ -777,8 +796,9 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
Intent intent = new Intent(Intent.ACTION_EDIT, result);
|
|
|
|
Intent intent = new Intent(Intent.ACTION_EDIT, result);
|
|
|
|
|
|
|
|
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
ContentValues values = new ContentValues();
|
|
|
|
createCalendarStartEndTimes(model.getPreferredDueDate(), model.getDefiniteDueDate(), model
|
|
|
|
createCalendarStartEndTimes(model.getPreferredDueDate(),
|
|
|
|
.getEstimatedSeconds(), values);
|
|
|
|
model.getDefiniteDueDate(), model.getEstimatedSeconds(),
|
|
|
|
|
|
|
|
values);
|
|
|
|
|
|
|
|
|
|
|
|
intent.putExtra("beginTime", values.getAsLong("dtstart"));
|
|
|
|
intent.putExtra("beginTime", values.getAsLong("dtstart"));
|
|
|
|
intent.putExtra("endTime", values.getAsLong("dtend"));
|
|
|
|
intent.putExtra("endTime", values.getAsLong("dtend"));
|
|
|
|
@ -802,17 +822,16 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
alertController.close();
|
|
|
|
alertController.close();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
/* ======================================================================
|
|
|
|
* ======================================================================
|
|
|
|
|
|
|
|
* ========================================== UI component helper classes
|
|
|
|
* ========================================== UI component helper classes
|
|
|
|
* ======================================================================
|
|
|
|
* ====================================================================== */
|
|
|
|
*/
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** Control set dealing with notification flags */
|
|
|
|
/** Control set dealing with notification flags */
|
|
|
|
public class NotifyFlagControlSet {
|
|
|
|
public class NotifyFlagControlSet {
|
|
|
|
private CheckBox before, during, after, nonstop;
|
|
|
|
private CheckBox before, during, after, nonstop;
|
|
|
|
|
|
|
|
|
|
|
|
public NotifyFlagControlSet(int beforeId, int duringId, int afterId, int nonstopId) {
|
|
|
|
public NotifyFlagControlSet(int beforeId, int duringId,
|
|
|
|
|
|
|
|
int afterId, int nonstopId) {
|
|
|
|
before = (CheckBox)findViewById(beforeId);
|
|
|
|
before = (CheckBox)findViewById(beforeId);
|
|
|
|
during = (CheckBox)findViewById(duringId);
|
|
|
|
during = (CheckBox)findViewById(duringId);
|
|
|
|
after = (CheckBox)findViewById(afterId);
|
|
|
|
after = (CheckBox)findViewById(afterId);
|
|
|
|
@ -820,10 +839,14 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public void setValue(int flags) {
|
|
|
|
public void setValue(int flags) {
|
|
|
|
before.setChecked((flags & TaskModelForEdit.NOTIFY_BEFORE_DEADLINE) > 0);
|
|
|
|
before.setChecked((flags &
|
|
|
|
during.setChecked((flags & TaskModelForEdit.NOTIFY_AT_DEADLINE) > 0);
|
|
|
|
TaskModelForEdit.NOTIFY_BEFORE_DEADLINE) > 0);
|
|
|
|
after.setChecked((flags & TaskModelForEdit.NOTIFY_AFTER_DEADLINE) > 0);
|
|
|
|
during.setChecked((flags &
|
|
|
|
nonstop.setChecked((flags & TaskModelForEdit.NOTIFY_NONSTOP) > 0);
|
|
|
|
TaskModelForEdit.NOTIFY_AT_DEADLINE) > 0);
|
|
|
|
|
|
|
|
after.setChecked((flags &
|
|
|
|
|
|
|
|
TaskModelForEdit.NOTIFY_AFTER_DEADLINE) > 0);
|
|
|
|
|
|
|
|
nonstop.setChecked((flags &
|
|
|
|
|
|
|
|
TaskModelForEdit.NOTIFY_NONSTOP) > 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public int getValue() {
|
|
|
|
public int getValue() {
|
|
|
|
@ -850,8 +873,8 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
|
|
|
|
|
|
|
|
for(Importance i : Importance.values()) {
|
|
|
|
for(Importance i : Importance.values()) {
|
|
|
|
final ToggleButton button = new ToggleButton(TaskEdit.this);
|
|
|
|
final ToggleButton button = new ToggleButton(TaskEdit.this);
|
|
|
|
button.setLayoutParams(new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
|
|
|
button.setLayoutParams(new LinearLayout.LayoutParams(
|
|
|
|
LayoutParams.WRAP_CONTENT, 1));
|
|
|
|
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
|
|
|
|
button.setTextColor(r.getColor(i.getColorResource()));
|
|
|
|
button.setTextColor(r.getColor(i.getColorResource()));
|
|
|
|
button.setTextOff(r.getString(i.getLabelResource()));
|
|
|
|
button.setTextOff(r.getString(i.getLabelResource()));
|
|
|
|
button.setTextOn(r.getString(i.getLabelResource()));
|
|
|
|
button.setTextOn(r.getString(i.getLabelResource()));
|
|
|
|
@ -900,12 +923,15 @@ public class TaskEdit extends TaskModificationTabbedActivity<TaskModelForEdit> {
|
|
|
|
Cursor tasks = controller.getActiveTaskListCursor();
|
|
|
|
Cursor tasks = controller.getActiveTaskListCursor();
|
|
|
|
startManagingCursor(tasks);
|
|
|
|
startManagingCursor(tasks);
|
|
|
|
SimpleCursorAdapter tasksAdapter = new SimpleCursorAdapter(TaskEdit.this,
|
|
|
|
SimpleCursorAdapter tasksAdapter = new SimpleCursorAdapter(TaskEdit.this,
|
|
|
|
android.R.layout.simple_list_item_1, tasks, new String[] { TaskModelForList.getNameField() },
|
|
|
|
android.R.layout.simple_list_item_1, tasks,
|
|
|
|
|
|
|
|
new String[] { TaskModelForList.getNameField() },
|
|
|
|
new int[] { android.R.id.text1 });
|
|
|
|
new int[] { android.R.id.text1 });
|
|
|
|
taskBox.setAdapter(tasksAdapter);
|
|
|
|
taskBox.setAdapter(tasksAdapter);
|
|
|
|
|
|
|
|
|
|
|
|
activatedCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
|
|
|
|
activatedCheckBox.setOnCheckedChangeListener(
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
|
|
|
|
new OnCheckedChangeListener() {
|
|
|
|
|
|
|
|
public void onCheckedChanged(CompoundButton buttonView,
|
|
|
|
|
|
|
|
boolean isChecked) {
|
|
|
|
taskBox.setEnabled(isChecked);
|
|
|
|
taskBox.setEnabled(isChecked);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|