Apply branding to sync status

This commit is contained in:
Stefan Niedermann 2020-06-21 10:12:04 +02:00
parent 4a3f132b95
commit 778ee79194
5 changed files with 12 additions and 4 deletions

View file

@ -41,7 +41,7 @@ public class NoteViewGridHolder extends NoteViewHolder {
super.bind(note, showCategory, mainColor, textColor, searchQuery); super.bind(note, showCategory, mainColor, textColor, searchQuery);
@NonNull final Context context = itemView.getContext(); @NonNull final Context context = itemView.getContext();
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor); 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()); bindFavorite(binding.noteFavorite, note.isFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor);
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), mainColor); bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), mainColor);

View file

@ -35,7 +35,7 @@ public class NoteViewGridHolderOnlyTitle extends NoteViewHolder {
public void bind(@NonNull DBNote note, boolean showCategory, int mainColor, int textColor, @Nullable CharSequence searchQuery) { public void bind(@NonNull DBNote note, boolean showCategory, int mainColor, int textColor, @Nullable CharSequence searchQuery) {
super.bind(note, showCategory, mainColor, textColor, searchQuery); super.bind(note, showCategory, mainColor, textColor, searchQuery);
@NonNull final Context context = itemView.getContext(); @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()); bindFavorite(binding.noteFavorite, note.isFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor);
} }

View file

@ -17,6 +17,7 @@ import androidx.annotation.CallSuper;
import androidx.annotation.ColorInt; import androidx.annotation.ColorInt;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.annotation.Nullable; import androidx.annotation.Nullable;
import androidx.appcompat.widget.AppCompatImageView;
import androidx.core.graphics.drawable.DrawableCompat; import androidx.core.graphics.drawable.DrawableCompat;
import androidx.recyclerview.widget.RecyclerView; 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.branding.BrandingUtil;
import it.niedermann.owncloud.notes.util.Notes; 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.contrastRatioIsSufficient;
import static it.niedermann.owncloud.notes.util.ColorUtil.isColorDark; 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)); 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) { protected void bindCategory(@NonNull Context context, @NonNull TextView noteCategory, boolean showCategory, @NonNull String category, int mainColor) {
final boolean isDarkThemeActive = Notes.isDarkThemeActive(context); final boolean isDarkThemeActive = Notes.isDarkThemeActive(context);
noteCategory.setVisibility(showCategory && !category.isEmpty() ? View.VISIBLE : View.GONE); noteCategory.setVisibility(showCategory && !category.isEmpty() ? View.VISIBLE : View.GONE);

View file

@ -29,7 +29,7 @@ public class NoteViewHolderWithExcerpt extends NoteViewHolder {
@NonNull final Context context = itemView.getContext(); @NonNull final Context context = itemView.getContext();
binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f); binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f);
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor); 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()); bindFavorite(binding.noteFavorite, note.isFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor);

View file

@ -29,7 +29,7 @@ public class NoteViewHolderWithoutExcerpt extends NoteViewHolder {
@NonNull final Context context = itemView.getContext(); @NonNull final Context context = itemView.getContext();
binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f); binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f);
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), mainColor); 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()); bindFavorite(binding.noteFavorite, note.isFavorite());
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor); bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), mainColor);
} }