|
|
@ -35,6 +35,7 @@ import android.text.Spannable;
|
|
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
import android.text.SpannableStringBuilder;
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.text.Spanned;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
import android.text.TextUtils;
|
|
|
|
|
|
|
|
import android.text.TextUtils.TruncateAt;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.util.DisplayMetrics;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.Log;
|
|
|
|
import android.util.TypedValue;
|
|
|
|
import android.util.TypedValue;
|
|
|
@ -143,6 +144,17 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
TAGS // Concatenated list of tags
|
|
|
|
TAGS // Concatenated list of tags
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static final Property<?>[] BASIC_PROPERTIES = new Property<?>[] {
|
|
|
|
|
|
|
|
Task.ID,
|
|
|
|
|
|
|
|
Task.TITLE,
|
|
|
|
|
|
|
|
Task.FLAGS,
|
|
|
|
|
|
|
|
Task.IMPORTANCE,
|
|
|
|
|
|
|
|
Task.RECURRENCE,
|
|
|
|
|
|
|
|
Task.COMPLETION_DATE,
|
|
|
|
|
|
|
|
Task.HIDE_UNTIL,
|
|
|
|
|
|
|
|
Task.DELETION_DATE
|
|
|
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
public static int[] IMPORTANCE_RESOURCES = new int[] {
|
|
|
|
public static int[] IMPORTANCE_RESOURCES = new int[] {
|
|
|
|
R.drawable.importance_check_1,
|
|
|
|
R.drawable.importance_check_1,
|
|
|
|
R.drawable.importance_check_2,
|
|
|
|
R.drawable.importance_check_2,
|
|
|
@ -202,6 +214,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
protected final DisplayMetrics displayMetrics;
|
|
|
|
protected final DisplayMetrics displayMetrics;
|
|
|
|
|
|
|
|
|
|
|
|
private final boolean simpleLayout;
|
|
|
|
private final boolean simpleLayout;
|
|
|
|
|
|
|
|
private final boolean titleOnlyLayout;
|
|
|
|
protected final int minRowHeight;
|
|
|
|
protected final int minRowHeight;
|
|
|
|
|
|
|
|
|
|
|
|
// --- task detail and decoration soft caches
|
|
|
|
// --- task detail and decoration soft caches
|
|
|
@ -229,6 +242,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
|
|
|
|
|
|
|
|
this.query = query;
|
|
|
|
this.query = query;
|
|
|
|
this.resource = resource;
|
|
|
|
this.resource = resource;
|
|
|
|
|
|
|
|
this.titleOnlyLayout = resource == R.layout.task_adapter_row_title_only;
|
|
|
|
this.fragment = fragment;
|
|
|
|
this.fragment = fragment;
|
|
|
|
this.resources = fragment.getResources();
|
|
|
|
this.resources = fragment.getResources();
|
|
|
|
this.onCompletedTaskListener = onCompletedTaskListener;
|
|
|
|
this.onCompletedTaskListener = onCompletedTaskListener;
|
|
|
@ -260,7 +274,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
|
|
|
|
|
|
|
|
protected int computeMinRowHeight() {
|
|
|
|
protected int computeMinRowHeight() {
|
|
|
|
DisplayMetrics metrics = resources.getDisplayMetrics();
|
|
|
|
DisplayMetrics metrics = resources.getDisplayMetrics();
|
|
|
|
if (simpleLayout) {
|
|
|
|
if (simpleLayout || titleOnlyLayout) {
|
|
|
|
return (int) (metrics.density * 40);
|
|
|
|
return (int) (metrics.density * 40);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
return (int) (metrics.density * 45);
|
|
|
|
return (int) (metrics.density * 45);
|
|
|
@ -277,16 +291,18 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void startDetailThread() {
|
|
|
|
private void startDetailThread() {
|
|
|
|
if (Preferences.getBoolean(R.string.p_showNotes, false) && !simpleLayout) {
|
|
|
|
if (Preferences.getBoolean(R.string.p_showNotes, false) && !simpleLayout && !titleOnlyLayout) {
|
|
|
|
detailLoader = new DetailLoaderThread();
|
|
|
|
detailLoader = new DetailLoaderThread();
|
|
|
|
detailLoader.start();
|
|
|
|
detailLoader.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void startTaskActionsThread() {
|
|
|
|
private void startTaskActionsThread() {
|
|
|
|
|
|
|
|
if (!titleOnlyLayout) {
|
|
|
|
actionsLoader = new ActionsLoaderThread();
|
|
|
|
actionsLoader = new ActionsLoaderThread();
|
|
|
|
actionsLoader.start();
|
|
|
|
actionsLoader.start();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
/* ======================================================================
|
|
|
|
/* ======================================================================
|
|
|
|
* =========================================================== filterable
|
|
|
|
* =========================================================== filterable
|
|
|
@ -336,13 +352,17 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
|
|
|
|
|
|
|
|
boolean showFullTaskTitle = Preferences.getBoolean(R.string.p_fullTaskTitle, false);
|
|
|
|
boolean showFullTaskTitle = Preferences.getBoolean(R.string.p_fullTaskTitle, false);
|
|
|
|
boolean showNotes = Preferences.getBoolean(R.string.p_showNotes, false);
|
|
|
|
boolean showNotes = Preferences.getBoolean(R.string.p_showNotes, false);
|
|
|
|
if (showFullTaskTitle) {
|
|
|
|
if (showFullTaskTitle && !titleOnlyLayout) {
|
|
|
|
viewHolder.nameView.setMaxLines(Integer.MAX_VALUE);
|
|
|
|
viewHolder.nameView.setMaxLines(Integer.MAX_VALUE);
|
|
|
|
viewHolder.nameView.setSingleLine(false);
|
|
|
|
viewHolder.nameView.setSingleLine(false);
|
|
|
|
viewHolder.nameView.setEllipsize(null);
|
|
|
|
viewHolder.nameView.setEllipsize(null);
|
|
|
|
|
|
|
|
} else if (titleOnlyLayout) {
|
|
|
|
|
|
|
|
viewHolder.nameView.setMaxLines(1);
|
|
|
|
|
|
|
|
viewHolder.nameView.setSingleLine(true);
|
|
|
|
|
|
|
|
viewHolder.nameView.setEllipsize(TruncateAt.END);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if (showNotes && !simpleLayout) {
|
|
|
|
if (showNotes && !simpleLayout && !titleOnlyLayout) {
|
|
|
|
RelativeLayout.LayoutParams taskRowParams = (RelativeLayout.LayoutParams)viewHolder.taskRow.getLayoutParams();
|
|
|
|
RelativeLayout.LayoutParams taskRowParams = (RelativeLayout.LayoutParams)viewHolder.taskRow.getLayoutParams();
|
|
|
|
taskRowParams.addRule(RelativeLayout.CENTER_VERTICAL, 0);
|
|
|
|
taskRowParams.addRule(RelativeLayout.CENTER_VERTICAL, 0);
|
|
|
|
}
|
|
|
|
}
|
|
|
@ -355,6 +375,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
viewHolder.details1.setTag(viewHolder);
|
|
|
|
viewHolder.details1.setTag(viewHolder);
|
|
|
|
|
|
|
|
|
|
|
|
// add UI component listeners
|
|
|
|
// add UI component listeners
|
|
|
|
|
|
|
|
if (!titleOnlyLayout)
|
|
|
|
addListeners(view);
|
|
|
|
addListeners(view);
|
|
|
|
|
|
|
|
|
|
|
|
return view;
|
|
|
|
return view;
|
|
|
@ -366,14 +387,17 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
TodorooCursor<Task> cursor = (TodorooCursor<Task>)c;
|
|
|
|
TodorooCursor<Task> cursor = (TodorooCursor<Task>)c;
|
|
|
|
ViewHolder viewHolder = ((ViewHolder)view.getTag());
|
|
|
|
ViewHolder viewHolder = ((ViewHolder)view.getTag());
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (!titleOnlyLayout) {
|
|
|
|
viewHolder.isTaskRabbit = (cursor.get(TASK_RABBIT_ID) > 0);
|
|
|
|
viewHolder.isTaskRabbit = (cursor.get(TASK_RABBIT_ID) > 0);
|
|
|
|
viewHolder.tagsString = cursor.get(TAGS);
|
|
|
|
viewHolder.tagsString = cursor.get(TAGS);
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
Task task = viewHolder.task;
|
|
|
|
Task task = viewHolder.task;
|
|
|
|
task.clear();
|
|
|
|
task.clear();
|
|
|
|
task.readFromCursor(cursor);
|
|
|
|
task.readFromCursor(cursor);
|
|
|
|
|
|
|
|
|
|
|
|
setFieldContentsAndVisibility(view);
|
|
|
|
setFieldContentsAndVisibility(view);
|
|
|
|
|
|
|
|
if (!titleOnlyLayout)
|
|
|
|
setTaskAppearance(viewHolder, task);
|
|
|
|
setTaskAppearance(viewHolder, task);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
@ -407,7 +431,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
public synchronized void setFieldContentsAndVisibility(View view) {
|
|
|
|
public synchronized void setFieldContentsAndVisibility(View view) {
|
|
|
|
ViewHolder viewHolder = (ViewHolder)view.getTag();
|
|
|
|
ViewHolder viewHolder = (ViewHolder)view.getTag();
|
|
|
|
Task task = viewHolder.task;
|
|
|
|
Task task = viewHolder.task;
|
|
|
|
if (fontSize < 16) {
|
|
|
|
if (fontSize < 16 || titleOnlyLayout) {
|
|
|
|
viewHolder.rowBody.setMinimumHeight(0);
|
|
|
|
viewHolder.rowBody.setMinimumHeight(0);
|
|
|
|
viewHolder.completeBox.setMinimumHeight(0);
|
|
|
|
viewHolder.completeBox.setMinimumHeight(0);
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
@ -432,6 +456,11 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
nameView.setText(nameValue);
|
|
|
|
nameView.setText(nameValue);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (titleOnlyLayout) {
|
|
|
|
|
|
|
|
setupCompleteBox(viewHolder);
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
float dueDateTextWidth = setupDueDateAndTags(viewHolder, task);
|
|
|
|
float dueDateTextWidth = setupDueDateAndTags(viewHolder, task);
|
|
|
|
|
|
|
|
|
|
|
|
String details;
|
|
|
|
String details;
|
|
|
@ -543,6 +572,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
viewHolder.completeBox.setOnTouchListener(otl);
|
|
|
|
viewHolder.completeBox.setOnTouchListener(otl);
|
|
|
|
viewHolder.completeBox.setOnClickListener(completeBoxListener);
|
|
|
|
viewHolder.completeBox.setOnClickListener(completeBoxListener);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (viewHolder.picture != null) {
|
|
|
|
viewHolder.picture.setOnTouchListener(otl);
|
|
|
|
viewHolder.picture.setOnTouchListener(otl);
|
|
|
|
viewHolder.picture.setOnClickListener(new OnClickListener() {
|
|
|
|
viewHolder.picture.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
@ -550,7 +580,9 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
viewHolder.completeBox.performClick();
|
|
|
|
viewHolder.completeBox.performClick();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if (viewHolder.taskActionContainer != null) {
|
|
|
|
viewHolder.taskActionContainer.setOnClickListener(new OnClickListener() {
|
|
|
|
viewHolder.taskActionContainer.setOnClickListener(new OnClickListener() {
|
|
|
|
@Override
|
|
|
|
@Override
|
|
|
|
public void onClick(View v) {
|
|
|
|
public void onClick(View v) {
|
|
|
@ -569,6 +601,7 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
private void showEditNotesDialog(final Task task) {
|
|
|
|
private void showEditNotesDialog(final Task task) {
|
|
|
|
int theme = ThemeService.getEditDialogTheme();
|
|
|
|
int theme = ThemeService.getEditDialogTheme();
|
|
|
@ -1124,7 +1157,14 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
setupCompleteBox(viewHolder);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void setupCompleteBox(ViewHolder viewHolder) {
|
|
|
|
// complete box
|
|
|
|
// complete box
|
|
|
|
|
|
|
|
final Task task = viewHolder.task;
|
|
|
|
|
|
|
|
final AsyncImageView pictureView = viewHolder.picture;
|
|
|
|
final CheckableImageView checkBoxView = viewHolder.completeBox; {
|
|
|
|
final CheckableImageView checkBoxView = viewHolder.completeBox; {
|
|
|
|
checkBoxView.setChecked(task.isCompleted());
|
|
|
|
checkBoxView.setChecked(task.isCompleted());
|
|
|
|
// disable checkbox if task is readonly
|
|
|
|
// disable checkbox if task is readonly
|
|
|
@ -1138,6 +1178,8 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
} else {
|
|
|
|
} else {
|
|
|
|
checkBoxView.setImageResource(IMPORTANCE_RESOURCES[value]);
|
|
|
|
checkBoxView.setImageResource(IMPORTANCE_RESOURCES[value]);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
if (titleOnlyLayout)
|
|
|
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
|
|
if (checkBoxView.isChecked()) {
|
|
|
|
if (checkBoxView.isChecked()) {
|
|
|
|
if (pictureView != null)
|
|
|
|
if (pictureView != null)
|
|
|
@ -1154,7 +1196,6 @@ public class TaskAdapter extends CursorAdapter implements Filterable {
|
|
|
|
checkBoxView.setVisibility(View.VISIBLE);
|
|
|
|
checkBoxView.setVisibility(View.VISIBLE);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Returns due date text width
|
|
|
|
// Returns due date text width
|
|
|
|