Fixed up task save toast to only appear when necessary, fixed bug with random repeats

pull/14/head
Tim Su 14 years ago
parent cd0712ade7
commit 6784269f47

@ -158,6 +158,7 @@ public class GCalControlSet implements TaskEditControlSet {
} }
} }
@SuppressWarnings("nls")
private void createStartAndEndDate(Task task, ContentValues values) { private void createStartAndEndDate(Task task, ContentValues values) {
long dueDate = task.getValue(Task.DUE_DATE); long dueDate = task.getValue(Task.DUE_DATE);
if(task.hasDueDate()) { if(task.hasDueDate()) {

@ -40,6 +40,7 @@ import android.view.LayoutInflater;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import android.view.View; import android.view.View;
import android.view.View.OnClickListener;
import android.view.ViewGroup.LayoutParams; import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView; import android.widget.AdapterView;
import android.widget.ArrayAdapter; import android.widget.ArrayAdapter;
@ -342,7 +343,7 @@ public final class TaskEditActivity extends TabActivity {
for(TaskEditControlSet controlSet : controls) for(TaskEditControlSet controlSet : controls)
controlSet.writeToModel(model); controlSet.writeToModel(model);
taskService.save(model, false); if(taskService.save(model, false))
showSaveToast(); showSaveToast();
} }
@ -394,7 +395,7 @@ public final class TaskEditActivity extends TabActivity {
* precision * precision
*/ */
private void showSaveToast() { private void showSaveToast() {
// if we have no title, don't show a message // if we have no title, or nothing's changed, don't show toast
if(isNewTask()) if(isNewTask())
return; return;
@ -1087,19 +1088,11 @@ public final class TaskEditActivity extends TabActivity {
public RandomReminderControlSet(int settingCheckboxId, int periodButtonId) { public RandomReminderControlSet(int settingCheckboxId, int periodButtonId) {
settingCheckbox = (CheckBox)findViewById(settingCheckboxId); settingCheckbox = (CheckBox)findViewById(settingCheckboxId);
periodSpinner = (Spinner)findViewById(periodButtonId); periodSpinner = (Spinner)findViewById(periodButtonId);
periodSpinner.setOnItemSelectedListener(new OnItemSelectedListener() { periodSpinner.setOnClickListener(new OnClickListener() {
@Override @Override
public void onItemSelected(AdapterView<?> arg0, View arg1, public void onClick(View v) {
int arg2, long arg3) {
settingCheckbox.setChecked(true); settingCheckbox.setChecked(true);
} }
@Override
public void onNothingSelected(AdapterView<?> arg0) {
// ignore
}
}); });
// create adapter // create adapter
@ -1120,7 +1113,7 @@ public final class TaskEditActivity extends TabActivity {
public void readFromTask(Task task) { public void readFromTask(Task task) {
long time = task.getValue(Task.REMINDER_PERIOD); long time = task.getValue(Task.REMINDER_PERIOD);
boolean shouldDisable = time <= 0; boolean enabled = time > 0;
if(time <= 0) { if(time <= 0) {
time = DEFAULT_INTERVAL; time = DEFAULT_INTERVAL;
} }
@ -1130,7 +1123,7 @@ public final class TaskEditActivity extends TabActivity {
if(hours[i] * DateUtilities.ONE_HOUR >= time) if(hours[i] * DateUtilities.ONE_HOUR >= time)
break; break;
periodSpinner.setSelection(i); periodSpinner.setSelection(i);
settingCheckbox.setChecked(!shouldDisable); settingCheckbox.setChecked(enabled);
} }
@Override @Override

@ -138,16 +138,18 @@ public class TaskDao extends GenericDao<Task> {
* @param skipHooks * @param skipHooks
* Whether pre and post hooks should run. This should be set * Whether pre and post hooks should run. This should be set
* to true if tasks are created as part of synchronization * to true if tasks are created as part of synchronization
* @return true if save occurred, false otherwise (i.e. nothing changed)
*/ */
public boolean save(Task task, boolean skipHooks) { public boolean save(Task task, boolean skipHooks) {
boolean saveSuccessful; boolean saveSuccessful;
ContentValues values = task.getSetValues();
if(values == null || values.size() == 0)
return false;
if (task.getId() == Task.NO_ID) { if (task.getId() == Task.NO_ID) {
saveSuccessful = createNew(task); saveSuccessful = createNew(task);
} else { } else {
ContentValues values = task.getSetValues();
if(values == null || values.size() == 0)
return true;
beforeSave(task, values, skipHooks); beforeSave(task, values, skipHooks);
saveSuccessful = saveExisting(task); saveSuccessful = saveExisting(task);
afterSave(task, values, skipHooks); afterSave(task, values, skipHooks);

Loading…
Cancel
Save