Cloning individual reusable tasks

pull/14/head
Sam Bosley 14 years ago
parent ba80ac686c
commit aac0b196fe

@ -16,6 +16,7 @@ import com.todoroo.andlib.utility.Preferences;
import com.todoroo.astrid.activity.TaskListFragment;
import com.todoroo.astrid.adapter.TaskAdapter;
import com.todoroo.astrid.data.Task;
import com.todoroo.astrid.utility.Flags;
public class ReusableTaskAdapter extends TaskAdapter {
@ -46,8 +47,9 @@ public class ReusableTaskAdapter extends TaskAdapter {
viewHolder.clone.setOnClickListener(new OnClickListener() {
@Override
public void onClick(View v) {
// Clone task
System.err.println("Cloning task");
ReusableTaskViewHolder holder = (ReusableTaskViewHolder) v.getTag();
taskService.cloneReusableTask(holder.task);
Flags.set(Flags.REFRESH);
}
});

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.3 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.4 KiB

@ -0,0 +1,7 @@
<?xml version="1.0" encoding="utf-8"?>
<selector xmlns:android="http://schemas.android.com/apk/res/android" >
<item android:state_pressed="true"
android:drawable="@drawable/icn_clone_down" />
<item android:drawable="@drawable/icn_clone_up" />
</selector>

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

@ -6,19 +6,23 @@
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:background="@android:drawable/list_selector_background"
android:orientation="horizontal">
android:orientation="horizontal"
android:gravity="center_vertical">
<ImageView
android:id="@+id/clone_task"
android:layout_width="45dip"
android:layout_height="45dip"
android:layout_centerVertical="true"
android:background="@android:color/black"/>
android:src="@drawable/btn_clone"
android:scaleType="fitCenter"
android:padding="6dip"/>
<!-- task name -->
<TextView
android:id="@+id/title"
style="@style/TextAppearance.TAd_ItemTitle"
android:layout_marginLeft="3dip"
android:layout_width="fill_parent"
android:layout_height="wrap_content"
android:layout_weight="100"

@ -152,7 +152,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
// --- instance variables
@Autowired
private TaskService taskService;
protected TaskService taskService;
public static int APPLY_LISTENERS_PARENT = 0;
public static int APPLY_LISTENERS_ROW_BODY= 1;

@ -184,6 +184,19 @@ public class TaskService {
return newTask;
}
public Task cloneReusableTask(Task task) {
Task newTask = fetchById(task.getId(), Task.PROPERTIES);
if (newTask == null)
return new Task();
newTask.clearValue(Task.ID);
newTask.clearValue(Task.REMOTE_ID);
newTask.clearValue(Task.USER);
newTask.clearValue(Task.USER_ID);
taskDao.save(newTask);
return newTask;
}
/**
* Delete the given task. Instead of deleting from the database, we set
* the deleted flag.

Loading…
Cancel
Save