diff options
Diffstat (limited to 'app')
5 files changed, 38 insertions, 10 deletions
diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AbstractCardViewHolder.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AbstractCardViewHolder.java index bad539918..da9790a0d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AbstractCardViewHolder.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/AbstractCardViewHolder.java @@ -67,7 +67,7 @@ public abstract class AbstractCardViewHolder extends RecyclerView.ViewHolder { getNotSyncedYet().setVisibility(DBStatus.LOCAL_EDITED.equals(fullCard.getStatusEnum()) ? View.VISIBLE : View.GONE); if (fullCard.getCard().getDueDate() != null || fullCard.getCard().getDone() != null) { - setupTemporalChip(getCardDueDate(), fullCard.getCard()); + setupDueDate(getCardDueDate(), fullCard.getCard()); getCardDueDate().setVisibility(View.VISIBLE); } else { getCardDueDate().setVisibility(View.GONE); @@ -113,15 +113,12 @@ public abstract class AbstractCardViewHolder extends RecyclerView.ViewHolder { return getCard(); } - /** - * Sets up a temporal information, e. g. {@link Card#getDone()} or {@link Card#getDueDate()} - */ - private static void setupTemporalChip(@NonNull TextView cardDueDate, @NonNull Card card) { + private static void setupDueDate(@NonNull TextView cardDueDate, @NonNull Card card) { final boolean isDone = card.getDone() != null; - final Instant temporalInformation = isDone ? card.getDone() : card.getDueDate(); + final Instant date = isDone ? card.getDone() : card.getDueDate(); - cardDueDate.setText(DateUtil.getRelativeDateTimeString(cardDueDate.getContext(), temporalInformation.toEpochMilli())); - DeckViewThemeUtils.themeTemporalChip(cardDueDate, temporalInformation.atZone(ZoneId.systemDefault()).toLocalDate(), isDone); + cardDueDate.setText(DateUtil.getRelativeDateTimeString(cardDueDate.getContext(), date.toEpochMilli())); + DeckViewThemeUtils.themeDueDate(cardDueDate, date.atZone(ZoneId.systemDefault()).toLocalDate(), isDone); } protected static void setupCoverImages(@NonNull Account account, @NonNull ViewGroup coverImagesHolder, @NonNull FullCard fullCard, int maxCoverImagesCount) { diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java index 76c99abe9..dd9b2785d 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/card/details/CardDetailsFragment.java @@ -33,6 +33,7 @@ import com.wdullaer.materialdatetimepicker.date.DatePickerDialog.OnDateSetListen import com.wdullaer.materialdatetimepicker.time.TimePickerDialog; import com.wdullaer.materialdatetimepicker.time.TimePickerDialog.OnTimeSetListener; +import java.time.Instant; import java.time.LocalDate; import java.time.LocalTime; import java.time.ZoneId; @@ -152,6 +153,8 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, binding.descriptionEditor.setSearchColor(color); binding.descriptionViewer.setSearchColor(color); + utils.material.colorMaterialButtonPrimaryFilled(binding.markAsDone); + // TODO apply correct branding on the BrandedDatePicker } @@ -194,6 +197,7 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, } private void setupDueDate() { + if (this.viewModel.getFullCard().getCard().getDueDate() != null) { final var dueDate = this.viewModel.getFullCard().getCard().getDueDate().atZone(ZoneId.systemDefault()); binding.dueDateDate.setText(dueDate == null ? null : dueDate.format(dateFormatter)); @@ -206,6 +210,16 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, } if (viewModel.canEdit()) { + if (this.viewModel.getFullCard().getCard().getDone() == null) { + binding.markAsDone.setVisibility(VISIBLE); + } else { + binding.markAsDone.setVisibility(GONE); + } + + binding.markAsDone.setOnClickListener(v -> { + viewModel.getFullCard().getCard().setDone(Instant.now()); + }); + binding.dueDateDate.setOnClickListener(v -> { final LocalDate date; if (viewModel.getFullCard() != null && viewModel.getFullCard().getCard() != null && viewModel.getFullCard().getCard().getDueDate() != null) { @@ -240,6 +254,7 @@ public class CardDetailsFragment extends Fragment implements OnDateSetListener, binding.dueDateDate.setEnabled(false); binding.dueDateTime.setEnabled(false); binding.clearDueDate.setVisibility(GONE); + binding.markAsDone.setVisibility(GONE); } } diff --git a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java index b219f75bc..d1b1535fd 100644 --- a/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java +++ b/app/src/main/java/it/niedermann/nextcloud/deck/ui/theme/DeckViewThemeUtils.java @@ -197,7 +197,7 @@ public class DeckViewThemeUtils extends ViewThemeUtilsBase { @Deprecated(forRemoval = true) - public static void themeTemporalChip(@NonNull TextView cardDueDate, @NonNull LocalDate date, boolean isDone) { + public static void themeDueDate(@NonNull TextView cardDueDate, @NonNull LocalDate date, boolean isDone) { final var context = cardDueDate.getContext(); @ColorInt @Nullable Integer textColor = null; diff --git a/app/src/main/res/layout/fragment_card_edit_tab_details.xml b/app/src/main/res/layout/fragment_card_edit_tab_details.xml index 631bc342f..39daeb4f4 100644 --- a/app/src/main/res/layout/fragment_card_edit_tab_details.xml +++ b/app/src/main/res/layout/fragment_card_edit_tab_details.xml @@ -83,7 +83,7 @@ android:layout_marginEnd="@dimen/spacer_2x" android:hint="@string/hint_due_date_date" android:labelFor="@id/dueDateDate" - app:layout_constraintBottom_toTopOf="@id/descriptionWrapper" + app:layout_constraintBottom_toTopOf="@id/markAsDone" app:layout_constraintEnd_toStartOf="@id/dueDateTimeWrapper" app:layout_constraintHorizontal_weight="2" app:layout_constraintStart_toStartOf="parent" @@ -145,6 +145,21 @@ app:layout_constraintTop_toTopOf="@id/dueDateTimeWrapper" app:srcCompat="@drawable/ic_close_circle_grey600" /> + <com.google.android.material.button.MaterialButton + android:id="@+id/markAsDone" + style="@style/Widget.Material3.Button" + android:layout_width="0dp" + android:layout_height="wrap_content" + android:layout_marginTop="@dimen/spacer_2x" + android:layout_marginBottom="@dimen/spacer_1hx" + android:text="@string/simple_completed" + app:backgroundTint="@color/defaultBrand" + app:icon="@drawable/ic_check_white_24dp" + app:layout_constraintBottom_toTopOf="@id/descriptionWrapper" + app:layout_constraintEnd_toEndOf="parent" + app:layout_constraintStart_toStartOf="@+id/dueDateTimeWrapper" + app:layout_constraintTop_toBottomOf="@id/dueDateDateWrapper" /> + <RelativeLayout android:id="@+id/descriptionWrapper" android:layout_width="match_parent" diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 23c2b079b..71b56aeab 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -19,6 +19,7 @@ <string name="simple_open">Open</string> <string name="simple_switch">Switch</string> <string name="simple_filter">Filter</string> + <string name="simple_completed">Completed</string> <string name="simple_overdue">Overdue</string> <string name="simple_clear">Clear</string> <string name="simple_discard">Discard</string> |