-
Notifications
You must be signed in to change notification settings - Fork 249
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
27 changed files
with
1,108 additions
and
73 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
94 changes: 94 additions & 0 deletions
94
opentasks/src/main/java/org/dmfs/tasks/detailsscreen/RowDataSubtaskViewParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,94 @@ | ||
/* | ||
* 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.tasks.detailsscreen; | ||
|
||
import org.dmfs.android.bolts.color.Color; | ||
import org.dmfs.android.contentpal.Projection; | ||
import org.dmfs.android.contentpal.RowDataSnapshot; | ||
import org.dmfs.android.contentpal.projections.Composite; | ||
import org.dmfs.jems.optional.Optional; | ||
import org.dmfs.opentaskspal.readdata.EffectiveDueDate; | ||
import org.dmfs.opentaskspal.readdata.EffectiveTaskColor; | ||
import org.dmfs.opentaskspal.readdata.Id; | ||
import org.dmfs.opentaskspal.readdata.PercentComplete; | ||
import org.dmfs.opentaskspal.readdata.TaskTitle; | ||
import org.dmfs.rfc5545.DateTime; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link SubtasksView.Params} that reads the data from the given {@link RowDataSnapshot}. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class RowDataSubtaskViewParams implements SubtaskView.Params | ||
{ | ||
|
||
/** | ||
* The projection required for this adapter to work. | ||
*/ | ||
public static final Projection<TaskContract.Tasks> SUBTASK_PROJECTION = new Composite<>( | ||
Id.PROJECTION, | ||
TaskTitle.PROJECTION, | ||
EffectiveDueDate.PROJECTION, | ||
EffectiveTaskColor.PROJECTION, | ||
PercentComplete.PROJECTION | ||
); | ||
|
||
private final RowDataSnapshot<TaskContract.Tasks> mRowDataSnapshot; | ||
|
||
|
||
public RowDataSubtaskViewParams(RowDataSnapshot<TaskContract.Tasks> rowDataSnapshot) | ||
{ | ||
mRowDataSnapshot = rowDataSnapshot; | ||
} | ||
|
||
|
||
@Override | ||
public Long id() | ||
{ | ||
return new Id(mRowDataSnapshot).value(); | ||
} | ||
|
||
|
||
@Override | ||
public Optional<CharSequence> title() | ||
{ | ||
return new TaskTitle(mRowDataSnapshot); | ||
} | ||
|
||
|
||
@Override | ||
public Optional<DateTime> due() | ||
{ | ||
return new EffectiveDueDate(mRowDataSnapshot); | ||
} | ||
|
||
|
||
@Override | ||
public Color color() | ||
{ | ||
return new EffectiveTaskColor(mRowDataSnapshot); | ||
} | ||
|
||
|
||
@Override | ||
public Optional<Integer> percentComplete() | ||
{ | ||
return new PercentComplete(mRowDataSnapshot); | ||
} | ||
} |
55 changes: 55 additions & 0 deletions
55
opentasks/src/main/java/org/dmfs/tasks/detailsscreen/RowDataSubtasksViewParams.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
/* | ||
* 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.tasks.detailsscreen; | ||
|
||
import org.dmfs.android.bolts.color.Color; | ||
import org.dmfs.android.contentpal.RowDataSnapshot; | ||
import org.dmfs.jems.iterable.decorators.Mapped; | ||
import org.dmfs.tasks.contract.TaskContract; | ||
|
||
|
||
/** | ||
* {@link SubtasksView.Params} that adapts the given {@link RowDataSnapshot}s (and takes the list color). | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class RowDataSubtasksViewParams implements SubtasksView.Params | ||
{ | ||
private final Color mTaskListColor; | ||
private final Iterable<RowDataSnapshot<TaskContract.Tasks>> mSubtaskRows; | ||
|
||
|
||
public RowDataSubtasksViewParams(Color taskListColor, Iterable<RowDataSnapshot<TaskContract.Tasks>> subtaskRows) | ||
{ | ||
mTaskListColor = taskListColor; | ||
mSubtaskRows = subtaskRows; | ||
} | ||
|
||
|
||
@Override | ||
public Color taskListColor() | ||
{ | ||
return mTaskListColor; | ||
} | ||
|
||
|
||
@Override | ||
public Iterable<SubtaskView.Params> subtasks() | ||
{ | ||
return new Mapped<>(RowDataSubtaskViewParams::new, mSubtaskRows); | ||
} | ||
} |
96 changes: 96 additions & 0 deletions
96
opentasks/src/main/java/org/dmfs/tasks/detailsscreen/SubtaskView.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,96 @@ | ||
/* | ||
* Copyright 2017 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.tasks.detailsscreen; | ||
|
||
import android.content.Context; | ||
import android.content.Intent; | ||
import android.util.AttributeSet; | ||
import android.view.View; | ||
import android.widget.FrameLayout; | ||
|
||
import org.dmfs.android.bolts.color.Color; | ||
import org.dmfs.jems.optional.Optional; | ||
import org.dmfs.jems.single.combined.Backed; | ||
import org.dmfs.rfc5545.DateTime; | ||
import org.dmfs.tasks.R; | ||
import org.dmfs.tasks.databinding.OpentasksViewItemTaskDetailsSubtaskBinding; | ||
import org.dmfs.tasks.readdata.TaskContentUri; | ||
import org.dmfs.tasks.utils.DateFormatter; | ||
import org.dmfs.tasks.utils.DateFormatter.DateFormatContext; | ||
import org.dmfs.tasks.widget.ProgressBackgroundView; | ||
import org.dmfs.tasks.widget.SmartView; | ||
|
||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.databinding.DataBindingUtil; | ||
|
||
|
||
/** | ||
* {@link View} for showing a subtask on the details screen. | ||
* | ||
* @author Gabor Keszthelyi | ||
*/ | ||
public final class SubtaskView extends FrameLayout implements SmartView<SubtaskView.Params> | ||
{ | ||
|
||
public interface Params // i.e. fields of the subtask | ||
{ | ||
Long id(); | ||
|
||
Optional<CharSequence> title(); | ||
|
||
Optional<DateTime> due(); | ||
|
||
Color color(); | ||
|
||
Optional<Integer> percentComplete(); | ||
} | ||
|
||
|
||
public SubtaskView(@NonNull Context context, @Nullable AttributeSet attrs) | ||
{ | ||
super(context, attrs); | ||
} | ||
|
||
|
||
@Override | ||
public void update(Params subtask) | ||
{ | ||
OpentasksViewItemTaskDetailsSubtaskBinding views = DataBindingUtil.bind(this); | ||
|
||
views.opentasksTaskDetailsSubtaskTitle.setText( | ||
new Backed<>(subtask.title(), getContext().getString(R.string.opentasks_task_details_subtask_untitled)).value()); | ||
|
||
if (subtask.due().isPresent()) | ||
{ | ||
views.opentasksTaskDetailsSubtaskDue.setText( | ||
new DateFormatter(getContext()).format(subtask.due().value(), DateTime.now(), DateFormatContext.LIST_VIEW)); | ||
} | ||
|
||
views.opentasksTaskDetailsSubtaskListRibbon.setBackgroundColor(subtask.color().argb()); | ||
|
||
new ProgressBackgroundView(views.opentasksTaskDetailsSubtaskProgressBackground) | ||
.update(subtask.percentComplete()); | ||
|
||
views.getRoot().setOnClickListener((v) -> | ||
{ | ||
Context ctx = v.getContext(); | ||
// TODO Use BasicTaskDetailsUi class when #589 is merged | ||
ctx.startActivity(new Intent(Intent.ACTION_VIEW, new TaskContentUri(subtask.id(), ctx).value())); | ||
}); | ||
} | ||
} |
Oops, something went wrong.