From 778ee791940c660f6bd12d4ae8d8b26bb270f450 Mon Sep 17 00:00:00 2001 From: Stefan Niedermann Date: Sun, 21 Jun 2020 10:12:04 +0200 Subject: [PATCH] Apply branding to sync status --- .../owncloud/notes/model/NoteViewGridHolder.java | 2 +- .../owncloud/notes/model/NoteViewGridHolderOnlyTitle.java | 2 +- .../niedermann/owncloud/notes/model/NoteViewHolder.java | 8 ++++++++ .../owncloud/notes/model/NoteViewHolderWithExcerpt.java | 2 +- .../notes/model/NoteViewHolderWithoutExcerpt.java | 2 +- 5 files changed, 12 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java index 6f840fb1..fa1f91c4 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolder.java @@ -41,7 +41,7 @@ public class NoteViewGridHolder extends NoteViewHolder { super.bind(note, showCategory, mainColor, textColor, searchQuery); @NonNull final Context context = itemView.getContext(); bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor); - binding.noteStatus.setVisibility(DBStatus.VOID.equals(note.getStatus()) ? INVISIBLE : VISIBLE); + bindStatus(binding.noteStatus, note.getStatus(), mainColor); bindFavorite(binding.noteFavorite, note.isFavorite()); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), mainColor); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolderOnlyTitle.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolderOnlyTitle.java index 59e14eff..3cee19e9 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolderOnlyTitle.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewGridHolderOnlyTitle.java @@ -35,7 +35,7 @@ public class NoteViewGridHolderOnlyTitle extends NoteViewHolder { public void bind(@NonNull DBNote note, boolean showCategory, int mainColor, int textColor, @Nullable CharSequence searchQuery) { super.bind(note, showCategory, mainColor, textColor, searchQuery); @NonNull final Context context = itemView.getContext(); - binding.noteStatus.setVisibility(DBStatus.VOID.equals(note.getStatus()) ? INVISIBLE : VISIBLE); + bindStatus(binding.noteStatus, note.getStatus(), mainColor); bindFavorite(binding.noteFavorite, note.isFavorite()); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); } diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java index c4e222e3..de83784c 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolder.java @@ -17,6 +17,7 @@ import androidx.annotation.CallSuper; import androidx.annotation.ColorInt; import androidx.annotation.NonNull; import androidx.annotation.Nullable; +import androidx.appcompat.widget.AppCompatImageView; import androidx.core.graphics.drawable.DrawableCompat; import androidx.recyclerview.widget.RecyclerView; @@ -29,6 +30,8 @@ import it.niedermann.owncloud.notes.R; import it.niedermann.owncloud.notes.branding.BrandingUtil; import it.niedermann.owncloud.notes.util.Notes; +import static android.view.View.INVISIBLE; +import static android.view.View.VISIBLE; import static it.niedermann.owncloud.notes.util.ColorUtil.contrastRatioIsSufficient; import static it.niedermann.owncloud.notes.util.ColorUtil.isColorDark; @@ -47,6 +50,11 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder { itemView.setOnLongClickListener((view) -> noteClickListener.onNoteLongClick(getAdapterPosition(), view)); } + protected void bindStatus(AppCompatImageView noteStatus, DBStatus status, int mainColor) { + noteStatus.setVisibility(DBStatus.VOID.equals(status) ? INVISIBLE : VISIBLE); + DrawableCompat.setTint(noteStatus.getDrawable(), BrandingUtil.getSecondaryForegroundColorDependingOnTheme(noteStatus.getContext(), mainColor)); + } + protected void bindCategory(@NonNull Context context, @NonNull TextView noteCategory, boolean showCategory, @NonNull String category, int mainColor) { final boolean isDarkThemeActive = Notes.isDarkThemeActive(context); noteCategory.setVisibility(showCategory && !category.isEmpty() ? View.VISIBLE : View.GONE); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithExcerpt.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithExcerpt.java index 88010fbd..05dc07c4 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithExcerpt.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithExcerpt.java @@ -29,7 +29,7 @@ public class NoteViewHolderWithExcerpt extends NoteViewHolder { @NonNull final Context context = itemView.getContext(); binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f); bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor); - binding.noteStatus.setVisibility(DBStatus.VOID.equals(note.getStatus()) ? View.INVISIBLE : View.VISIBLE); + bindStatus(binding.noteStatus, note.getStatus(), mainColor); bindFavorite(binding.noteFavorite, note.isFavorite()); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); diff --git a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithoutExcerpt.java b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithoutExcerpt.java index acdb4fb6..2af456a8 100644 --- a/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithoutExcerpt.java +++ b/app/src/main/java/it/niedermann/owncloud/notes/model/NoteViewHolderWithoutExcerpt.java @@ -29,7 +29,7 @@ public class NoteViewHolderWithoutExcerpt extends NoteViewHolder { @NonNull final Context context = itemView.getContext(); binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f); bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor); - binding.noteStatus.setVisibility(DBStatus.VOID.equals(note.getStatus()) ? View.INVISIBLE : View.VISIBLE); + bindStatus(binding.noteStatus, note.getStatus(), mainColor); bindFavorite(binding.noteFavorite, note.isFavorite()); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); }