|
|
|
@ -1,6 +1,7 @@
|
|
|
|
package com.todoroo.astrid.adapter;
|
|
|
|
package com.todoroo.astrid.adapter;
|
|
|
|
|
|
|
|
|
|
|
|
import java.util.Collection;
|
|
|
|
import java.util.Collection;
|
|
|
|
|
|
|
|
import java.util.Collections;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.Date;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.HashMap;
|
|
|
|
import java.util.Iterator;
|
|
|
|
import java.util.Iterator;
|
|
|
|
@ -15,6 +16,7 @@ import android.database.Cursor;
|
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.graphics.Paint;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.graphics.drawable.Drawable;
|
|
|
|
import android.text.Html;
|
|
|
|
import android.text.Html;
|
|
|
|
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.Html.ImageGetter;
|
|
|
|
import android.text.Html.ImageGetter;
|
|
|
|
import android.text.util.Linkify;
|
|
|
|
import android.text.util.Linkify;
|
|
|
|
import android.view.ContextMenu;
|
|
|
|
import android.view.ContextMenu;
|
|
|
|
@ -43,18 +45,12 @@ import com.todoroo.andlib.utility.DateUtilities;
|
|
|
|
import com.todoroo.andlib.utility.SoftHashMap;
|
|
|
|
import com.todoroo.andlib.utility.SoftHashMap;
|
|
|
|
import com.todoroo.astrid.activity.TaskEditActivity;
|
|
|
|
import com.todoroo.astrid.activity.TaskEditActivity;
|
|
|
|
import com.todoroo.astrid.activity.TaskListActivity;
|
|
|
|
import com.todoroo.astrid.activity.TaskListActivity;
|
|
|
|
import com.todoroo.astrid.alarms.AlarmDetailExposer;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.api.AstridApiConstants;
|
|
|
|
import com.todoroo.astrid.api.AstridApiConstants;
|
|
|
|
import com.todoroo.astrid.api.DetailExposer;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.api.TaskAction;
|
|
|
|
import com.todoroo.astrid.api.TaskAction;
|
|
|
|
import com.todoroo.astrid.api.TaskDecoration;
|
|
|
|
import com.todoroo.astrid.api.TaskDecoration;
|
|
|
|
import com.todoroo.astrid.model.Task;
|
|
|
|
import com.todoroo.astrid.model.Task;
|
|
|
|
import com.todoroo.astrid.notes.NoteDetailExposer;
|
|
|
|
import com.todoroo.astrid.service.AddOnService;
|
|
|
|
import com.todoroo.astrid.producteev.ProducteevDetailExposer;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.repeats.RepeatDetailExposer;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.rmilk.MilkDetailExposer;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.service.TaskService;
|
|
|
|
import com.todoroo.astrid.service.TaskService;
|
|
|
|
import com.todoroo.astrid.tags.TagDetailExposer;
|
|
|
|
|
|
|
|
import com.todoroo.astrid.utility.Constants;
|
|
|
|
import com.todoroo.astrid.utility.Constants;
|
|
|
|
import com.todoroo.astrid.utility.Preferences;
|
|
|
|
import com.todoroo.astrid.utility.Preferences;
|
|
|
|
|
|
|
|
|
|
|
|
@ -83,16 +79,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
Task.COMPLETION_DATE,
|
|
|
|
Task.COMPLETION_DATE,
|
|
|
|
Task.HIDE_UNTIL,
|
|
|
|
Task.HIDE_UNTIL,
|
|
|
|
Task.DELETION_DATE,
|
|
|
|
Task.DELETION_DATE,
|
|
|
|
};
|
|
|
|
Task.DETAILS,
|
|
|
|
|
|
|
|
|
|
|
|
/** Internal Task Detail exposers */
|
|
|
|
|
|
|
|
public static final DetailExposer[] EXPOSERS = new DetailExposer[] {
|
|
|
|
|
|
|
|
new TagDetailExposer(),
|
|
|
|
|
|
|
|
new RepeatDetailExposer(),
|
|
|
|
|
|
|
|
new NoteDetailExposer(),
|
|
|
|
|
|
|
|
new MilkDetailExposer(),
|
|
|
|
|
|
|
|
new ProducteevDetailExposer(),
|
|
|
|
|
|
|
|
new AlarmDetailExposer(),
|
|
|
|
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private static int[] IMPORTANCE_COLORS = null;
|
|
|
|
private static int[] IMPORTANCE_COLORS = null;
|
|
|
|
@ -105,6 +92,9 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
@Autowired
|
|
|
|
@Autowired
|
|
|
|
private TaskService taskService;
|
|
|
|
private TaskService taskService;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@Autowired
|
|
|
|
|
|
|
|
private AddOnService addOnService;
|
|
|
|
|
|
|
|
|
|
|
|
protected final ListActivity activity;
|
|
|
|
protected final ListActivity activity;
|
|
|
|
protected final HashMap<Long, Boolean> completedItems = new HashMap<Long, Boolean>();
|
|
|
|
protected final HashMap<Long, Boolean> completedItems = new HashMap<Long, Boolean>();
|
|
|
|
private OnCompletedTaskListener onCompletedTaskListener = null;
|
|
|
|
private OnCompletedTaskListener onCompletedTaskListener = null;
|
|
|
|
@ -112,6 +102,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
private final int resource;
|
|
|
|
private final int resource;
|
|
|
|
private final LayoutInflater inflater;
|
|
|
|
private final LayoutInflater inflater;
|
|
|
|
private int fontSize;
|
|
|
|
private int fontSize;
|
|
|
|
|
|
|
|
private DetailLoaderThread detailLoader;
|
|
|
|
|
|
|
|
|
|
|
|
private final AtomicReference<String> query;
|
|
|
|
private final AtomicReference<String> query;
|
|
|
|
|
|
|
|
|
|
|
|
@ -120,8 +111,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
|
|
|
|
|
|
|
|
// --- task detail and decoration soft caches
|
|
|
|
// --- task detail and decoration soft caches
|
|
|
|
|
|
|
|
|
|
|
|
public final DetailManager detailManager = new DetailManager(false);
|
|
|
|
public final DetailManager extendedDetailManager = new DetailManager();
|
|
|
|
public final DetailManager extendedDetailManager = new DetailManager(true);
|
|
|
|
|
|
|
|
public final DecorationManager decorationManager =
|
|
|
|
public final DecorationManager decorationManager =
|
|
|
|
new DecorationManager();
|
|
|
|
new DecorationManager();
|
|
|
|
public final TaskActionManager taskActionManager = new TaskActionManager();
|
|
|
|
public final TaskActionManager taskActionManager = new TaskActionManager();
|
|
|
|
@ -159,6 +149,9 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
if(IMPORTANCE_COLORS == null)
|
|
|
|
if(IMPORTANCE_COLORS == null)
|
|
|
|
IMPORTANCE_COLORS = Task.getImportanceColors(activity.getResources());
|
|
|
|
IMPORTANCE_COLORS = Task.getImportanceColors(activity.getResources());
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
detailLoader = new DetailLoaderThread();
|
|
|
|
|
|
|
|
detailLoader.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
/* ======================================================================
|
|
|
|
@ -221,6 +214,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
ViewHolder viewHolder = ((ViewHolder)view.getTag());
|
|
|
|
ViewHolder viewHolder = ((ViewHolder)view.getTag());
|
|
|
|
|
|
|
|
|
|
|
|
Task task = viewHolder.task;
|
|
|
|
Task task = viewHolder.task;
|
|
|
|
|
|
|
|
task.clear();
|
|
|
|
task.readFromCursor(cursor);
|
|
|
|
task.readFromCursor(cursor);
|
|
|
|
|
|
|
|
|
|
|
|
setFieldContentsAndVisibility(view);
|
|
|
|
setFieldContentsAndVisibility(view);
|
|
|
|
@ -324,9 +318,21 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
importanceView.setBackgroundColor(0);
|
|
|
|
importanceView.setBackgroundColor(0);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
String details;
|
|
|
|
|
|
|
|
if(tasksToLoad.containsKey(task.getId()))
|
|
|
|
|
|
|
|
details = tasksToLoad.get(task.getId()).getValue(Task.DETAILS);
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
details = task.getValue(Task.DETAILS);
|
|
|
|
|
|
|
|
if(TextUtils.isEmpty(details)) {
|
|
|
|
|
|
|
|
viewHolder.details.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
} else {
|
|
|
|
|
|
|
|
viewHolder.details.setVisibility(View.VISIBLE);
|
|
|
|
|
|
|
|
viewHolder.details.setText(Html.fromHtml(details.trim().replace("\n", //$NON-NLS-1$
|
|
|
|
|
|
|
|
"<br>"), detailImageGetter, null)); //$NON-NLS-1$
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// details and decorations, expanded
|
|
|
|
// details and decorations, expanded
|
|
|
|
if(!isFling) {
|
|
|
|
if(!isFling) {
|
|
|
|
detailManager.request(viewHolder);
|
|
|
|
|
|
|
|
decorationManager.request(viewHolder);
|
|
|
|
decorationManager.request(viewHolder);
|
|
|
|
if(expanded == task.getId()) {
|
|
|
|
if(expanded == task.getId()) {
|
|
|
|
extendedDetailManager.request(viewHolder);
|
|
|
|
extendedDetailManager.request(viewHolder);
|
|
|
|
@ -337,8 +343,9 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
long taskId = viewHolder.task.getId();
|
|
|
|
long taskId = viewHolder.task.getId();
|
|
|
|
detailManager.reset(viewHolder, taskId);
|
|
|
|
|
|
|
|
decorationManager.reset(viewHolder, taskId);
|
|
|
|
decorationManager.reset(viewHolder, taskId);
|
|
|
|
|
|
|
|
viewHolder.extendedDetails.setVisibility(View.GONE);
|
|
|
|
|
|
|
|
viewHolder.actions.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@ -360,27 +367,69 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
/* ======================================================================
|
|
|
|
* ============================================================== add-ons
|
|
|
|
* ============================================================== details
|
|
|
|
* ====================================================================== */
|
|
|
|
* ====================================================================== */
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
private final Map<Long, Task> tasksToLoad = Collections.synchronizedMap(new HashMap<Long, Task>());
|
|
|
|
* Called to tell the cache to be cleared
|
|
|
|
|
|
|
|
*/
|
|
|
|
public class DetailLoaderThread extends Thread {
|
|
|
|
public void flushCaches() {
|
|
|
|
@Override
|
|
|
|
detailManager.clearCache();
|
|
|
|
public void run() {
|
|
|
|
extendedDetailManager.clearCache();
|
|
|
|
// for all of the tasks returned by our cursor, verify details
|
|
|
|
decorationManager.clearCache();
|
|
|
|
TodorooCursor<Task> fetchCursor = taskService.fetchFiltered(
|
|
|
|
taskActionManager.clearCache();
|
|
|
|
query.get(), null, Task.ID, Task.DETAILS);
|
|
|
|
|
|
|
|
activity.startManagingCursor(fetchCursor);
|
|
|
|
|
|
|
|
Task task = new Task();
|
|
|
|
|
|
|
|
for(fetchCursor.moveToFirst(); !fetchCursor.isAfterLast(); fetchCursor.moveToNext()) {
|
|
|
|
|
|
|
|
task.clear();
|
|
|
|
|
|
|
|
task.readFromCursor(fetchCursor);
|
|
|
|
|
|
|
|
if(!task.containsNonNullValue(Task.DETAILS)) {
|
|
|
|
|
|
|
|
System.err.println("READING details for " + task.getId());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_REQUEST_DETAILS);
|
|
|
|
|
|
|
|
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, task.getId());
|
|
|
|
|
|
|
|
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_EXTENDED, false);
|
|
|
|
|
|
|
|
activity.sendOrderedBroadcast(broadcastIntent, AstridApiConstants.PERMISSION_READ);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
Task loadHolder = new Task(fetchCursor);
|
|
|
|
|
|
|
|
tasksToLoad.put(task.getId(), loadHolder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
task.setValue(Task.DETAILS, ""); //$NON-NLS-1$
|
|
|
|
|
|
|
|
taskService.save(task);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
/**
|
|
|
|
* AddOnManager for Details
|
|
|
|
* Add detail to a task
|
|
|
|
* @author Tim Su <tim@todoroo.com>
|
|
|
|
|
|
|
|
*
|
|
|
|
*
|
|
|
|
|
|
|
|
* @param id
|
|
|
|
|
|
|
|
* @param detail
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class DetailManager extends AddOnManager<String> {
|
|
|
|
public void addDetails(long id, String detail) {
|
|
|
|
|
|
|
|
final Task task = tasksToLoad.get(id);
|
|
|
|
|
|
|
|
if(task == null)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
String newDetails = task.getValue(Task.DETAILS);
|
|
|
|
|
|
|
|
if(TextUtils.isEmpty(newDetails))
|
|
|
|
|
|
|
|
newDetails = detail;
|
|
|
|
|
|
|
|
else if(newDetails.contains(detail))
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
else
|
|
|
|
|
|
|
|
newDetails += DETAIL_SEPARATOR + detail;
|
|
|
|
|
|
|
|
task.setValue(Task.DETAILS, newDetails);
|
|
|
|
|
|
|
|
taskService.save(task);
|
|
|
|
|
|
|
|
|
|
|
|
private final ImageGetter imageGetter = new ImageGetter() {
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
notifyDataSetInvalidated();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final ImageGetter detailImageGetter = new ImageGetter() {
|
|
|
|
public Drawable getDrawable(String source) {
|
|
|
|
public Drawable getDrawable(String source) {
|
|
|
|
Resources r = activity.getResources();
|
|
|
|
Resources r = activity.getResources();
|
|
|
|
int drawable = r.getIdentifier("drawable/" + source, null, Constants.PACKAGE); //$NON-NLS-1$
|
|
|
|
int drawable = r.getIdentifier("drawable/" + source, null, Constants.PACKAGE); //$NON-NLS-1$
|
|
|
|
@ -392,50 +441,43 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
private final boolean extended;
|
|
|
|
/* ======================================================================
|
|
|
|
public DetailManager(boolean extended) {
|
|
|
|
* ============================================================== add-ons
|
|
|
|
this.extended = extended;
|
|
|
|
* ====================================================================== */
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* Called to tell the cache to be cleared
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public void flushCaches() {
|
|
|
|
|
|
|
|
extendedDetailManager.clearCache();
|
|
|
|
|
|
|
|
decorationManager.clearCache();
|
|
|
|
|
|
|
|
taskActionManager.clearCache();
|
|
|
|
|
|
|
|
detailLoader = new DetailLoaderThread();
|
|
|
|
|
|
|
|
detailLoader.start();
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/**
|
|
|
|
|
|
|
|
* AddOnManager for Details
|
|
|
|
|
|
|
|
* @author Tim Su <tim@todoroo.com>
|
|
|
|
|
|
|
|
*
|
|
|
|
|
|
|
|
*/
|
|
|
|
|
|
|
|
public class DetailManager extends AddOnManager<String> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public DetailManager() {
|
|
|
|
|
|
|
|
//
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
Intent createBroadcastIntent(long taskId) {
|
|
|
|
Intent createBroadcastIntent(long taskId) {
|
|
|
|
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_REQUEST_DETAILS);
|
|
|
|
Intent broadcastIntent = new Intent(AstridApiConstants.BROADCAST_REQUEST_DETAILS);
|
|
|
|
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
|
|
|
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_TASK_ID, taskId);
|
|
|
|
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_EXTENDED, extended);
|
|
|
|
broadcastIntent.putExtra(AstridApiConstants.EXTRAS_EXTENDED, true);
|
|
|
|
return broadcastIntent;
|
|
|
|
return broadcastIntent;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public boolean request(final ViewHolder viewHolder) {
|
|
|
|
public void addNew(long taskId, String addOn, String item) {
|
|
|
|
if(super.request(viewHolder)) {
|
|
|
|
super.addNew(taskId, addOn, item);
|
|
|
|
final long taskId = viewHolder.task.getId();
|
|
|
|
|
|
|
|
// load internal details
|
|
|
|
|
|
|
|
new Thread() {
|
|
|
|
|
|
|
|
@Override
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
for(DetailExposer exposer : EXPOSERS) {
|
|
|
|
|
|
|
|
final String detail = exposer.getTaskDetails(activity,
|
|
|
|
|
|
|
|
taskId, extended);
|
|
|
|
|
|
|
|
if(detail == null)
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
final Collection<String> cacheList =
|
|
|
|
|
|
|
|
addIfNotExists(taskId, exposer.getPluginIdentifier(),
|
|
|
|
|
|
|
|
detail);
|
|
|
|
|
|
|
|
if(cacheList != null) {
|
|
|
|
|
|
|
|
if(taskId != viewHolder.task.getId())
|
|
|
|
|
|
|
|
continue;
|
|
|
|
|
|
|
|
activity.runOnUiThread(new Runnable() {
|
|
|
|
|
|
|
|
public void run() {
|
|
|
|
|
|
|
|
draw(viewHolder, taskId, cacheList);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
}.start();
|
|
|
|
|
|
|
|
return true;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
return false;
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@SuppressWarnings("nls")
|
|
|
|
@SuppressWarnings("nls")
|
|
|
|
@ -443,9 +485,9 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
void draw(ViewHolder viewHolder, long taskId, Collection<String> details) {
|
|
|
|
void draw(ViewHolder viewHolder, long taskId, Collection<String> details) {
|
|
|
|
if(details == null || viewHolder.task.getId() != taskId)
|
|
|
|
if(details == null || viewHolder.task.getId() != taskId)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
TextView view = extended ? viewHolder.extendedDetails : viewHolder.details;
|
|
|
|
TextView view = viewHolder.extendedDetails;
|
|
|
|
|
|
|
|
if(details.isEmpty() || (expanded != taskId)) {
|
|
|
|
reset(viewHolder, taskId);
|
|
|
|
reset(viewHolder, taskId);
|
|
|
|
if(details.isEmpty() || (extended && expanded != taskId)) {
|
|
|
|
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
view.setVisibility(View.VISIBLE);
|
|
|
|
view.setVisibility(View.VISIBLE);
|
|
|
|
@ -457,7 +499,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
String string = detailText.toString();
|
|
|
|
String string = detailText.toString();
|
|
|
|
if(string.contains("<"))
|
|
|
|
if(string.contains("<"))
|
|
|
|
view.setText(Html.fromHtml(string.trim().replace("\n", "<br>"), imageGetter, null));
|
|
|
|
view.setText(Html.fromHtml(string.trim().replace("\n", "<br>"),
|
|
|
|
|
|
|
|
detailImageGetter, null));
|
|
|
|
else
|
|
|
|
else
|
|
|
|
view.setText(string.trim());
|
|
|
|
view.setText(string.trim());
|
|
|
|
Linkify.addLinks(view, Linkify.ALL);
|
|
|
|
Linkify.addLinks(view, Linkify.ALL);
|
|
|
|
@ -465,7 +508,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
void reset(ViewHolder viewHolder, long taskId) {
|
|
|
|
void reset(ViewHolder viewHolder, long taskId) {
|
|
|
|
TextView view = extended ? viewHolder.extendedDetails : viewHolder.details;
|
|
|
|
TextView view = viewHolder.extendedDetails;
|
|
|
|
view.setVisibility(View.GONE);
|
|
|
|
view.setVisibility(View.GONE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
@ -533,6 +576,11 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
*
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
*/
|
|
|
|
public class TaskActionManager extends AddOnManager<TaskAction> {
|
|
|
|
public class TaskActionManager extends AddOnManager<TaskAction> {
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final LinearLayout.LayoutParams params =
|
|
|
|
|
|
|
|
new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
|
|
|
|
|
|
|
LayoutParams.FILL_PARENT, 1f);
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
Intent createBroadcastIntent(long taskId) {
|
|
|
|
Intent createBroadcastIntent(long taskId) {
|
|
|
|
Intent intent = new Intent(AstridApiConstants.BROADCAST_REQUEST_ACTIONS);
|
|
|
|
Intent intent = new Intent(AstridApiConstants.BROADCAST_REQUEST_ACTIONS);
|
|
|
|
@ -545,15 +593,24 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
if(actions == null || viewHolder.task.getId() != taskId)
|
|
|
|
if(actions == null || viewHolder.task.getId() != taskId)
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
reset(viewHolder, taskId);
|
|
|
|
// hack because we know we have > 1 button
|
|
|
|
|
|
|
|
if(addOnService.hasPowerPack() && actions.size() == 0)
|
|
|
|
LinearLayout.LayoutParams params =
|
|
|
|
return;
|
|
|
|
new LinearLayout.LayoutParams(LayoutParams.FILL_PARENT,
|
|
|
|
|
|
|
|
LayoutParams.FILL_PARENT, 1f);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(int i = viewHolder.actions.getChildCount(); i < actions.size() + 1; i++) {
|
|
|
|
Button editButton = new Button(activity);
|
|
|
|
Button editButton = new Button(activity);
|
|
|
|
editButton.setText(R.string.TAd_actionEditTask);
|
|
|
|
editButton.setLayoutParams(params);
|
|
|
|
editButton.setOnClickListener(new OnClickListener() {
|
|
|
|
viewHolder.actions.addView(editButton);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
if(actions.size() + 1 < viewHolder.actions.getChildCount())
|
|
|
|
|
|
|
|
viewHolder.actions.removeViews(0, viewHolder.actions.getChildCount() -
|
|
|
|
|
|
|
|
actions.size() - 1);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int i = 0;
|
|
|
|
|
|
|
|
Button button = (Button) viewHolder.actions.getChildAt(i++);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
button.setText(R.string.TAd_actionEditTask);
|
|
|
|
|
|
|
|
button.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
public void onClick(View arg0) {
|
|
|
|
Intent intent = new Intent(activity, TaskEditActivity.class);
|
|
|
|
Intent intent = new Intent(activity, TaskEditActivity.class);
|
|
|
|
@ -561,17 +618,14 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
activity.startActivityForResult(intent, TaskListActivity.ACTIVITY_EDIT_TASK);
|
|
|
|
activity.startActivityForResult(intent, TaskListActivity.ACTIVITY_EDIT_TASK);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
editButton.setLayoutParams(params);
|
|
|
|
|
|
|
|
viewHolder.actions.addView(editButton);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
for(TaskAction action : actions) {
|
|
|
|
for(TaskAction action : actions) {
|
|
|
|
Button view = new Button(activity);
|
|
|
|
button = (Button) viewHolder.actions.getChildAt(i++);
|
|
|
|
view.setText(action.text);
|
|
|
|
button.setText(action.text);
|
|
|
|
view.setOnClickListener(new ActionClickListener(action));
|
|
|
|
button.setOnClickListener(new ActionClickListener(action));
|
|
|
|
view.setLayoutParams(params);
|
|
|
|
|
|
|
|
viewHolder.actions.addView(view);
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
reset(viewHolder, taskId);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
@ -581,7 +635,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
viewHolder.actions.setVisibility(View.VISIBLE);
|
|
|
|
viewHolder.actions.setVisibility(View.VISIBLE);
|
|
|
|
viewHolder.actions.removeAllViews();
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|