Updated images to tango images. Updated task defaults to actually work.

pull/14/head
Tim Su 14 years ago
parent 133033b193
commit 753626c2ee

@ -55,7 +55,6 @@ public final class TaskDetail implements Parcelable {
this(plugin, text, 0);
}
// --- parcelable helpers

@ -1,6 +1,9 @@
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<launchConfiguration type="com.android.ide.eclipse.adt.debug.LaunchConfigType">
<stringAttribute key="bad_container_name" value="/astrid.launch"/>
<booleanAttribute key="ch.zork.quicklaunch" value="true"/>
<stringAttribute key="ch.zork.quicklaunch.icon" value="14.gif"/>
<intAttribute key="ch.zork.quicklaunch.index" value="0"/>
<intAttribute key="com.android.ide.eclipse.adt.action" value="0"/>
<stringAttribute key="com.android.ide.eclipse.adt.commandline" value="-scale 0.7"/>
<intAttribute key="com.android.ide.eclipse.adt.delay" value="0"/>

@ -131,7 +131,7 @@ public class GenericDao<TYPE extends AbstractModel> {
*
* @return true on success.
*/
public boolean persist(AbstractModel item) {
public boolean persist(TYPE item) {
if (item.getId() == AbstractModel.NO_ID) {
return createNew(item);
} else {
@ -154,7 +154,7 @@ public class GenericDao<TYPE extends AbstractModel> {
* item model
* @return returns true on success.
*/
public boolean createNew(AbstractModel item) {
public boolean createNew(TYPE item) {
long newRow = database.getDatabase().insert(table.name,
AbstractModel.ID_PROPERTY.name, item.getMergedValues());
item.setId(newRow);
@ -171,7 +171,7 @@ public class GenericDao<TYPE extends AbstractModel> {
* item model
* @return returns true on success.
*/
public boolean saveExisting(AbstractModel item) {
public boolean saveExisting(TYPE item) {
ContentValues values = item.getSetValues();
if(values.size() == 0) // nothing changed
return true;

@ -79,6 +79,13 @@ public class DateUtilities {
return System.currentTimeMillis();
}
/** Returns unixtime one month from now */
public static final long oneMonthFromNow() {
Date date = new Date();
date.setMonth(date.getMonth() + 1);
return date.getTime();
}
/** Represents a single hour */
public static long ONE_HOUR = 3600000L;

@ -10,5 +10,5 @@
# Indicates whether an apk should be generated for each density.
split.density=false
# Project target.
target=Google Inc.:Google APIs:8
target=android-4
apk-configurations=

@ -43,11 +43,11 @@ public final class CoreFilterExposer extends BroadcastReceiver {
new QueryTemplate().where(Criterion.not(TaskCriteria.isDeleted())).
orderBy(Order.desc(Task.MODIFICATION_DATE)),
null);
all.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_all)).getBitmap();
all.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_files)).getBitmap();
SearchFilter searchFilter = new SearchFilter(CorePlugin.IDENTIFIER,
"Search");
searchFilter.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_search)).getBitmap();
searchFilter.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_search)).getBitmap();
// transmit filter list
FilterListItem[] list = new FilterListItem[3];
@ -73,7 +73,7 @@ public final class CoreFilterExposer extends BroadcastReceiver {
String.format("(%d + 1000000 * %s)", DateUtilities.now(), Task.IMPORTANCE),
String.format("(%s + 1000000 * %s)", Task.DUE_DATE, Task.IMPORTANCE)))),
null);
inbox.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_inbox)).getBitmap();
inbox.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_home)).getBitmap();
return inbox;
}

@ -46,14 +46,14 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
TaskCriteria.isVisible(DateUtilities.now()))).
orderBy(Order.asc(Task.TITLE)),
null);
alphabetical.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_alpha)).getBitmap();
alphabetical.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_alpha)).getBitmap();
Filter recent = new Filter(ExtendedPlugin.IDENTIFIER,
"Recently Modified",
"Recently Modified",
new QueryTemplate().orderBy(Order.desc(Task.MODIFICATION_DATE)).limit(15),
null);
recent.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_recent)).getBitmap();
recent.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_new)).getBitmap();
ContentValues hiddenValues = new ContentValues();
hiddenValues.put(Task.HIDE_UNTIL.name, DateUtilities.now() + DateUtilities.ONE_DAY);
@ -64,7 +64,7 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
Criterion.not(TaskCriteria.isVisible(DateUtilities.now())))).
orderBy(Order.asc(Task.HIDE_UNTIL)),
hiddenValues);
hidden.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_hidden)).getBitmap();
hidden.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_calendar)).getBitmap();
Filter deleted = new Filter(ExtendedPlugin.IDENTIFIER,
"Deleted Tasks",
@ -72,7 +72,7 @@ public final class ExtendedFilterExposer extends BroadcastReceiver {
new QueryTemplate().where(TaskCriteria.isDeleted()).
orderBy(Order.desc(Task.DELETION_DATE)),
null);
deleted.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.filter_deleted)).getBitmap();
deleted.listingIcon = ((BitmapDrawable)r.getDrawable(R.drawable.tango_trash)).getBitmap();
// transmit filter list
FilterListItem[] list = new FilterListItem[5];

@ -132,7 +132,7 @@ public class Notifications extends BroadcastReceiver {
// update last reminder time
task.setValue(Task.REMINDER_LAST, DateUtilities.now());
taskDao.save(task, false);
taskDao.saveExisting(task);
// quiet hours? unless alarm clock
boolean quietHours = false;

Binary file not shown.

Before

Width:  |  Height:  |  Size: 733 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 666 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 997 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 3.7 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 390 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 567 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 655 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 853 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 806 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 378 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 615 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.5 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 386 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 939 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 807 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 995 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 482 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 920 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 718 B

@ -17,10 +17,10 @@
<selector xmlns:android="http://schemas.android.com/apk/res/android">
<item android:state_pressed="false" android:state_enabled="true"
android:state_focused="false" android:drawable="@drawable/ic_tasklist_back" />
android:state_focused="false" android:drawable="@drawable/tango_previous_normal" />
<item android:state_pressed="true" android:state_enabled="true"
android:drawable="@drawable/ic_tasklist_back_pressed" />
android:drawable="@drawable/tango_previous_pressed" />
<item android:state_pressed="false" android:state_enabled="true"
android:state_focused="true" android:drawable="@drawable/ic_tasklist_back_selected" />
android:state_focused="true" android:drawable="@drawable/tango_previous_pressed" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 787 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.2 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.1 KiB

@ -4,11 +4,10 @@
android:orientation="horizontal"
android:background="@android:drawable/list_selector_background"
android:focusable="true"
android:paddingTop="6px"
android:paddingLeft="4dip"
android:paddingRight="6dip"
android:paddingBottom="6px"
android:minHeight="56px"
android:paddingBottom="4px"
android:minHeight="60px"
android:layout_width="fill_parent"
android:layout_height="wrap_content">
@ -17,7 +16,8 @@
android:layout_width="52px"
android:layout_height="fill_parent"
android:layout_weight="1"
android:paddingLeft="10px"
android:paddingLeft="5px"
android:focusable="false"
android:button="@drawable/btn_check"/>
<LinearLayout android:id="@+id/details"
@ -26,6 +26,7 @@
android:layout_weight="100"
android:paddingLeft="12px"
android:paddingRight="2px"
android:orientation="vertical">
<!-- task name -->

@ -101,24 +101,24 @@
android:gravity="bottom"
android:paddingTop="5dip"
android:baselineAligned="false">
<Button
<ImageButton
android:id="@+id/save_basic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/TEA_save_label" />
android:src="@drawable/tango_save" />
<Button
android:id="@+id/discard_basic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/TEA_cancel_label" />
android:src="@drawable/tango_stop" />
<Button
android:id="@+id/delete_basic"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="@string/TEA_delete_label" />
android:src="@drawable/tango_trash" />
</LinearLayout>
</LinearLayout>
</ScrollView>

@ -3,8 +3,7 @@
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="fill_parent"
android:layout_height="fill_parent"
android:orientation="vertical"
android:background="@drawable/background_gradient">
android:orientation="vertical">
<!-- Header -->
<LinearLayout
@ -19,7 +18,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/tasklist_back"
android:src="@drawable/tango_previous"
android:paddingTop="8px"
android:paddingLeft="5px"/>
@ -47,11 +46,12 @@
android:layout_height="fill_parent"
android:visibility="gone"
android:text="@string/TLA_no_items"
style="@style/TextAppearance.TLA_NoItems"/>
style="@style/TextAppearance.TLA_NoItems"
android:background="@drawable/background_gradient"/>
<!-- Task List -->
<ListView android:id="@android:id/list"
android:background="@drawable/none"
android:background="@drawable/background_gradient"
android:scrollbars="vertical"
android:layout_width="fill_parent"
android:layout_height="fill_parent"/>
@ -70,13 +70,13 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/btn_add"
android:src="@drawable/tango_add"
android:scaleType="fitCenter"/>
<!-- Quick Add Task -->
<EditText android:id="@+id/quickAddText"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_height="fill_parent"
android:layout_weight="100"
android:hint="@string/TLA_quick_add_hint"
android:singleLine="true"
@ -88,7 +88,7 @@
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:src="@drawable/btn_add_extended"
android:src="@drawable/tango_edit"
android:scaleType="fitCenter"/>
</LinearLayout>

@ -18,12 +18,12 @@ import android.preference.CheckBoxPreference;
import android.preference.EditTextPreference;
import android.preference.ListPreference;
import android.preference.Preference;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import android.preference.PreferenceActivity;
import android.preference.PreferenceCategory;
import android.preference.PreferenceGroup;
import android.preference.PreferenceScreen;
import android.preference.Preference.OnPreferenceChangeListener;
import android.preference.Preference.OnPreferenceClickListener;
import com.timsu.astrid.R;
import com.todoroo.andlib.service.Autowired;
@ -230,7 +230,6 @@ public class EditPreferences extends PreferenceActivity {
Editor editor = Preferences.getPrefs(this).edit();
editor.putString(preference.getKey(), (String)value);
editor.commit();
Task.refreshDefaultValues();
}
}
}

@ -18,15 +18,15 @@ import android.graphics.drawable.BitmapDrawable;
import android.os.Bundle;
import android.os.Parcelable;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.Menu;
import android.view.MenuItem;
import android.view.View;
import android.view.ContextMenu.ContextMenuInfo;
import android.widget.EditText;
import android.widget.ExpandableListView;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import android.widget.FrameLayout;
import android.widget.Toast;
import android.widget.ExpandableListView.ExpandableListContextMenuInfo;
import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R;
@ -319,7 +319,7 @@ public class FilterListActivity extends ExpandableListActivity {
bitmap = bitmap.copy(bitmap.getConfig(), true);
Canvas canvas = new Canvas(bitmap);
canvas.drawBitmap(emblem, new Rect(0, 0, emblem.getWidth(), emblem.getHeight()),
new Rect(bitmap.getWidth() - 32, bitmap.getHeight() - 32,
new Rect(bitmap.getWidth() - 22, bitmap.getHeight() - 22,
bitmap.getWidth(), bitmap.getHeight()), null);
Intent createShortcutIntent = new Intent();

@ -27,9 +27,9 @@ import java.util.List;
import android.app.AlertDialog;
import android.app.DatePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.TabActivity;
import android.app.TimePickerDialog;
import android.app.DatePickerDialog.OnDateSetListener;
import android.app.TimePickerDialog.OnTimeSetListener;
import android.content.ContentValues;
import android.content.DialogInterface;
@ -44,6 +44,7 @@ import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup.LayoutParams;
import android.widget.AdapterView;
import android.widget.AdapterView.OnItemSelectedListener;
import android.widget.ArrayAdapter;
import android.widget.AutoCompleteTextView;
import android.widget.Button;
@ -59,22 +60,21 @@ import android.widget.TextView;
import android.widget.TimePicker;
import android.widget.Toast;
import android.widget.ToggleButton;
import android.widget.AdapterView.OnItemSelectedListener;
import com.flurry.android.FlurryAgent;
import com.timsu.astrid.R;
import com.timsu.astrid.data.enums.RepeatInterval;
import com.timsu.astrid.data.task.TaskModelForEdit;
import com.timsu.astrid.data.task.AbstractTaskModel.RepeatInfo;
import com.timsu.astrid.data.task.TaskModelForEdit;
import com.timsu.astrid.utilities.AstridUtilities;
import com.timsu.astrid.widget.NumberPicker;
import com.timsu.astrid.widget.NumberPickerDialog;
import com.timsu.astrid.widget.TimeDurationControlSet;
import com.timsu.astrid.widget.NumberPickerDialog.OnNumberPickedListener;
import com.timsu.astrid.widget.TimeDurationControlSet;
import com.timsu.astrid.widget.TimeDurationControlSet.TimeDurationType;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.service.ExceptionService;
@ -597,10 +597,9 @@ public final class TaskEditActivity extends TabActivity {
LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, 1));
StringBuilder label = new StringBuilder();
for(int j = Task.IMPORTANCE_LEAST; j >= 0; j--)
for(int j = Task.IMPORTANCE_LEAST; j >= i; j--)
label.append('!');
button.setTextColor(colors[i]);
button.setTextOff(label);
button.setTextOn(label);
@ -622,9 +621,11 @@ public final class TaskEditActivity extends TabActivity {
if(b.getTag() == i) {
b.setTextSize(24);
b.setChecked(true);
b.setBackgroundResource(R.drawable.btn_selected);
} else {
b.setTextSize(16);
b.setChecked(false);
b.setBackgroundResource(android.R.drawable.btn_default);
}
}
}
@ -633,7 +634,7 @@ public final class TaskEditActivity extends TabActivity {
for(CompoundButton b : buttons)
if(b.isChecked())
return (Integer) b.getTag();
return Task.getStaticDefaultValues().getAsInteger(Task.IMPORTANCE.name);
return Task.IMPORTANCE_LEAST;
}
@Override
@ -652,8 +653,6 @@ public final class TaskEditActivity extends TabActivity {
private class UrgencyControlSet implements TaskEditControlSet,
OnItemSelectedListener, OnTimeSetListener, OnDateSetListener {
private static final int SPECIFIC_DATE = -1;
private final Spinner urgency;
private ArrayAdapter<UrgencyValue> urgencyAdapter;
@ -665,13 +664,19 @@ public final class TaskEditActivity extends TabActivity {
*/
private class UrgencyValue {
public String label;
public int setting;
public long dueDate;
public boolean hasDueTime;
public UrgencyValue(String label, long dueDate, boolean hasDueTime) {
public UrgencyValue(String label, int setting) {
this.label = label;
this.setting = setting;
dueDate = model.createDueDate(setting, 0);
}
public UrgencyValue(String label, int setting, long dueDate) {
this.label = label;
this.setting = setting;
this.dueDate = dueDate;
this.hasDueTime = hasDueTime;
}
@Override
@ -685,43 +690,64 @@ public final class TaskEditActivity extends TabActivity {
this.urgency.setOnItemSelectedListener(this);
}
private UrgencyValue[] createUrgencyList(long specificDate, boolean hasDueTime) {
// set up base urgencies
/**
* set up urgency adapter and picks the right selected item
* @param dueDate
*/
private void createUrgencyList(long dueDate) {
// set up base urgency list
String[] labels = getResources().getStringArray(R.array.TEA_urgency);
UrgencyValue[] urgencyValues = new UrgencyValue[labels.length];
urgencyValues[0] = new UrgencyValue(labels[0], 0, false);
urgencyValues[1] = new UrgencyValue(labels[1], DateUtilities.now(), false);
urgencyValues[2] = new UrgencyValue(labels[2],
DateUtilities.now() + DateUtilities.ONE_DAY, false);
urgencyValues[0] = new UrgencyValue(labels[Task.URGENCY_NONE],
Task.URGENCY_NONE);
urgencyValues[1] = new UrgencyValue(labels[Task.URGENCY_TODAY],
Task.URGENCY_TODAY);
urgencyValues[2] = new UrgencyValue(labels[Task.URGENCY_TOMORROW],
Task.URGENCY_TOMORROW);
String dayAfterTomorrow = new SimpleDateFormat("EEEE").format( //$NON-NLS-1$
new Date(DateUtilities.now() + 2 * DateUtilities.ONE_DAY));
urgencyValues[3] = new UrgencyValue(dayAfterTomorrow,
DateUtilities.now() + 2 * DateUtilities.ONE_DAY, false);
urgencyValues[4] = new UrgencyValue(labels[4],
DateUtilities.now() + DateUtilities.ONE_WEEK, false);
Date nextMonth = new Date();
nextMonth.setMonth(nextMonth.getMonth() + 1);
urgencyValues[5] = new UrgencyValue(labels[5],
nextMonth.getTime(), false);
urgencyValues[6] = new UrgencyValue(labels[6], SPECIFIC_DATE, false);
urgencyValues[7] = new UrgencyValue(labels[7], SPECIFIC_DATE, true);
if(specificDate > 0) {
Task.URGENCY_DAY_AFTER);
urgencyValues[4] = new UrgencyValue(labels[Task.URGENCY_NEXT_WEEK],
Task.URGENCY_NEXT_WEEK);
urgencyValues[5] = new UrgencyValue(labels[Task.URGENCY_NEXT_MONTH],
Task.URGENCY_NEXT_MONTH);
urgencyValues[6] = new UrgencyValue(labels[Task.URGENCY_SPECIFIC_DAY],
Task.URGENCY_SPECIFIC_DAY);
urgencyValues[7] = new UrgencyValue(labels[Task.URGENCY_SPECIFIC_DAY_TIME],
Task.URGENCY_SPECIFIC_DAY_TIME);
// search for setting
int selection = -1;
for(int i = 0; i < urgencyValues.length; i++)
if(urgencyValues[i].dueDate == dueDate) {
selection = i;
break;
}
if(selection == -1) {
UrgencyValue[] updated = new UrgencyValue[labels.length + 1];
for(int i = 0; i < labels.length; i++)
updated[i+1] = urgencyValues[i];
SimpleDateFormat format;
if(hasDueTime)
format = DateUtilities.getDateWithTimeFormat(TaskEditActivity.this);
else
format = DateUtilities.getDateFormat(TaskEditActivity.this);
updated[0] = new UrgencyValue(format.format(new Date(specificDate)),
specificDate, hasDueTime);
if(Task.hasDueTime(dueDate)) {
SimpleDateFormat format = DateUtilities.getDateWithTimeFormat(TaskEditActivity.this);
updated[0] = new UrgencyValue(format.format(new Date(dueDate)),
Task.URGENCY_SPECIFIC_DAY_TIME, dueDate);
} else {
SimpleDateFormat format = DateUtilities.getDateFormat(TaskEditActivity.this);
updated[0] = new UrgencyValue(format.format(new Date(dueDate)),
Task.URGENCY_SPECIFIC_DAY, dueDate);
}
selection = 0;
urgencyValues = updated;
}
return urgencyValues;
urgencyAdapter = new ArrayAdapter<UrgencyValue>(
TaskEditActivity.this, android.R.layout.simple_spinner_item,
urgencyValues);
urgencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
this.urgency.setAdapter(urgencyAdapter);
this.urgency.setSelection(selection);
}
// --- listening for events
@ -731,12 +757,13 @@ public final class TaskEditActivity extends TabActivity {
// if specific date or date & time selected, show dialog
// ... at conclusion of dialog, update our list
UrgencyValue item = urgencyAdapter.getItem(position);
if(item.dueDate == SPECIFIC_DATE) {
hasTime = item.hasDueTime;
intermediateDate = new Date();
intermediateDate.setSeconds(0);
if(item.setting == Task.URGENCY_SPECIFIC_DAY ||
item.setting == Task.URGENCY_SPECIFIC_DAY_TIME) {
customSetting = item.setting;
customDate = new Date();
customDate.setSeconds(0);
DatePickerDialog datePicker = new DatePickerDialog(TaskEditActivity.this,
this, 1900 + intermediateDate.getYear(), intermediateDate.getMonth(), intermediateDate.getDate());
this, 1900 + customDate.getYear(), customDate.getMonth(), customDate.getDate());
datePicker.show();
}
}
@ -746,40 +773,34 @@ public final class TaskEditActivity extends TabActivity {
// ignore
}
Date intermediateDate;
boolean hasTime;
Date customDate;
int customSetting;
public void onDateSet(DatePicker view, int year, int month, int monthDay) {
intermediateDate.setYear(year - 1900);
intermediateDate.setMonth(month);
intermediateDate.setDate(monthDay);
intermediateDate.setMinutes(0);
customDate.setYear(year - 1900);
customDate.setMonth(month);
customDate.setDate(monthDay);
customDate.setMinutes(0);
if(!hasTime) {
if(customSetting != Task.URGENCY_SPECIFIC_DAY_TIME) {
customDateFinished();
return;
}
new TimePickerDialog(TaskEditActivity.this, this,
intermediateDate.getHours(), intermediateDate.getMinutes(),
customDate.getHours(), customDate.getMinutes(),
DateUtilities.is24HourFormat(TaskEditActivity.this)).show();
}
public void onTimeSet(TimePicker view, int hourOfDay, int minute) {
intermediateDate.setHours(hourOfDay);
intermediateDate.setMinutes(minute);
customDate.setHours(hourOfDay);
customDate.setMinutes(minute);
customDateFinished();
}
private void customDateFinished() {
UrgencyValue[] urgencyList = createUrgencyList(intermediateDate.getTime(),
hasTime);
urgencyAdapter = new ArrayAdapter<UrgencyValue>(
TaskEditActivity.this, android.R.layout.simple_spinner_item,
urgencyList);
urgencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
this.urgency.setAdapter(urgencyAdapter);
urgency.setSelection(0);
long time = model.createDueDate(customSetting, customDate.getTime());
createUrgencyList(time);
}
// --- setting up values
@ -787,25 +808,13 @@ public final class TaskEditActivity extends TabActivity {
@Override
public void readFromModel() {
long dueDate = model.getValue(Task.DUE_DATE);
UrgencyValue[] urgencyList = createUrgencyList(dueDate, model.hasDueTime());
urgencyAdapter = new ArrayAdapter<UrgencyValue>(
TaskEditActivity.this, android.R.layout.simple_spinner_item,
urgencyList);
urgencyAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
this.urgency.setAdapter(urgencyAdapter);
if(isNewTask()) {
urgency.setSelection(Preferences.getIntegerFromString(R.string.p_default_urgency_key));
} else {
urgency.setSelection(0);
}
createUrgencyList(dueDate);
}
@Override
public void writeToModel() {
UrgencyValue item = urgencyAdapter.getItem(urgency.getSelectedItemPosition());
model.setDueDateAndTime(new Date(item.dueDate), item.hasDueTime);
model.setValue(Task.DUE_DATE, item.dueDate);
}
}
@ -1075,8 +1084,8 @@ public final class TaskEditActivity extends TabActivity {
}
settingCheckbox.setChecked(time > 0);
if(time == 0) {
time = 7*24;
if(time <= 0) {
time = DateUtilities.ONE_WEEK;
}
int i;

@ -11,13 +11,13 @@ import android.content.res.Resources;
import android.database.Cursor;
import android.graphics.Paint;
import android.view.ContextMenu;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.KeyEvent;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.view.ContextMenu.ContextMenuInfo;
import android.view.View.OnCreateContextMenuListener;
import android.view.View.OnKeyListener;
import android.view.ViewGroup;
import android.widget.CheckBox;
import android.widget.CursorAdapter;
import android.widget.LinearLayout;
@ -277,6 +277,9 @@ public class TaskAdapter extends CursorAdapter {
return;
ArrayList<TaskDetail> details = detailCache.get(taskId);
if(details.contains(detail))
return;
details.add(detail);
// update view if it is visible

@ -9,7 +9,7 @@ import android.content.ContentValues;
import android.content.Context;
import android.content.Intent;
import com.todoroo.andlib.data.AbstractModel;
import com.timsu.astrid.R;
import com.todoroo.andlib.data.GenericDao;
import com.todoroo.andlib.service.Autowired;
import com.todoroo.andlib.service.ContextManager;
@ -20,6 +20,7 @@ import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.dao.MetadataDao.MetadataCriteria;
import com.todoroo.astrid.model.Task;
import com.todoroo.astrid.reminders.ReminderService;
import com.todoroo.astrid.utility.Preferences;
/**
* Data Access layer for {@link Task}-related operations.
@ -152,15 +153,32 @@ public class TaskDao extends GenericDao<Task> {
}
@Override
public boolean createNew(AbstractModel item) {
public boolean createNew(Task item) {
if(!item.containsValue(Task.CREATION_DATE))
item.setValue(Task.CREATION_DATE, DateUtilities.now());
item.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
// set up task defaults
if(!item.containsValue(Task.IMPORTANCE))
item.setValue(Task.IMPORTANCE, Preferences.getIntegerFromString(
R.string.p_default_importance_key));
if(!item.containsValue(Task.DUE_DATE)) {
int setting = Preferences.getIntegerFromString(R.string.p_default_urgency_key);
item.setValue(Task.DUE_DATE, item.createDueDate(setting, 0));
}
if(!item.containsValue(Task.HIDE_UNTIL)) {
int setting = Preferences.getIntegerFromString(R.string.p_default_hideUntil_key);
item.setValue(Task.HIDE_UNTIL, item.createHideUntil(setting, 0));
}
if(!item.containsValue(Task.REMINDER_PERIOD))
item.setValue(Task.REMINDER_PERIOD, DateUtilities.ONE_HOUR *
Preferences.getIntegerFromString(R.string.p_rmd_default_random_hours));
return super.createNew(item);
}
@Override
public boolean saveExisting(AbstractModel item) {
public boolean saveExisting(Task item) {
item.setValue(Task.MODIFICATION_DATE, DateUtilities.now());
return super.saveExisting(item);
}

@ -15,13 +15,12 @@ import com.timsu.astrid.R;
import com.timsu.astrid.data.task.AbstractTaskModel.RepeatInfo;
import com.todoroo.andlib.data.AbstractModel;
import com.todoroo.andlib.data.Property;
import com.todoroo.andlib.data.Table;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.data.Property.IntegerProperty;
import com.todoroo.andlib.data.Property.LongProperty;
import com.todoroo.andlib.data.Property.StringProperty;
import com.todoroo.andlib.data.Table;
import com.todoroo.andlib.data.TodorooCursor;
import com.todoroo.andlib.utility.DateUtilities;
import com.todoroo.astrid.utility.Preferences;
/**
* Data Model which represents a task users need to accomplish.
@ -175,28 +174,8 @@ public final class Task extends AbstractModel {
defaultValues.put(TIMER_START.name, 0);
}
private static boolean defaultValuesLoaded = false;
public static ContentValues getStaticDefaultValues() {
return defaultValues;
}
/**
* Call to load task default values from preferences.
*/
public static void refreshDefaultValues() {
defaultValues.put(IMPORTANCE.name,
Preferences.getIntegerFromString(R.string.p_default_importance_key));
defaultValuesLoaded = true;
}
@Override
public ContentValues getDefaultValues() {
// if refreshDefaultValues has never been called, call it
if(!defaultValuesLoaded) {
refreshDefaultValues();
}
return defaultValues;
}
@ -238,16 +217,16 @@ public final class Task extends AbstractModel {
/** Checks whether task is deleted. Will return false if DELETION_DATE not read */
public boolean isDeleted() {
try {
return getValue(DELETION_DATE) > 0;
} catch (UnsupportedOperationException e) {
// assume false if we didn't load deletion date
if(!containsValue(DELETION_DATE))
return false;
}
else
return getValue(DELETION_DATE) > 0;
}
/** Checks whether task is hidden. Requires HIDDEN_UNTIL */
public boolean isHidden() {
return getValue(HIDE_UNTIL) > DateUtilities.now();
return getValue(HIDE_UNTIL) > DateUtilities.now();
}
/** Checks whether task is done. Requires DUE_DATE */
@ -256,59 +235,155 @@ public final class Task extends AbstractModel {
}
/**
* @return true if hours, minutes, and seconds indicate end of day
* Returns the set state of the given flag on the given property
* @param property
* @param flag
* @return
*/
private static boolean isEndOfDay(Date date) {
int hours = date.getHours();
int minutes = date.getMinutes();
int seconds = date.getSeconds();
return hours == 23 && minutes == 59 && seconds == 59;
public boolean getFlag(IntegerProperty property, int flag) {
return (getValue(property) & flag) > 0;
}
/**
* Sets due date for this task. If this due date has no time associated,
* @return repeat data structure. Requires REPEAT
*/
public RepeatInfo getRepeatInfo() {
return RepeatInfo.fromSingleField(getValue(Task.REPEAT));
}
// --- due and hide until date management
/** urgency array index -> significance */
public static final int URGENCY_NONE = 0;
public static final int URGENCY_TODAY = 1;
public static final int URGENCY_TOMORROW = 2;
public static final int URGENCY_DAY_AFTER = 3;
public static final int URGENCY_NEXT_WEEK = 4;
public static final int URGENCY_NEXT_MONTH = 5;
public static final int URGENCY_SPECIFIC_DAY = 6;
public static final int URGENCY_SPECIFIC_DAY_TIME = 7;
/** hide until array index -> significance */
public static final int HIDE_UNTIL_NONE = 0;
public static final int HIDE_UNTIL_DUE = 1;
public static final int HIDE_UNTIL_DAY_BEFORE = 2;
public static final int HIDE_UNTIL_WEEK_BEFORE = 3;
public static final int HIDE_UNTIL_SPECIFIC_DAY = 4;
/**
* Creates due date for this task. If this due date has no time associated,
* we move it to the last millisecond of the day.
*
* @param date
* @param hasDueTime
* @param setting
* one of the URGENCY_* constants
* @param customDate
* if specific day or day & time is set, this value
*/
public void setDueDateAndTime(Date dueDate, boolean hasDueTime) {
if(dueDate == null || dueDate.getTime() == 0) {
setValue(Task.DUE_DATE, 0L);
return;
public long createDueDate(int setting, long customDate) {
long date;
switch(setting) {
case URGENCY_NONE:
date = 0;
case URGENCY_TODAY:
date = DateUtilities.now();
break;
case URGENCY_TOMORROW:
date = DateUtilities.now() + DateUtilities.ONE_DAY;
break;
case URGENCY_DAY_AFTER:
date = DateUtilities.now() + 2 * DateUtilities.ONE_DAY;
break;
case URGENCY_NEXT_WEEK:
date = DateUtilities.now() + DateUtilities.ONE_WEEK;
break;
case URGENCY_NEXT_MONTH:
date = DateUtilities.oneMonthFromNow();
break;
case URGENCY_SPECIFIC_DAY:
case URGENCY_SPECIFIC_DAY_TIME:
date = customDate;
default:
throw new IllegalArgumentException("Unknown setting " + setting);
}
if(!hasDueTime) {
if(date <= 0)
return date;
Date dueDate = new Date(date);
if(setting != URGENCY_SPECIFIC_DAY_TIME) {
dueDate.setHours(23);
dueDate.setMinutes(59);
dueDate.setSeconds(59);
} else if(isEndOfDay(dueDate)) {
dueDate.setSeconds(58);
}
setValue(Task.DUE_DATE, dueDate.getTime());
return dueDate.getTime();
}
/**
* Checks whether this due date has a due time or only a date
* Create hide until for this task.
*
* @param setting
* one of the HIDE_UNTIL_* constants
* @param customDate
* if specific day is set, this value
* @return
*/
public boolean hasDueTime() {
return !isEndOfDay(new Date(getValue(DUE_DATE)));
public long createHideUntil(int setting, long customDate) {
long date;
switch(setting) {
case HIDE_UNTIL_NONE:
return 0;
case HIDE_UNTIL_DUE:
date = getValue(DUE_DATE);
break;
case HIDE_UNTIL_DAY_BEFORE:
date = getValue(DUE_DATE) - DateUtilities.ONE_DAY;
break;
case HIDE_UNTIL_WEEK_BEFORE:
date = getValue(DUE_DATE) - DateUtilities.ONE_WEEK;
break;
case HIDE_UNTIL_SPECIFIC_DAY:
date = customDate;
break;
default:
throw new IllegalArgumentException("Unknown setting " + setting);
}
if(date <= 0)
return date;
Date hideUntil = new Date(date);
hideUntil.setHours(0);
hideUntil.setMinutes(0);
hideUntil.setSeconds(0);
return hideUntil.getTime();
}
/**
* Returns the set state of the given flag on the given property
* @param property
* @param flag
* @return
* @return true if hours, minutes, and seconds indicate end of day
*/
public boolean getFlag(IntegerProperty property, int flag) {
return (getValue(property) & flag) > 0;
private static boolean isEndOfDay(Date date) {
int hours = date.getHours();
int minutes = date.getMinutes();
int seconds = date.getSeconds();
return hours == 23 && minutes == 59 && seconds == 59;
}
/**
* @return repeat data structure. Requires REPEAT
* Checks whether this due date has a due time or only a date
*/
public RepeatInfo getRepeatInfo() {
return RepeatInfo.fromSingleField(getValue(Task.REPEAT));
public boolean hasDueTime() {
return hasDueTime(getValue(Task.DUE_DATE));
}
/**
* Checks whether provided due date has a due time or only a date
*/
public static boolean hasDueTime(long dueDate) {
return !isEndOfDay(new Date(dueDate));
}
}

@ -11,8 +11,8 @@ import android.content.SharedPreferences;
import android.content.SharedPreferences.Editor;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.database.sqlite.SQLiteOpenHelper;
import android.database.sqlite.SQLiteDatabase.CursorFactory;
import android.database.sqlite.SQLiteOpenHelper;
import android.util.Log;
import com.timsu.astrid.R;
@ -181,10 +181,10 @@ public class Astrid2To3UpgradeHelper {
// --- database upgrade helpers
protected static final class UpgradeVisitorContainer {
protected static final class UpgradeVisitorContainer<TYPE extends AbstractModel> {
public int columnIndex;
public Cursor cursor;
public AbstractModel model;
public TYPE model;
public StringBuilder upgradeNotes;
}
@ -194,9 +194,9 @@ public class Astrid2To3UpgradeHelper {
*
*/
@SuppressWarnings("nls")
protected static final class ColumnUpgradeVisitor implements PropertyVisitor<Void, UpgradeVisitorContainer> {
protected static final class ColumnUpgradeVisitor implements PropertyVisitor<Void, UpgradeVisitorContainer<?>> {
@Override
public Void visitDouble(Property<Double> property, UpgradeVisitorContainer data) {
public Void visitDouble(Property<Double> property, UpgradeVisitorContainer<?> data) {
double value = data.cursor.getDouble(data.columnIndex);
data.model.setValue(property, value);
Log.d("upgrade", "wrote " + value + " to -> " + property + " of model id " + data.cursor.getLong(1));
@ -204,7 +204,7 @@ public class Astrid2To3UpgradeHelper {
}
@Override
public Void visitInteger(Property<Integer> property, UpgradeVisitorContainer data) {
public Void visitInteger(Property<Integer> property, UpgradeVisitorContainer<?> data) {
int value = data.cursor.getInt(data.columnIndex);
data.model.setValue(property, value);
Log.d("upgrade", "wrote " + value + " to -> " + property + " of model id " + data.cursor.getLong(1));
@ -212,7 +212,7 @@ public class Astrid2To3UpgradeHelper {
}
@Override
public Void visitLong(Property<Long> property, UpgradeVisitorContainer data) {
public Void visitLong(Property<Long> property, UpgradeVisitorContainer<?> data) {
long value = data.cursor.getLong(data.columnIndex);
// special handling for due date
@ -240,7 +240,7 @@ public class Astrid2To3UpgradeHelper {
}
@Override
public Void visitString(Property<String> property, UpgradeVisitorContainer data) {
public Void visitString(Property<String> property, UpgradeVisitorContainer<?> data) {
String value = data.cursor.getString(data.columnIndex);
data.model.setValue(property, value);
Log.d("upgrade", "wrote " + value + " to -> " + property + " of model id " + data.cursor.getLong(1));
@ -270,7 +270,7 @@ public class Astrid2To3UpgradeHelper {
null, 1).getReadableDatabase();
Cursor cursor = upgradeDb.rawQuery("SELECT * FROM " + legacyTable, null);
UpgradeVisitorContainer container = new UpgradeVisitorContainer();
UpgradeVisitorContainer<TYPE> container = new UpgradeVisitorContainer<TYPE>();
container.cursor = cursor;
container.model = model;
ColumnUpgradeVisitor visitor = new ColumnUpgradeVisitor();

Loading…
Cancel
Save