Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -255,7 +255,10 @@ public void themeCard(@NonNull MaterialCardView view) {
new Pair<>(android.R.attr.state_activated, dynamicColor.secondaryContainer().getArgb(scheme)),
new Pair<>(-android.R.attr.state_activated, dynamicColor.surface().getArgb(scheme)))
);
view.setStrokeColor(dynamicColor.outlineVariant().getArgb(scheme));
view.setStrokeColor(buildColorStateList(
new Pair<>(android.R.attr.state_activated, dynamicColor.onSecondaryContainer().getArgb(scheme)),
new Pair<>(-android.R.attr.state_activated, dynamicColor.outlineVariant().getArgb(scheme)))
);
return view;
});
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -226,20 +226,20 @@ protected void onCreate(Bundle savedInstanceState) {

switch (selectedCategory.getType()) {
case RECENT -> {
activityBinding.searchText.setText(getString(R.string.search_in_all));
activityBinding.searchBar.searchText.setText(getString(R.string.search_in_all));
}
case FAVORITES -> {
activityBinding.searchText.setText(getString(R.string.search_in_category, getString(R.string.label_favorites)));
activityBinding.searchBar.searchText.setText(getString(R.string.search_in_category, getString(R.string.label_favorites)));
}
case UNCATEGORIZED -> {
activityBinding.searchText.setText(getString(R.string.search_in_category, getString(R.string.action_uncategorized)));
activityBinding.searchBar.searchText.setText(getString(R.string.search_in_category, getString(R.string.action_uncategorized)));
}
default -> {
final String category = selectedCategory.getCategory();
if (category == null) {
throw new IllegalStateException(NavigationCategory.class.getSimpleName() + " type is " + DEFAULT_CATEGORY + ", but category is null.");
}
activityBinding.searchText.setText(getString(R.string.search_in_category, NoteUtil.extendCategory(category)));
activityBinding.searchBar.searchText.setText(getString(R.string.search_in_category, NoteUtil.extendCategory(category)));
}
}

Expand Down Expand Up @@ -280,7 +280,7 @@ protected void onCreate(Bundle savedInstanceState) {
mainViewModel.getSearchTerm().observe(this, adapter::setHighlightSearchQuery);
mainViewModel.getCategorySortingMethodOfSelectedCategory().observe(this, methodOfCategory -> {
updateSortMethodIcon(methodOfCategory.second);
activityBinding.sortingMethod.setOnClickListener((v) -> {
activityBinding.searchBar.sortingMethod.setOnClickListener((v) -> {
if (methodOfCategory.first != null) {
int newId = 0;
if (methodOfCategory.second != null)
Expand All @@ -303,7 +303,7 @@ protected void onCreate(Bundle savedInstanceState) {
.placeholder(R.drawable.ic_account_circle_grey_24dp)
.error(R.drawable.ic_account_circle_grey_24dp)
.apply(RequestOptions.circleCropTransform())
.into(activityBinding.launchAccountSwitcher);
.into(activityBinding.searchBar.launchAccountSwitcher);

mainViewModel.synchronizeNotes(this, nextAccount, new IResponseCallback<>() {
@Override
Expand Down Expand Up @@ -331,7 +331,7 @@ public void onError(@NonNull Throwable t) {
}
});
fabCreate.show();
activityBinding.launchAccountSwitcher.setOnClickListener((v) -> AccountSwitcherDialog.newInstance(nextAccount.getId()).show(getSupportFragmentManager(), AccountSwitcherDialog.class.getSimpleName()));
activityBinding.searchBar.launchAccountSwitcher.setOnClickListener((v) -> AccountSwitcherDialog.newInstance(nextAccount.getId()).show(getSupportFragmentManager(), AccountSwitcherDialog.class.getSimpleName()));

if (menuAdapter == null) {
menuAdapter = new MenuAdapter(getApplicationContext(), nextAccount, REQUEST_CODE_SERVER_SETTINGS, (menuItem) -> {
Expand Down Expand Up @@ -484,13 +484,13 @@ protected void onRestoreInstanceState(@NonNull Bundle savedInstanceState) {

private void setupToolbars() {
setSupportActionBar(binding.activityNotesListView.searchToolbar);
activityBinding.homeToolbar.setOnClickListener((v) -> {
activityBinding.searchBar.homeToolbar.setOnClickListener((v) -> {
if (activityBinding.searchToolbar.getVisibility() == GONE) {
updateToolbars(true);
}
});

final var toggle = new ActionBarDrawerToggle(this, binding.drawerLayout, activityBinding.homeToolbar, 0, 0);
final var toggle = new ActionBarDrawerToggle(this, binding.drawerLayout, activityBinding.searchBar.homeToolbar, 0, 0);
binding.drawerLayout.addDrawerListener(toggle);
toggle.syncState();

Expand Down Expand Up @@ -525,7 +525,7 @@ private void setupNotesList() {
listView.setLayoutManager(gridLayoutManager);
listView.addItemDecoration(new GridItemDecoration(adapter, spanCount,
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
getResources().getDimensionPixelSize(R.dimen.spacer_5x),
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
getResources().getDimensionPixelSize(R.dimen.spacer_1x),
getResources().getDimensionPixelSize(R.dimen.spacer_activity_sides) + getResources().getDimensionPixelSize(R.dimen.spacer_1x)
Expand All @@ -535,7 +535,7 @@ private void setupNotesList() {
listView.setLayoutManager(layoutManager);
listView.addItemDecoration(new SectionItemDecoration(adapter,
getResources().getDimensionPixelSize(R.dimen.spacer_activity_sides) + getResources().getDimensionPixelSize(R.dimen.spacer_1x) + getResources().getDimensionPixelSize(R.dimen.spacer_3x) + getResources().getDimensionPixelSize(R.dimen.spacer_2x),
getResources().getDimensionPixelSize(R.dimen.spacer_5x),
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
getResources().getDimensionPixelSize(R.dimen.spacer_1x),
0
));
Expand Down Expand Up @@ -684,11 +684,11 @@ public void applyBrand(int color) {
util.platform.colorCircularProgressBar(activityBinding.progressCircular, ColorRole.PRIMARY);
util.platform.colorNavigationView(binding.navigationView);
util.material.themeFAB(activityBinding.fabCreate);
util.notes.themeSearchCardView(binding.activityNotesListView.searchBarWrapper);
util.platform.colorViewBackground(getWindow().getDecorView());
util.platform.colorViewBackground(binding.getRoot());
util.platform.colorViewBackground(binding.activityNotesListView.activityNotesListView);
util.platform.colorTextView(binding.activityNotesListView.searchText, ColorRole.ON_SURFACE_VARIANT);
util.notes.themeSearchCardView(binding.activityNotesListView.searchBar.searchBarCardWrapper);
util.platform.colorViewBackground(getWindow().getDecorView(), ColorRole.SURFACE_CONTAINER);
util.platform.colorViewBackground(binding.getRoot(), ColorRole.SURFACE_CONTAINER);
util.platform.colorViewBackground(binding.activityNotesListView.activityNotesListView, ColorRole.SURFACE_CONTAINER);
util.platform.colorTextView(binding.activityNotesListView.searchBar.searchText, ColorRole.ON_SURFACE_VARIANT);
util.notes.themeSearchToolbar(binding.activityNotesListView.searchToolbar);
util.notes.themeToolbarSearchView(binding.activityNotesListView.searchView);

Expand Down Expand Up @@ -723,29 +723,29 @@ private void updateSortMethodIcon(CategorySortingMethod method) {
CategorySortingMethod newMethod = (method != null) ? method: CategorySortingMethod.SORT_MODIFIED_DESC;
switch (newMethod){
case SORT_MODIFIED_DESC :
activityBinding.sortingMethod.setImageResource(R.drawable.modification_desc);
activityBinding.sortingMethod.setContentDescription(getString(R.string.sort_alphabetically));
activityBinding.searchBar.sortingMethod.setImageResource(R.drawable.modification_desc);
activityBinding.searchBar.sortingMethod.setContentDescription(getString(R.string.sort_alphabetically));
if (SDK_INT >= O) {
activityBinding.sortingMethod.setTooltipText(getString(R.string.sort_alphabetically));
activityBinding.searchBar.sortingMethod.setTooltipText(getString(R.string.sort_alphabetically));
}
break;
case SORT_LEXICOGRAPHICAL_ASC:
activityBinding.sortingMethod.setImageResource(R.drawable.alphabetical_asc);
activityBinding.sortingMethod.setContentDescription(getString(R.string.sort_alphabetically));
activityBinding.searchBar.sortingMethod.setImageResource(R.drawable.alphabetical_asc);
activityBinding.searchBar.sortingMethod.setContentDescription(getString(R.string.sort_alphabetically));
if (SDK_INT >= O) {
activityBinding.sortingMethod.setTooltipText(getString(R.string.sort_alphabetically));
activityBinding.searchBar.sortingMethod.setTooltipText(getString(R.string.sort_alphabetically));
}
break;
case SORT_LEXICOGRAPHICAL_DESC:
activityBinding.sortingMethod.setImageResource(R.drawable.alphabetical_desc);
activityBinding.sortingMethod.setContentDescription(getString(R.string.sort_last_modified));
activityBinding.searchBar.sortingMethod.setImageResource(R.drawable.alphabetical_desc);
activityBinding.searchBar.sortingMethod.setContentDescription(getString(R.string.sort_last_modified));
if (SDK_INT >= O) {
activityBinding.sortingMethod.setTooltipText(getString(R.string.sort_last_modified));
activityBinding.searchBar.sortingMethod.setTooltipText(getString(R.string.sort_last_modified));
}
break;
default: throw new IllegalStateException("Unknown method: " + method.name());
}
brandingUtil().platform.colorImageView(activityBinding.sortingMethod, ColorRole.ON_SURFACE);
brandingUtil().platform.colorImageView(activityBinding.searchBar.sortingMethod, ColorRole.ON_SURFACE);
}

@Override
Expand Down Expand Up @@ -883,7 +883,7 @@ public void onNoteFavoriteClick(int position, View view) {
}

private void updateToolbars(boolean enableSearch) {
activityBinding.homeToolbar.setVisibility(enableSearch ? GONE : VISIBLE);
activityBinding.searchBar.searchBarWrapper.setVisibility(enableSearch ? GONE : VISIBLE);
activityBinding.searchToolbar.setVisibility(enableSearch ? VISIBLE : GONE);
activityBinding.appBar.setStateListAnimator(AnimatorInflater.loadStateListAnimator(activityBinding.appBar.getContext(), enableSearch
? R.animator.appbar_elevation_on
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@
import androidx.recyclerview.selection.SelectionTracker;
import androidx.recyclerview.widget.RecyclerView;

import com.google.android.material.card.MaterialCardView;
import com.nextcloud.android.common.ui.theme.utils.ColorRole;

import java.util.ArrayList;
Expand Down Expand Up @@ -120,12 +121,12 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
}
case TYPE_NOTE_ONLY_TITLE -> {
ItemNotesListNoteItemGridOnlyTitleBinding binding = ItemNotesListNoteItemGridOnlyTitleBinding.inflate(inflater, parent, false);
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.card);
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
return new NoteViewGridHolderOnlyTitle(binding, noteClickListener, monospace, fontSize);
}
case TYPE_NOTE_WITH_EXCERPT, TYPE_NOTE_WITHOUT_EXCERPT -> {
ItemNotesListNoteItemGridBinding binding = ItemNotesListNoteItemGridBinding.inflate(inflater, parent, false);
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.card);
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
return new NoteViewGridHolder(binding, noteClickListener, monospace, fontSize);
}
default -> {
Expand All @@ -141,12 +142,12 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
}
case TYPE_NOTE_WITH_EXCERPT -> {
ItemNotesListNoteItemWithExcerptBinding binding = ItemNotesListNoteItemWithExcerptBinding.inflate(inflater, parent, false);
BrandingUtil.of(color, parent.getContext()).notes.themeBackgroundItemView(binding.noteSwipeable);
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
return new NoteViewHolderWithExcerpt(binding, noteClickListener);
}
case TYPE_NOTE_ONLY_TITLE, TYPE_NOTE_WITHOUT_EXCERPT -> {
ItemNotesListNoteItemWithoutExcerptBinding binding = ItemNotesListNoteItemWithoutExcerptBinding.inflate(inflater, parent, false);
BrandingUtil.of(color, parent.getContext()).notes.themeBackgroundItemView(binding.noteSwipeable);
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
return new NoteViewHolderWithoutExcerpt(binding, noteClickListener);
}
default -> {
Expand Down Expand Up @@ -175,8 +176,10 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(tracker != null && tracker.hasSelection() ? View.VISIBLE : View.GONE);
holder.itemView.setSelected(isSelected);
if (isSelected) {
((MaterialCardView) holder.itemView.findViewById(R.id.noteCard)).setStrokeWidth((int) holder.itemView.getResources().getDimension(R.dimen.card_stroke_width_selected));
((ImageView) holder.itemView.findViewById(R.id.custom_checkbox)).setImageDrawable(BrandingUtil.getInstance(holder.itemView.getContext()).platform.tintDrawable(holder.itemView.getContext(), R.drawable.ic_checkbox_marked, ColorRole.PRIMARY));
} else {
((MaterialCardView) holder.itemView.findViewById(R.id.noteCard)).setStrokeWidth((int) holder.itemView.getResources().getDimension(R.dimen.card_stroke_width));
((ImageView) holder.itemView.findViewById(R.id.custom_checkbox)).setImageResource(R.drawable.ic_checkbox_blank_outline);
}
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(isMultiSelect ? View.VISIBLE : View.GONE);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ protected void bindSearchableContent(@NonNull Context context, @NonNull TextView
}
}

public abstract void showSwipe(boolean left);
public abstract void showSwipe(float dX);

@Nullable
public abstract View getNoteSwipeable();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ public NoteViewGridHolder(@NonNull ItemNotesListNoteItemGridBinding binding, @No
}
}

public void showSwipe(boolean left) {
public void showSwipe(float dX) {
throw new UnsupportedOperationException(NoteViewGridHolder.class.getSimpleName() + " does not support swiping");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ public NoteViewGridHolderOnlyTitle(@NonNull ItemNotesListNoteItemGridOnlyTitleBi
}
}

public void showSwipe(boolean left) {
public void showSwipe(float dX) {
throw new UnsupportedOperationException(NoteViewGridHolderOnlyTitle.class.getSimpleName() + " does not support swiping");
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,11 +6,13 @@
*/
package it.niedermann.owncloud.notes.main.items.list;

import android.content.res.Resources;
import android.view.View;

import androidx.annotation.ColorInt;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.core.content.res.ResourcesCompat;

import it.niedermann.owncloud.notes.R;
import it.niedermann.owncloud.notes.databinding.ItemNotesListNoteItemWithExcerptBinding;
Expand All @@ -23,21 +25,37 @@ public class NoteViewHolderWithExcerpt extends NoteViewHolder {
@NonNull
private final ItemNotesListNoteItemWithExcerptBinding binding;

private final int defaultSwipeBackgroundColor;
private final int starSwipeBackgroundColor;
private final int deleteSwipeBackgroundColor;


public NoteViewHolderWithExcerpt(@NonNull ItemNotesListNoteItemWithExcerptBinding binding, @NonNull NoteClickListener noteClickListener) {
super(binding.getRoot(), noteClickListener);
this.binding = binding;
Resources resources = binding.getRoot().getContext().getResources();
this.defaultSwipeBackgroundColor = ResourcesCompat.getColor(resources, R.color.transparent, null);
this.starSwipeBackgroundColor = ResourcesCompat.getColor(resources, R.color.bg_warning, null);
this.deleteSwipeBackgroundColor = ResourcesCompat.getColor(resources, R.color.bg_attention, null);
}

public void showSwipe(boolean left) {
binding.noteFavoriteLeft.setVisibility(left ? View.VISIBLE : View.INVISIBLE);
binding.noteDeleteRight.setVisibility(left ? View.INVISIBLE : View.VISIBLE);
binding.noteSwipeFrame.setBackgroundResource(left ? R.color.bg_warning : R.color.bg_attention);
public void showSwipe(float dX) {
if (dX == 0.0f) {
binding.noteFavoriteLeft.setVisibility(View.INVISIBLE);
binding.noteDeleteRight.setVisibility(View.INVISIBLE);
binding.noteSwipeFrame.setCardBackgroundColor(defaultSwipeBackgroundColor);
} else {
boolean left = dX > 0;
binding.noteFavoriteLeft.setVisibility(left ? View.VISIBLE : View.INVISIBLE);
binding.noteDeleteRight.setVisibility(left ? View.INVISIBLE : View.VISIBLE);
binding.noteSwipeFrame.setCardBackgroundColor(left ? starSwipeBackgroundColor : deleteSwipeBackgroundColor);
}
}

public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @ColorInt int color, @Nullable CharSequence searchQuery) {
super.bind(isSelected, note, showCategory, color, searchQuery);
@NonNull final var context = itemView.getContext();
binding.noteSwipeable.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f);
binding.noteCard.setAlpha(DBStatus.LOCAL_DELETED.equals(note.getStatus()) ? 0.5f : 1.0f);
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), color);
bindStatus(binding.noteStatus, note.getStatus(), color);
bindFavorite(binding.noteFavorite, note.getFavorite());
Expand All @@ -49,6 +67,6 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @

@NonNull
public View getNoteSwipeable() {
return binding.noteSwipeable;
return binding.noteCard;
}
}
}
Loading
Loading