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

Unverified Commit 08bbda6a authored by Marten Gajda's avatar Marten Gajda Committed by GitHub
Browse files

Add OpenTasksPal classes to support SubTasks, #442 (#935)

This adds a few more RowData implementations to support the implementation of SubTasks.
parent a59ca624
Loading
Loading
Loading
Loading
+3 −5
Original line number Diff line number Diff line
@@ -16,12 +16,9 @@

package org.dmfs.opentaskspal.readdata;

import androidx.annotation.NonNull;

import org.dmfs.android.contentpal.Projection;
import org.dmfs.android.contentpal.RowDataSnapshot;
import org.dmfs.android.contentpal.projections.Composite;
import org.dmfs.android.contentpal.projections.Joined;
import org.dmfs.android.contentpal.projections.MultiProjection;
import org.dmfs.iterables.elementary.Seq;
import org.dmfs.jems.optional.Optional;
@@ -32,6 +29,8 @@ import org.dmfs.rfc5545.DateTime;
import org.dmfs.tasks.contract.TaskContract;
import org.dmfs.tasks.contract.TaskContract.Tasks;

import androidx.annotation.NonNull;


/**
 * {@link Optional} representing the effective due date of a task. It's either taken directly from the due value (if present) or from start + duration (if both
@@ -43,8 +42,7 @@ public final class EffectiveDueDate extends DelegatingOptional<DateTime>
{
    public static final Projection<? super TaskContract.TaskColumns> PROJECTION = new Composite<>(
            new MultiProjection<>(Tasks.DUE, Tasks.DTSTART),
            // TODO: figure out how to get rid of Joined here
            new Joined<>(TaskDateTime.PROJECTION),
            TaskDateTime.PROJECTION,
            TaskDuration.PROJECTION);


+4 −2
Original line number Diff line number Diff line
@@ -21,6 +21,8 @@ import org.dmfs.android.contentpal.tables.BaseTable;
import org.dmfs.android.contentpal.tables.DelegatingTable;
import org.dmfs.tasks.contract.TaskContract;

import androidx.annotation.NonNull;


/**
 * {@link Table} for {@link TaskContract.Properties}.
@@ -29,8 +31,8 @@ import org.dmfs.tasks.contract.TaskContract;
 */
public final class PropertiesTable extends DelegatingTable<TaskContract.Properties>
{
    public PropertiesTable(String authority)
    public PropertiesTable(@NonNull String authority)
    {
        super(new BaseTable<TaskContract.Properties>(TaskContract.Properties.getContentUri(authority)));
        super(new BaseTable<>(TaskContract.Properties.getContentUri(authority)));
    }
}
+40 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.opentaskspal.tasklists;

import org.dmfs.android.bolts.color.Color;
import org.dmfs.android.contentpal.RowData;
import org.dmfs.android.contentpal.rowdata.DelegatingRowData;
import org.dmfs.tasks.contract.TaskContract;

import androidx.annotation.NonNull;


/**
 * {@link RowData} of the color of a task list.
 *
 * @author Marten Gajda
 */
public final class ColorData extends DelegatingRowData<TaskContract.TaskLists>
{

    public ColorData(@NonNull Color color)
    {
        super((transactionContext, builder) -> builder.withValue(TaskContract.TaskLists.LIST_COLOR, color.argb()));
    }

}
 No newline at end of file
+41 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.opentaskspal.tasklists;

import org.dmfs.android.contentpal.RowData;
import org.dmfs.android.contentpal.rowdata.CharSequenceRowData;
import org.dmfs.android.contentpal.rowdata.DelegatingRowData;
import org.dmfs.tasks.contract.TaskContract;

import androidx.annotation.NonNull;


/**
 * {@link RowData} of the owner account of a task list.
 *
 * @author Marten Gajda
 */
public final class OwnerData extends DelegatingRowData<TaskContract.TaskLists>
{

    public OwnerData(@NonNull CharSequence owner)
    {
        // TODO CharSequenceRowData allows null so this class wouldn't fail with that but erase the value
        super(new CharSequenceRowData<>(TaskContract.TaskLists.OWNER, owner));
    }

}
 No newline at end of file
+43 −0
Original line number Diff line number Diff line
/*
 * Copyright 2018 dmfs GmbH
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *     http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.dmfs.opentaskspal.tasklists;

import org.dmfs.android.contentpal.RowData;
import org.dmfs.android.contentpal.rowdata.DelegatingRowData;
import org.dmfs.tasks.contract.TaskContract;


/**
 * {@link RowData} of the sync status of a task list.
 *
 * @author Marten Gajda
 */
public final class SyncStatusData extends DelegatingRowData<TaskContract.TaskLists>
{

    public SyncStatusData()
    {
        this(true);
    }


    public SyncStatusData(boolean syncEnabled)
    {
        super((transactionContext, builder) -> builder.withValue(TaskContract.TaskLists.SYNC_ENABLED, syncEnabled ? 1 : 0));
    }

}
 No newline at end of file
Loading