Remove public and readonly columns from tasks

pull/73/head
Alex Baker 11 years ago
parent 94d2189f85
commit f541415309

@ -91,12 +91,6 @@ public final class Task extends RemoteModel {
public static final IntegerProperty FLAGS = new IntegerProperty( public static final IntegerProperty FLAGS = new IntegerProperty(
TABLE, "flags"); TABLE, "flags");
public static final IntegerProperty IS_PUBLIC = new IntegerProperty(
TABLE, "is_public", Property.PROP_FLAG_BOOLEAN);
public static final IntegerProperty IS_READONLY = new IntegerProperty(
TABLE, "is_readonly", Property.PROP_FLAG_BOOLEAN);
// --- non-core task metadata // --- non-core task metadata
public static final StringProperty NOTES = new StringProperty( public static final StringProperty NOTES = new StringProperty(
@ -257,8 +251,6 @@ public final class Task extends RemoteModel {
defaultValues.put(TIMER_START.name, 0); defaultValues.put(TIMER_START.name, 0);
defaultValues.put(DETAILS.name, (String)null); defaultValues.put(DETAILS.name, (String)null);
defaultValues.put(DETAILS_DATE.name, 0); defaultValues.put(DETAILS_DATE.name, 0);
defaultValues.put(IS_PUBLIC.name, 0);
defaultValues.put(IS_READONLY.name, 0);
defaultValues.put(CLASSIFICATION.name, ""); defaultValues.put(CLASSIFICATION.name, "");
defaultValues.put(LAST_SYNC.name, 0); defaultValues.put(LAST_SYNC.name, 0);
@ -473,11 +465,6 @@ public final class Task extends RemoteModel {
return dueDate < compareTo; return dueDate < compareTo;
} }
public boolean isEditable() {
return (getValue(Task.IS_READONLY) == 0) &&
!(getValue(Task.IS_PUBLIC) == 1 && !Task.USER_ID_SELF.equals(getValue(Task.USER_ID)));
}
public boolean repeatAfterCompletion() { public boolean repeatAfterCompletion() {
return getValue(Task.RECURRENCE).contains("FROM=COMPLETION"); return getValue(Task.RECURRENCE).contains("FROM=COMPLETION");
} }

@ -70,8 +70,6 @@ public class NameMaps {
putTaskPropertyToServerName(Task.USER_ID, "user_id", true); putTaskPropertyToServerName(Task.USER_ID, "user_id", true);
putTaskPropertyToServerName(Task.CREATOR_ID, "creator_id", false); putTaskPropertyToServerName(Task.CREATOR_ID, "creator_id", false);
putTaskPropertyToServerName(Task.UUID, "uuid", false); putTaskPropertyToServerName(Task.UUID, "uuid", false);
putTaskPropertyToServerName(Task.IS_PUBLIC, "public", true);
putTaskPropertyToServerName(Task.IS_READONLY, "read_only", false);
putTaskPropertyToServerName(Task.CLASSIFICATION, "classification", false); putTaskPropertyToServerName(Task.CLASSIFICATION, "classification", false);
} }

@ -25,10 +25,8 @@ import com.todoroo.andlib.service.ContextManager;
import com.todoroo.andlib.service.DependencyInjectionService; import com.todoroo.andlib.service.DependencyInjectionService;
import com.todoroo.andlib.utility.AndroidUtilities; import com.todoroo.andlib.utility.AndroidUtilities;
import com.todoroo.andlib.utility.DialogUtilities; import com.todoroo.andlib.utility.DialogUtilities;
import com.todoroo.astrid.actfm.CommentsActivity;
import com.todoroo.astrid.actfm.CommentsFragment; import com.todoroo.astrid.actfm.CommentsFragment;
import com.todoroo.astrid.actfm.TagCommentsFragment; import com.todoroo.astrid.actfm.TagCommentsFragment;
import com.todoroo.astrid.actfm.TaskCommentsFragment;
import com.todoroo.astrid.api.AstridApiConstants; import com.todoroo.astrid.api.AstridApiConstants;
import com.todoroo.astrid.api.Filter; import com.todoroo.astrid.api.Filter;
import com.todoroo.astrid.api.FilterListItem; import com.todoroo.astrid.api.FilterListItem;
@ -216,19 +214,7 @@ public class AstridActivity extends ActionBarActivity
@Override @Override
public void onTaskListItemClicked(long taskId) { public void onTaskListItemClicked(long taskId) {
Task task = taskDao.fetch(taskId, Task.IS_READONLY, Task.IS_PUBLIC, Task.USER_ID);
if (task != null) {
onTaskListItemClicked(taskId, task.isEditable());
}
}
@Override
public void onTaskListItemClicked(long taskId, boolean editable) {
if (editable) {
editTask(taskId); editTask(taskId);
} else {
showComments(taskId);
}
} }
private void editTask(long taskId) { private void editTask(long taskId) {
@ -272,13 +258,6 @@ public class AstridActivity extends ActionBarActivity
} }
} }
private void showComments(long taskId) {
Intent intent = new Intent(this, CommentsActivity.class);
intent.putExtra(TaskCommentsFragment.EXTRA_TASK, taskId);
startActivity(intent);
AndroidUtilities.callOverridePendingTransition(this, R.anim.slide_left_in, R.anim.slide_left_out);
}
@Override @Override
public void onBackPressed() { public void onBackPressed() {
if (isFinishing()) { if (isFinishing()) {

@ -54,7 +54,7 @@ public final class ShareLinkActivity extends TaskListActivity {
task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT)); task.setValue(Task.NOTES, callerIntent.getStringExtra(Intent.EXTRA_TEXT));
taskService.save(task); taskService.save(task);
handled = true; handled = true;
onTaskListItemClicked(task.getId(), true); onTaskListItemClicked(task.getId());
} }
} }
} }

@ -282,13 +282,13 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
if (getIntent().hasExtra(OPEN_TASK)) { if (getIntent().hasExtra(OPEN_TASK)) {
long id = getIntent().getLongExtra(OPEN_TASK, 0); long id = getIntent().getLongExtra(OPEN_TASK, 0);
if (id > 0) { if (id > 0) {
onTaskListItemClicked(id, true); onTaskListItemClicked(id);
} else { } else {
TaskListFragment tlf = getTaskListFragment(); TaskListFragment tlf = getTaskListFragment();
if (tlf != null) { if (tlf != null) {
Task result = tlf.quickAddBar.quickAddTask("", true); //$NON-NLS-1$ Task result = tlf.quickAddBar.quickAddTask("", true); //$NON-NLS-1$
if (result != null) { if (result != null) {
onTaskListItemClicked(result.getId(), true); onTaskListItemClicked(result.getId());
} }
} }
} }
@ -313,8 +313,8 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
} }
@Override @Override
public void onTaskListItemClicked(long taskId, boolean editable) { public void onTaskListItemClicked(long taskId) {
if (fragmentLayout != LAYOUT_SINGLE && editable) { if (fragmentLayout != LAYOUT_SINGLE) {
getIntent().putExtra(OPEN_TASK, taskId); getIntent().putExtra(OPEN_TASK, taskId);
} }
CommentsFragment tuf = getTagUpdatesFragment(); CommentsFragment tuf = getTagUpdatesFragment();
@ -322,7 +322,7 @@ public class TaskListActivity extends AstridActivity implements OnPageChangeList
tuf.getView().setVisibility(View.INVISIBLE); tuf.getView().setVisibility(View.INVISIBLE);
} }
super.onTaskListItemClicked(taskId, editable); super.onTaskListItemClicked(taskId);
} }
public void setListsTitle(String title) { public void setListsTitle(String title) {

@ -233,7 +233,6 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
*/ */
public interface OnTaskListItemClickedListener { public interface OnTaskListItemClickedListener {
public void onTaskListItemClicked(long taskId); public void onTaskListItemClicked(long taskId);
public void onTaskListItemClicked(long taskId, boolean editable);
} }
@Override @Override
@ -325,7 +324,7 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
return; return;
} }
onTaskListItemClicked(id, task.isEditable()); onTaskListItemClicked(id);
} }
} }
}); });
@ -910,9 +909,6 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
ContextMenuInfo menuInfo) { ContextMenuInfo menuInfo) {
AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) menuInfo; AdapterContextMenuInfo adapterInfo = (AdapterContextMenuInfo) menuInfo;
Task task = ((ViewHolder) adapterInfo.targetView.getTag()).task; Task task = ((ViewHolder) adapterInfo.targetView.getTag()).task;
if (task.getValue(Task.IS_READONLY) > 0) {
return;
}
int id = (int) task.getId(); int id = (int) task.getId();
menu.setHeaderTitle(task.getValue(Task.TITLE)); menu.setHeaderTitle(task.getValue(Task.TITLE));
@ -1118,8 +1114,8 @@ public class TaskListFragment extends ListFragment implements OnSortSelectedList
startActivityForResult(intent, ACTIVITY_SETTINGS); startActivityForResult(intent, ACTIVITY_SETTINGS);
} }
public void onTaskListItemClicked(long taskId, boolean editable) { public void onTaskListItemClicked(long taskId) {
mListener.onTaskListItemClicked(taskId, editable); mListener.onTaskListItemClicked(taskId);
} }
protected void toggleDragDrop(boolean newState) { protected void toggleDragDrop(boolean newState) {

@ -24,7 +24,6 @@ import android.text.Spanned;
import android.text.TextUtils; import android.text.TextUtils;
import android.text.TextUtils.TruncateAt; import android.text.TextUtils.TruncateAt;
import android.util.DisplayMetrics; import android.util.DisplayMetrics;
import android.util.TypedValue;
import android.view.LayoutInflater; import android.view.LayoutInflater;
import android.view.MotionEvent; import android.view.MotionEvent;
import android.view.View; import android.view.View;
@ -107,8 +106,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
Task.ID, Task.ID,
Task.UUID, Task.UUID,
Task.TITLE, Task.TITLE,
Task.IS_READONLY,
Task.IS_PUBLIC,
Task.IMPORTANCE, Task.IMPORTANCE,
Task.DUE_DATE, Task.DUE_DATE,
Task.COMPLETION_DATE, Task.COMPLETION_DATE,
@ -131,8 +128,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
Task.ID, Task.ID,
Task.UUID, Task.UUID,
Task.TITLE, Task.TITLE,
Task.IS_READONLY,
Task.IS_PUBLIC,
Task.IMPORTANCE, Task.IMPORTANCE,
Task.RECURRENCE, Task.RECURRENCE,
Task.COMPLETION_DATE, Task.COMPLETION_DATE,
@ -196,7 +191,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
private int fontSize; private int fontSize;
private long mostRecentlyMade = -1; private long mostRecentlyMade = -1;
private final ScaleAnimation scaleAnimation; private final ScaleAnimation scaleAnimation;
private final int readonlyBackground;
private final AtomicReference<String> query; private final AtomicReference<String> query;
@ -255,16 +249,11 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f); Animation.RELATIVE_TO_SELF, 0.5f, Animation.RELATIVE_TO_SELF, 0.5f);
scaleAnimation.setDuration(100); scaleAnimation.setDuration(100);
TypedValue readonlyBg = new TypedValue();
fragment.getActivity().getTheme().resolveAttribute(R.attr.asReadonlyTaskBackground, readonlyBg, false);
readonlyBackground = readonlyBg.data;
preloadDrawables(IMPORTANCE_RESOURCES, IMPORTANCE_DRAWABLES); preloadDrawables(IMPORTANCE_RESOURCES, IMPORTANCE_DRAWABLES);
preloadDrawables(IMPORTANCE_RESOURCES_CHECKED, IMPORTANCE_DRAWABLES_CHECKED); preloadDrawables(IMPORTANCE_RESOURCES_CHECKED, IMPORTANCE_DRAWABLES_CHECKED);
preloadDrawables(IMPORTANCE_RESOURCES_LARGE, IMPORTANCE_DRAWABLES_LARGE); preloadDrawables(IMPORTANCE_RESOURCES_LARGE, IMPORTANCE_DRAWABLES_LARGE);
preloadDrawables(IMPORTANCE_REPEAT_RESOURCES, IMPORTANCE_REPEAT_DRAWABLES); preloadDrawables(IMPORTANCE_REPEAT_RESOURCES, IMPORTANCE_REPEAT_DRAWABLES);
preloadDrawables(IMPORTANCE_REPEAT_RESOURCES_CHECKED, IMPORTANCE_REPEAT_DRAWABLES_CHECKED); preloadDrawables(IMPORTANCE_REPEAT_RESOURCES_CHECKED, IMPORTANCE_REPEAT_DRAWABLES_CHECKED);
} }
private void preloadDrawables(int[] resourceIds, Drawable[] drawables) { private void preloadDrawables(int[] resourceIds, Drawable[] drawables) {
@ -437,11 +426,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
viewHolder.completeBox.setMinimumHeight(minRowHeight); viewHolder.completeBox.setMinimumHeight(minRowHeight);
} }
if (task.isEditable()) {
viewHolder.view.setBackgroundColor(resources.getColor(android.R.color.transparent)); viewHolder.view.setBackgroundColor(resources.getColor(android.R.color.transparent));
} else {
viewHolder.view.setBackgroundColor(readonlyBackground);
}
// name // name
final TextView nameView = viewHolder.nameView; { final TextView nameView = viewHolder.nameView; {
@ -508,7 +493,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
} }
private TaskAction getTaskAction(Task task, boolean hasFiles, boolean hasNotes) { private TaskAction getTaskAction(Task task, boolean hasFiles, boolean hasNotes) {
if (titleOnlyLayout || task.isCompleted() || !task.isEditable()) { if (titleOnlyLayout || task.isCompleted()) {
return null; return null;
} }
if (taskActionLoader.containsKey(task.getId())) { if (taskActionLoader.containsKey(task.getId())) {
@ -986,7 +971,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
} }
long taskId = viewHolder.task.getId(); long taskId = viewHolder.task.getId();
fragment.onTaskListItemClicked(taskId, viewHolder.task.isEditable()); fragment.onTaskListItemClicked(taskId);
} }
} }
@ -1054,8 +1039,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
final CheckableImageView checkBoxView = viewHolder.completeBox; { final CheckableImageView checkBoxView = viewHolder.completeBox; {
boolean completed = task.isCompleted(); boolean completed = task.isCompleted();
checkBoxView.setChecked(completed); checkBoxView.setChecked(completed);
// disable checkbox if task is readonly checkBoxView.setEnabled(true);
checkBoxView.setEnabled(viewHolder.task.isEditable());
int value = task.getValue(Task.IMPORTANCE); int value = task.getValue(Task.IMPORTANCE);
if (value >= IMPORTANCE_RESOURCES.length) { if (value >= IMPORTANCE_RESOURCES.length) {

@ -276,8 +276,6 @@ public class Database extends AbstractDatabase {
tryExecSQL(createTableSql(visitor, TaskListMetadata.TABLE.name, TaskListMetadata.PROPERTIES)); tryExecSQL(createTableSql(visitor, TaskListMetadata.TABLE.name, TaskListMetadata.PROPERTIES));
tryExecSQL(addColumnSql(Task.TABLE, Task.PUSHED_AT, visitor, null)); tryExecSQL(addColumnSql(Task.TABLE, Task.PUSHED_AT, visitor, null));
tryExecSQL(addColumnSql(Task.TABLE, Task.IS_PUBLIC, visitor, "0"));
tryExecSQL(addColumnSql(Task.TABLE, Task.IS_READONLY, visitor, "0"));
tryExecSQL(addColumnSql(Task.TABLE, Task.CLASSIFICATION, visitor, null)); tryExecSQL(addColumnSql(Task.TABLE, Task.CLASSIFICATION, visitor, null));
tryExecSQL(addColumnSql(Task.TABLE, Task.ATTACHMENTS_PUSHED_AT, visitor, null)); tryExecSQL(addColumnSql(Task.TABLE, Task.ATTACHMENTS_PUSHED_AT, visitor, null));
tryExecSQL(addColumnSql(Task.TABLE, Task.USER_ACTIVITIES_PUSHED_AT, visitor, null)); tryExecSQL(addColumnSql(Task.TABLE, Task.USER_ACTIVITIES_PUSHED_AT, visitor, null));

@ -78,7 +78,6 @@ public class TaskDao extends RemoteModelDao<Task> {
return Criterion.and(Task.COMPLETION_DATE.eq(0), return Criterion.and(Task.COMPLETION_DATE.eq(0),
Task.DELETION_DATE.eq(0), Task.DELETION_DATE.eq(0),
Task.HIDE_UNTIL.lt(Functions.now()), Task.HIDE_UNTIL.lt(Functions.now()),
Task.IS_READONLY.eq(0),
Task.USER_ID.eq(0)); Task.USER_ID.eq(0));
} }
@ -120,15 +119,11 @@ public class TaskDao extends RemoteModelDao<Task> {
/** Check if a given task belongs to someone else & is read-only */ /** Check if a given task belongs to someone else & is read-only */
public static Criterion ownedByMe() { public static Criterion ownedByMe() {
return Criterion.and(Task.IS_READONLY.eq(0), return Task.USER_ID.eq(0);
Task.USER_ID.eq(0));
} }
} }
// --- custom operations
// --- delete // --- delete
/** /**

@ -63,7 +63,6 @@ public class DateChangedAlerts {
final Dialog d = new Dialog(activity, R.style.ReminderDialog); final Dialog d = new Dialog(activity, R.style.ReminderDialog);
final long taskId = task.getId(); final long taskId = task.getId();
final boolean editable = task.isEditable();
d.setContentView(R.layout.astrid_reminder_view); d.setContentView(R.layout.astrid_reminder_view);
Button okButton = (Button) d.findViewById(R.id.reminder_complete); Button okButton = (Button) d.findViewById(R.id.reminder_complete);
@ -83,7 +82,7 @@ public class DateChangedAlerts {
@Override @Override
public void onClick(View v) { public void onClick(View v) {
d.dismiss(); d.dismiss();
activity.onTaskListItemClicked(taskId, editable); activity.onTaskListItemClicked(taskId);
} }
}); });

@ -162,7 +162,7 @@ public class QuickAddBar extends LinearLayout {
public void onClick(View v) { public void onClick(View v) {
Task task = quickAddTask(quickAddBox.getText().toString(), true); Task task = quickAddTask(quickAddBox.getText().toString(), true);
if (task != null && task.getValue(Task.TITLE).length() == 0) { if (task != null && task.getValue(Task.TITLE).length() == 0) {
mListener.onTaskListItemClicked(task.getId(), true); mListener.onTaskListItemClicked(task.getId());
} }
} }
}); });
@ -188,7 +188,7 @@ public class QuickAddBar extends LinearLayout {
return true; return true;
} }
mListener.onTaskListItemClicked(task.getId(), true); mListener.onTaskListItemClicked(task.getId());
return true; return true;
} }
}); });

@ -19,12 +19,10 @@
<attr name="asFilterHeaderColor" format="color"/> <attr name="asFilterHeaderColor" format="color"/>
<attr name="asSeparatorBackground" format="color"/> <attr name="asSeparatorBackground" format="color"/>
<attr name="asListDividerColor" format="color"/> <attr name="asListDividerColor" format="color"/>
<attr name="asThemeTextColor" format="color"/> <attr name="asThemeTextColor" format="color"/>
<attr name="asHeaderTextColor" format="color"/> <attr name="asHeaderTextColor" format="color"/>
<attr name="asHeaderTextColorInverse" format="color"/> <attr name="asHeaderTextColorInverse" format="color"/>
<attr name="asEditTextBackground" format="reference"/> <attr name="asEditTextBackground" format="reference"/>
<attr name="asReadonlyTaskBackground" format="color" />
<attr name="asAbBackgroundColor" format="color"/> <attr name="asAbBackgroundColor" format="color"/>
<attr name="asQuickaddBackgroundColor" format="color" /> <attr name="asQuickaddBackgroundColor" format="color" />
<attr name="asFilterSelectedIcon" format="reference"/> <attr name="asFilterSelectedIcon" format="reference"/>

@ -28,7 +28,6 @@
<item name="asQuickaddBackgroundColor">?attr/asAbBackgroundColor</item> <item name="asQuickaddBackgroundColor">?attr/asAbBackgroundColor</item>
<item name="asFilterSelectedIcon">@drawable/filter_selected_icon</item> <item name="asFilterSelectedIcon">@drawable/filter_selected_icon</item>
<item name="asTaskRowSelector">@drawable/task_row_bg_dark</item> <item name="asTaskRowSelector">@drawable/task_row_bg_dark</item>
<item name="asReadonlyTaskBackground">#322c19</item>
<item name="asHeaderTextColor">?attr/asThemeTextColor</item> <item name="asHeaderTextColor">?attr/asThemeTextColor</item>
<item name="asHeaderTextColorInverse">?attr/asAbBackgroundColor</item> <item name="asHeaderTextColorInverse">?attr/asAbBackgroundColor</item>
<item name="ic_action_gear">@drawable/ic_action_gear_light</item> <item name="ic_action_gear">@drawable/ic_action_gear_light</item>
@ -73,7 +72,6 @@
<item name="asEditRowBackground">@drawable/task_edit_background_white</item> <item name="asEditRowBackground">@drawable/task_edit_background_white</item>
<item name="asFilterSelectedIcon">@drawable/filter_selected_icon_black</item> <item name="asFilterSelectedIcon">@drawable/filter_selected_icon_black</item>
<item name="asTaskRowSelector">@drawable/task_row_bg_white</item> <item name="asTaskRowSelector">@drawable/task_row_bg_white</item>
<item name="asReadonlyTaskBackground">#fff6d7</item>
<item name="asThemeTextColor">@color/dark_blue_theme_color</item> <item name="asThemeTextColor">@color/dark_blue_theme_color</item>
<item name="asAbBackgroundColor">#e9e9e9</item> <item name="asAbBackgroundColor">#e9e9e9</item>
<item name="ic_action_gear">@drawable/ic_action_gear</item> <item name="ic_action_gear">@drawable/ic_action_gear</item>

Loading…
Cancel
Save