Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 0ff0bfa4 authored by Marten Gajda's avatar Marten Gajda
Browse files

update check list view and constraint to use new field adapter

parent 7750d5c9
Loading
Loading
Loading
Loading
+1 −9
Original line number Diff line number Diff line
<?xml version="1.0" encoding="utf-8"?>
<org.dmfs.tasks.widget.CheckListFieldView xmlns:android="http://schemas.android.com/apk/res/android"
    style="@style/task_widget"
    android:visibility="gone" >
    android:visibility="visible" >

    <include layout="@layout/detail_header" />

    <TextView
        android:id="@+id/text"
        style="@style/field_view_text_value"
        android:layout_width="match_parent"
        android:layout_height="wrap_content"
        android:autoLink="all" >
    </TextView>

    <LinearLayout
        android:id="@+id/checklist"
        android:layout_width="match_parent"
+1 −0
Original line number Diff line number Diff line
@@ -46,6 +46,7 @@
    <string name="task_title">Title</string>
    <string name="task_location">Location</string>
    <string name="task_description">Description</string>
    <string name="task_checklist">Check list</string>
    <string name="task_start">Start</string>
    <string name="task_due">Due</string>
    <string name="task_completed">Completed</string>
+21 −0
Original line number Diff line number Diff line
package org.dmfs.tasks.model;

import android.text.TextUtils;


public final class CheckListItem
{
	public boolean checked;
@@ -11,4 +14,22 @@ public final class CheckListItem
		this.checked = checked;
		this.text = text;
	}


	@Override
	public int hashCode()
	{
		return text != null ? (text.hashCode() << 1) + (checked ? 1 : 0) : (checked ? 1 : 0);
	}


	public boolean equals(Object o)
	{
		if (!(o instanceof CheckListItem))
		{
			return false;
		}
		CheckListItem other = (CheckListItem) o;
		return TextUtils.equals(text, other.text) && checked == other.checked;
	};
}
+6 −2
Original line number Diff line number Diff line
@@ -96,8 +96,12 @@ public class DefaultModel extends Model
		mFields.add(new FieldDescriptor(mContext, R.string.task_location, TaskFieldAdapters.LOCATION).setViewLayout(TEXT_VIEW).setEditorLayout(TEXT_EDIT));

		// description
		mFields.add(new FieldDescriptor(mContext, R.string.task_description, TaskFieldAdapters.DESCRIPTION).setViewLayout(TEXT_VIEW).setEditorLayout(
			TEXT_EDIT));
		mFields
			.add(new FieldDescriptor(mContext, R.string.task_description, TaskFieldAdapters.DESCRIPTION).setViewLayout(TEXT_VIEW).setEditorLayout(TEXT_EDIT));

		// description
		mFields.add(new FieldDescriptor(mContext, R.string.task_checklist, TaskFieldAdapters.CHECKLIST).setViewLayout(CHECKLIST_VIEW).setEditorLayout(
			CHECKLIST_EDIT));

		// start
		mFields.add(new FieldDescriptor(mContext, R.string.task_start, TaskFieldAdapters.DTSTART).setViewLayout(TIME_VIEW).setEditorLayout(TIME_EDIT));
+8 −0
Original line number Diff line number Diff line
@@ -20,6 +20,7 @@ package org.dmfs.tasks.model;
import org.dmfs.provider.tasks.TaskContract;
import org.dmfs.provider.tasks.TaskContract.Tasks;
import org.dmfs.tasks.model.adapters.BooleanFieldAdapter;
import org.dmfs.tasks.model.adapters.ChecklistFieldAdapter;
import org.dmfs.tasks.model.adapters.DescriptionStringFieldAdapter;
import org.dmfs.tasks.model.adapters.FloatFieldAdapter;
import org.dmfs.tasks.model.adapters.IntegerFieldAdapter;
@@ -28,6 +29,7 @@ import org.dmfs.tasks.model.adapters.TimeFieldAdapter;
import org.dmfs.tasks.model.adapters.TimezoneFieldAdapter;
import org.dmfs.tasks.model.adapters.UrlFieldAdapter;
import org.dmfs.tasks.model.contraints.AdjustPercentComplete;
import org.dmfs.tasks.model.contraints.ChecklistConstraint;
import org.dmfs.tasks.model.contraints.NotAfter;
import org.dmfs.tasks.model.contraints.NotBefore;

@@ -90,6 +92,12 @@ public final class TaskFieldAdapters
	 */
	public final static DescriptionStringFieldAdapter DESCRIPTION = new DescriptionStringFieldAdapter(Tasks.DESCRIPTION);

	/**
	 * Adapter for the checklist of a task.
	 */
	public final static ChecklistFieldAdapter CHECKLIST = (ChecklistFieldAdapter) new ChecklistFieldAdapter(Tasks.DESCRIPTION)
		.addContraint(new ChecklistConstraint(STATUS, PERCENT_COMPLETE));

	/**
	 * Private adapter for the start date of a task. We need this to reference DTSTART from DUE.
	 */
Loading