-
-
Notifications
You must be signed in to change notification settings - Fork 53
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(done): Enhance due date / done UX in board view
- Use βοΈ icon when done is present in favor of π / π in board view - Change icon from π to π for due dates - Move temporal information into own reusable component to encapsulate logic Refs: #1556 Signed-off-by: Stefan Niedermann <info@niedermann.it>
- Loading branch information
1 parent
8ab9514
commit 8471bf3
Showing
14 changed files
with
135 additions
and
86 deletions.
There are no files selected for viewing
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
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
105 changes: 105 additions & 0 deletions
105
app/src/main/java/it/niedermann/nextcloud/deck/ui/view/DueDateChip.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,105 @@ | ||
package it.niedermann.nextcloud.deck.ui.view; | ||
|
||
import static java.time.temporal.ChronoUnit.DAYS; | ||
|
||
import android.content.Context; | ||
import android.content.res.ColorStateList; | ||
import android.util.AttributeSet; | ||
import android.util.TypedValue; | ||
|
||
import androidx.annotation.ColorInt; | ||
import androidx.annotation.ColorRes; | ||
import androidx.annotation.DrawableRes; | ||
import androidx.annotation.NonNull; | ||
import androidx.annotation.Nullable; | ||
import androidx.annotation.Px; | ||
import androidx.core.content.ContextCompat; | ||
|
||
import com.google.android.material.chip.Chip; | ||
|
||
import java.time.Instant; | ||
import java.time.LocalDate; | ||
import java.time.ZoneId; | ||
|
||
import it.niedermann.android.util.DimensionUtil; | ||
import it.niedermann.nextcloud.deck.R; | ||
import it.niedermann.nextcloud.deck.util.DateUtil; | ||
|
||
public class DueDateChip extends Chip { | ||
|
||
protected @ColorInt int colorOnSurface; | ||
|
||
public DueDateChip(Context context) { | ||
super(context); | ||
initialize(); | ||
} | ||
|
||
public DueDateChip(Context context, AttributeSet attrs) { | ||
super(context, attrs); | ||
initialize(); | ||
} | ||
|
||
public DueDateChip(Context context, AttributeSet attrs, int defStyleAttr) { | ||
super(context, attrs, defStyleAttr); | ||
initialize(); | ||
} | ||
|
||
private void initialize() { | ||
setEnsureMinTouchTargetSize(false); | ||
setMinHeight(0); | ||
setChipMinHeight(0); | ||
@Px final var padding = DimensionUtil.INSTANCE.dpToPx(getContext(), R.dimen.spacer_1x); | ||
setPadding(padding, padding, padding, padding); | ||
setClickable(false); | ||
|
||
final var typedValue = new TypedValue(); | ||
final var theme = getContext().getTheme(); | ||
theme.resolveAttribute(R.attr.colorOnSurface, typedValue, true); | ||
this.colorOnSurface = typedValue.data; | ||
} | ||
|
||
public void setDueDate(@NonNull Instant date, boolean isDone) { | ||
setText(DateUtil.getRelativeDateTimeString(getContext(), date.toEpochMilli())); | ||
|
||
@DrawableRes final int chipIconRes; | ||
@Nullable @ColorRes final Integer textColorRes; | ||
@ColorRes final int backgroundColorRes; | ||
|
||
if (isDone) { // Done | ||
chipIconRes = R.drawable.ic_check_white_24dp; | ||
backgroundColorRes = R.color.due_done; | ||
textColorRes = R.color.due_text_done; | ||
|
||
} else { | ||
final long diff = DAYS.between(LocalDate.now(), date.atZone(ZoneId.systemDefault()).toLocalDate()); | ||
|
||
if (diff == 0) { // Today | ||
chipIconRes = R.drawable.ic_time_24; | ||
backgroundColorRes = R.color.due_today; | ||
textColorRes = R.color.due_text_today; | ||
|
||
} else if (diff < 0) { // Overdue | ||
chipIconRes = R.drawable.ic_time_filled_24; | ||
backgroundColorRes = R.color.due_overdue; | ||
textColorRes = R.color.due_text_overdue; | ||
|
||
} else { // Future | ||
chipIconRes = R.drawable.ic_time_24; | ||
backgroundColorRes = android.R.color.transparent; | ||
textColorRes = null; | ||
} | ||
} | ||
|
||
setChipIcon(ContextCompat.getDrawable(getContext(), chipIconRes)); | ||
setChipBackgroundColorResource(backgroundColorRes); | ||
|
||
if (textColorRes == null) { | ||
setTextColor(colorOnSurface); | ||
setChipIconTint(ColorStateList.valueOf(colorOnSurface)); | ||
|
||
} else { | ||
setTextColor(ContextCompat.getColor(getContext(), textColorRes)); | ||
setChipIconTintResource(textColorRes); | ||
} | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
<vector android:autoMirrored="true" android:height="24dp" | ||
android:tint="?attr/colorOnSurface" android:viewportHeight="24" | ||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM12,20c-4.42,0 -8,-3.58 -8,-8s3.58,-8 8,-8 8,3.58 8,8 -3.58,8 -8,8z"/> | ||
<path android:fillColor="@android:color/white" android:pathData="M12.5,7H11v6l5.25,3.15 0.75,-1.23 -4.5,-2.67z"/> | ||
</vector> |
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,5 @@ | ||
<vector android:autoMirrored="true" android:height="24dp" | ||
android:tint="?attr/colorOnSurface" android:viewportHeight="24" | ||
android:viewportWidth="24" android:width="24dp" xmlns:android="http://schemas.android.com/apk/res/android"> | ||
<path android:fillColor="@android:color/white" android:pathData="M11.99,2C6.47,2 2,6.48 2,12s4.47,10 9.99,10C17.52,22 22,17.52 22,12S17.52,2 11.99,2zM15.29,16.71L11,12.41V7h2v4.59l3.71,3.71L15.29,16.71z"/> | ||
</vector> |
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