Skip to content

Commit b519fce

Browse files
style(list): M3 list item style
Signed-off-by: Andy Scherzinger <[email protected]>
1 parent 3b0e892 commit b519fce

File tree

4 files changed

+93
-56
lines changed

4 files changed

+93
-56
lines changed

app/src/main/java/it/niedermann/owncloud/notes/main/MainActivity.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,7 @@ private void setupNotesList() {
525525
listView.setLayoutManager(gridLayoutManager);
526526
listView.addItemDecoration(new GridItemDecoration(adapter, spanCount,
527527
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
528-
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
528+
getResources().getDimensionPixelSize(R.dimen.spacer_2x),
529529
getResources().getDimensionPixelSize(R.dimen.spacer_3x),
530530
getResources().getDimensionPixelSize(R.dimen.spacer_1x),
531531
getResources().getDimensionPixelSize(R.dimen.spacer_activity_sides) + getResources().getDimensionPixelSize(R.dimen.spacer_1x)

app/src/main/java/it/niedermann/owncloud/notes/main/items/ItemAdapter.java

Lines changed: 52 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,6 @@
5252

5353
public class ItemAdapter extends RecyclerView.Adapter<RecyclerView.ViewHolder> implements Branded {
5454

55-
5655
public static final int TYPE_SECTION = 0;
5756
public static final int TYPE_NOTE_WITH_EXCERPT = 1;
5857
public static final int TYPE_NOTE_WITHOUT_EXCERPT = 2;
@@ -85,8 +84,8 @@ public <T extends Context & NoteClickListener> ItemAdapter(@NonNull T context, b
8584
setHasStableIds(true);
8685
}
8786

88-
89-
// FIXME this causes {@link it.niedermann.owncloud.notes.noteslist.items.list.NotesListViewItemTouchHelper} to not call clearView anymore → After marking a note as favorite, it stays yellow.
87+
// FIXME this causes {@link it.niedermann.owncloud.notes.noteslist.items.list.NotesListViewItemTouchHelper} to
88+
// not call clearView anymore → After marking a note as favorite, it stays yellow.
9089
@Override
9190
public long getItemId(int position) {
9291
return getItemViewType(position) == TYPE_SECTION
@@ -118,13 +117,31 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
118117
return new SectionViewHolder(binding);
119118
}
120119
case TYPE_NOTE_ONLY_TITLE -> {
121-
ItemNotesListNoteItemGridOnlyTitleBinding binding = ItemNotesListNoteItemGridOnlyTitleBinding.inflate(inflater, parent, false);
120+
ItemNotesListNoteItemGridOnlyTitleBinding binding = ItemNotesListNoteItemGridOnlyTitleBinding
121+
.inflate(inflater, parent, false);
122122
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
123+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
124+
binding.noteTitle, ColorRole.ON_SURFACE
125+
);
126+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
127+
binding.noteModified, ColorRole.ON_SURFACE_VARIANT
128+
);
123129
return new NoteViewGridHolderOnlyTitle(binding, noteClickListener, monospace, fontSize);
124130
}
125131
case TYPE_NOTE_WITH_EXCERPT, TYPE_NOTE_WITHOUT_EXCERPT -> {
126-
ItemNotesListNoteItemGridBinding binding = ItemNotesListNoteItemGridBinding.inflate(inflater, parent, false);
132+
ItemNotesListNoteItemGridBinding binding = ItemNotesListNoteItemGridBinding.inflate(
133+
inflater, parent, false
134+
);
127135
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
136+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
137+
binding.noteTitle, ColorRole.ON_SURFACE
138+
);
139+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
140+
binding.noteExcerpt, ColorRole.ON_SURFACE_VARIANT
141+
);
142+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
143+
binding.noteModified, ColorRole.ON_SURFACE_VARIANT
144+
);
128145
return new NoteViewGridHolder(binding, noteClickListener, monospace, fontSize);
129146
}
130147
default -> {
@@ -139,8 +156,18 @@ public RecyclerView.ViewHolder onCreateViewHolder(@NonNull ViewGroup parent, int
139156
return new SectionViewHolder(binding);
140157
}
141158
case TYPE_NOTE_WITH_EXCERPT, TYPE_NOTE_ONLY_TITLE, TYPE_NOTE_WITHOUT_EXCERPT -> {
142-
ItemNotesListNoteItemWithExcerptBinding binding = ItemNotesListNoteItemWithExcerptBinding.inflate(inflater, parent, false);
159+
ItemNotesListNoteItemWithExcerptBinding binding = ItemNotesListNoteItemWithExcerptBinding
160+
.inflate(inflater, parent, false);
143161
BrandingUtil.of(color, parent.getContext()).notes.themeCard(binding.noteCard);
162+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
163+
binding.noteTitle, ColorRole.ON_SURFACE
164+
);
165+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
166+
binding.noteExcerpt, ColorRole.ON_SURFACE_VARIANT
167+
);
168+
BrandingUtil.of(color, parent.getContext()).platform.colorTextView(
169+
binding.noteModified, ColorRole.ON_SURFACE_VARIANT
170+
);
144171
return new NoteViewListHolder(binding, noteClickListener);
145172
}
146173
default -> {
@@ -166,18 +193,30 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
166193
case TYPE_SECTION ->
167194
((SectionViewHolder) holder).bind((SectionItem) itemList.get(position));
168195
case TYPE_NOTE_WITH_EXCERPT, TYPE_NOTE_WITHOUT_EXCERPT, TYPE_NOTE_ONLY_TITLE -> {
169-
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(tracker != null && tracker.hasSelection() ? View.VISIBLE : View.GONE);
196+
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(tracker != null &&
197+
tracker.hasSelection() ? View.VISIBLE : View.GONE);
170198
holder.itemView.setSelected(isSelected);
171199
if (isSelected) {
172200
((MaterialCardView) holder.itemView.findViewById(R.id.noteCard)).setStrokeWidth((int) holder.itemView.getResources().getDimension(R.dimen.card_stroke_width_selected));
173-
((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));
201+
((ImageView) holder.itemView.findViewById(R.id.custom_checkbox)).setImageDrawable(
202+
BrandingUtil.getInstance(holder.itemView.getContext()).platform.tintDrawable(
203+
holder.itemView.getContext(), R.drawable.ic_checkbox_marked, ColorRole.PRIMARY)
204+
);
174205
} else {
175206
((MaterialCardView) holder.itemView.findViewById(R.id.noteCard)).setStrokeWidth((int) holder.itemView.getResources().getDimension(R.dimen.card_stroke_width));
176-
((ImageView) holder.itemView.findViewById(R.id.custom_checkbox)).setImageResource(R.drawable.ic_checkbox_blank_outline);
207+
((ImageView) holder.itemView.findViewById(R.id.custom_checkbox)).setImageResource(
208+
R.drawable.ic_checkbox_blank_outline
209+
);
177210
}
178-
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(isMultiSelect ? View.VISIBLE : View.GONE);
179-
holder.itemView.findViewById(R.id.noteFavorite).setVisibility(isMultiSelect ? View.GONE : View.VISIBLE);
180-
((NoteViewHolder) holder).bind(isSelected, (Note) itemList.get(position), showCategory, color, searchQuery);
211+
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(
212+
isMultiSelect ? View.VISIBLE : View.GONE
213+
);
214+
holder.itemView.findViewById(R.id.noteFavorite).setVisibility(
215+
isMultiSelect ? View.GONE : View.VISIBLE
216+
);
217+
((NoteViewHolder) holder).bind(
218+
isSelected, (Note) itemList.get(position), showCategory, color, searchQuery
219+
);
181220
}
182221
}
183222
}
@@ -270,4 +309,4 @@ public Integer getSwipedPosition() {
270309
public void setSwipedPosition(@Nullable Integer swipedPosition) {
271310
this.swipedPosition = swipedPosition;
272311
}
273-
}
312+
}

app/src/main/res/layout/item_notes_list_note_item_grid.xml

Lines changed: 15 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
~ Nextcloud Notes - Android Client
44
~
5-
~ SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
5+
~ SPDX-FileCopyrightText: 2020-2025 Nextcloud GmbH and Nextcloud contributors
66
~ SPDX-License-Identifier: GPL-3.0-or-later
77
-->
88
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
@@ -18,34 +18,32 @@
1818
android:id="@+id/wrapper"
1919
android:layout_width="match_parent"
2020
android:layout_height="match_parent"
21-
android:orientation="vertical"
22-
android:paddingBottom="@dimen/spacer_1x">
21+
android:orientation="vertical">
2322

2423
<TextView
2524
android:id="@+id/noteTitle"
2625
android:layout_width="match_parent"
2726
android:layout_height="wrap_content"
2827
android:layout_marginHorizontal="@dimen/spacer_2x"
29-
android:layout_marginTop="@dimen/spacer_2x"
28+
android:layout_marginTop="@dimen/spacer_list_card"
3029
android:layout_marginBottom="@dimen/spacer_1x"
3130
android:hyphenationFrequency="full"
3231
android:textAppearance="?attr/textAppearanceHeadline5"
3332
android:textColor="@color/fg_default"
3433
tools:maxLength="50"
3534
tools:text="@tools:sample/lorem/random" />
3635

37-
3836
<TextView
3937
android:id="@+id/noteExcerpt"
4038
android:layout_width="match_parent"
4139
android:layout_height="wrap_content"
4240
android:layout_marginHorizontal="@dimen/spacer_2x"
41+
android:layout_marginBottom="@dimen/spacer_1x"
4342
android:textAppearance="?android:attr/textAppearanceMedium"
4443
android:textColor="@color/fg_default"
4544
tools:maxLength="200"
4645
tools:text="@tools:sample/lorem/random" />
4746

48-
4947
<LinearLayout
5048
android:layout_width="match_parent"
5149
android:layout_height="wrap_content"
@@ -61,7 +59,8 @@
6159
android:layout_height="wrap_content"
6260
android:background="?attr/selectableItemBackgroundBorderless"
6361
android:contentDescription="@string/menu_favorite"
64-
android:padding="@dimen/spacer_2x"
62+
android:paddingStart="@dimen/spacer_2x"
63+
android:paddingEnd="@dimen/spacer_list_card"
6564
tools:src="@drawable/ic_star_yellow_24dp" />
6665

6766
<ImageView
@@ -72,24 +71,27 @@
7271
android:clickable="false"
7372
android:contentDescription="@null"
7473
android:focusable="false"
75-
android:padding="@dimen/spacer_2x"
74+
android:paddingStart="@dimen/spacer_2x"
75+
android:paddingEnd="@dimen/spacer_list_card"
7676
android:src="@drawable/ic_checkbox_blank_outline" />
7777

7878
<androidx.appcompat.widget.AppCompatImageView
7979
android:id="@+id/noteStatus"
8080
android:layout_width="wrap_content"
8181
android:layout_height="wrap_content"
8282
android:layout_gravity="center_vertical|end"
83-
android:layout_marginTop="12dp"
84-
android:layout_marginEnd="4dp"
83+
android:layout_marginTop="@dimen/spacer_1x"
84+
android:layout_marginEnd="2dp"
8585
android:baseline="14dp"
8686
app:srcCompat="@drawable/ic_sync_blue_18dp" />
8787
</FrameLayout>
8888

8989
<LinearLayout
9090
android:layout_width="match_parent"
9191
android:layout_height="wrap_content"
92-
android:layout_marginTop="@dimen/spacer_2x"
92+
android:layout_marginBottom="@dimen/spacer_2x"
93+
android:gravity="center_vertical"
94+
android:minHeight="@dimen/iconized_single_line_item_icon_size"
9395
android:orientation="vertical">
9496

9597
<com.google.android.material.chip.Chip
@@ -120,11 +122,10 @@
120122
android:layout_width="wrap_content"
121123
android:layout_height="wrap_content"
122124
android:layout_gravity="end"
123-
android:paddingStart="@dimen/spacer_1hx"
124-
android:paddingEnd="@dimen/spacer_2x"
125+
android:layout_marginEnd="@dimen/spacer_2x"
125126
tools:text="27.11." />
126127

127128
</LinearLayout>
128129
</LinearLayout>
129130
</LinearLayout>
130-
</com.google.android.material.card.MaterialCardView>
131+
</com.google.android.material.card.MaterialCardView>

app/src/main/res/layout/item_notes_list_note_item_grid_only_title.xml

Lines changed: 25 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
<!--
33
~ Nextcloud Notes - Android Client
44
~
5-
~ SPDX-FileCopyrightText: 2020-2024 Nextcloud GmbH and Nextcloud contributors
5+
~ SPDX-FileCopyrightText: 2020-2025 Nextcloud GmbH and Nextcloud contributors
66
~ SPDX-License-Identifier: GPL-3.0-or-later
77
-->
88
<com.google.android.material.card.MaterialCardView xmlns:android="http://schemas.android.com/apk/res/android"
@@ -15,30 +15,23 @@
1515
app:cardCornerRadius="@dimen/card_radius">
1616

1717
<LinearLayout
18+
android:id="@+id/wrapper"
1819
android:layout_width="match_parent"
1920
android:layout_height="wrap_content"
20-
android:layout_marginBottom="@dimen/spacer_2x"
2121
android:orientation="vertical">
2222

23-
<LinearLayout
24-
android:id="@+id/wrapper"
23+
<TextView
24+
android:id="@+id/noteTitle"
2525
android:layout_width="match_parent"
26-
android:layout_height="match_parent"
27-
android:orientation="vertical">
28-
29-
<TextView
30-
android:id="@+id/noteTitle"
31-
android:layout_width="match_parent"
32-
android:layout_height="wrap_content"
33-
android:layout_marginHorizontal="@dimen/spacer_2x"
34-
android:layout_marginTop="@dimen/spacer_2x"
35-
android:hyphenationFrequency="full"
36-
android:textAppearance="?attr/textAppearanceHeadline5"
37-
android:textColor="@color/fg_default"
38-
tools:maxLength="50"
39-
tools:text="@tools:sample/lorem/random" />
40-
41-
</LinearLayout>
26+
android:layout_height="wrap_content"
27+
android:layout_marginHorizontal="@dimen/spacer_2x"
28+
android:layout_marginTop="@dimen/spacer_list_card"
29+
android:layout_marginBottom="@dimen/spacer_1x"
30+
android:hyphenationFrequency="full"
31+
android:textAppearance="?attr/textAppearanceHeadline5"
32+
android:textColor="@color/fg_default"
33+
tools:maxLength="50"
34+
tools:text="@tools:sample/lorem/random" />
4235

4336
<LinearLayout
4437
android:layout_width="match_parent"
@@ -55,34 +48,39 @@
5548
android:layout_height="wrap_content"
5649
android:background="?attr/selectableItemBackgroundBorderless"
5750
android:contentDescription="@string/menu_favorite"
58-
android:padding="@dimen/spacer_2x"
51+
android:paddingStart="@dimen/spacer_2x"
52+
android:paddingEnd="@dimen/spacer_list_card"
5953
tools:src="@drawable/ic_star_yellow_24dp" />
6054

6155
<ImageView
6256
android:id="@+id/custom_checkbox"
6357
android:layout_width="wrap_content"
64-
android:layout_height="match_parent"
58+
android:layout_height="wrap_content"
59+
android:layout_gravity="top"
6560
android:clickable="false"
6661
android:contentDescription="@null"
6762
android:focusable="false"
68-
android:padding="@dimen/spacer_2x"
63+
android:paddingStart="@dimen/spacer_2x"
64+
android:paddingEnd="@dimen/spacer_list_card"
6965
android:src="@drawable/ic_checkbox_blank_outline" />
7066

7167
<androidx.appcompat.widget.AppCompatImageView
7268
android:id="@+id/noteStatus"
7369
android:layout_width="wrap_content"
7470
android:layout_height="wrap_content"
7571
android:layout_gravity="center_vertical|end"
76-
android:layout_marginTop="12dp"
77-
android:layout_marginEnd="4dp"
72+
android:layout_marginTop="@dimen/spacer_1x"
73+
android:layout_marginEnd="2dp"
7874
android:baseline="14dp"
7975
app:srcCompat="@drawable/ic_sync_blue_18dp" />
8076
</FrameLayout>
8177

8278
<LinearLayout
8379
android:layout_width="match_parent"
8480
android:layout_height="wrap_content"
85-
android:layout_marginTop="@dimen/spacer_2x"
81+
android:layout_marginBottom="@dimen/spacer_2x"
82+
android:gravity="center_vertical"
83+
android:minHeight="@dimen/iconized_single_line_item_icon_size"
8684
android:orientation="vertical">
8785

8886
<com.google.android.material.chip.Chip
@@ -113,8 +111,7 @@
113111
android:layout_width="wrap_content"
114112
android:layout_height="wrap_content"
115113
android:layout_gravity="end"
116-
android:paddingStart="@dimen/spacer_1hx"
117-
android:paddingEnd="@dimen/spacer_2x"
114+
android:layout_marginEnd="@dimen/spacer_2x"
118115
tools:text="27.11." />
119116

120117
</LinearLayout>

0 commit comments

Comments
 (0)