Skip to content

Commit 433091e

Browse files
feat: Display the date of last edit
Resolves #2835 Signed-off-by: Andy Scherzinger <[email protected]>
1 parent 39e44a3 commit 433091e

10 files changed

+203
-83
lines changed

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

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212

1313
import android.content.Context;
1414
import android.text.TextUtils;
15+
import android.text.format.DateFormat;
1516
import android.view.View;
1617
import android.widget.ImageView;
1718
import android.widget.TextView;
@@ -27,6 +28,10 @@
2728
import com.google.android.material.chip.Chip;
2829
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
2930

31+
import java.text.SimpleDateFormat;
32+
import java.util.Calendar;
33+
import java.util.Locale;
34+
3035
import it.niedermann.owncloud.notes.R;
3136
import it.niedermann.owncloud.notes.branding.BrandingUtil;
3237
import it.niedermann.owncloud.notes.persistence.entity.Note;
@@ -37,10 +42,16 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder {
3742
@NonNull
3843
private final NoteClickListener noteClickListener;
3944

45+
private final SimpleDateFormat sdf;
46+
4047
public NoteViewHolder(@NonNull View v, @NonNull NoteClickListener noteClickListener) {
4148
super(v);
4249
this.noteClickListener = noteClickListener;
4350
this.setIsRecyclable(false);
51+
52+
Locale locale = v.getResources().getConfiguration().locale;
53+
String pattern = DateFormat.getBestDateTimePattern(locale, "dd.MM.");
54+
this.sdf = new SimpleDateFormat(pattern, locale);
4455
}
4556

4657
@CallSuper
@@ -50,6 +61,15 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
5061
itemView.setOnClickListener((view) -> noteClickListener.onNoteClick(getLayoutPosition(), view));
5162
}
5263

64+
protected void bindModified(@NonNull TextView noteModified, @Nullable Calendar modified) {
65+
if (modified != null && modified.getTimeInMillis() > 0) {
66+
noteModified.setText(sdf.format(modified.getTime()));
67+
noteModified.setVisibility(VISIBLE);
68+
} else {
69+
noteModified.setVisibility(INVISIBLE);
70+
}
71+
}
72+
5373
protected void bindStatus(AppCompatImageView noteStatus, DBStatus status, int color) {
5474
noteStatus.setVisibility(DBStatus.VOID.equals(status) ? INVISIBLE : VISIBLE);
5575

app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolder.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,7 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
5252
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), color);
5353
bindStatus(binding.noteStatus, note.getStatus(), color);
5454
bindFavorite(binding.noteFavorite, note.getFavorite());
55+
bindModified(binding.noteModified, note.getModified());
5556
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
5657
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt().replace(EXCERPT_LINE_SEPARATOR, "\n"), color);
5758
binding.noteExcerpt.setVisibility(TextUtils.isEmpty(note.getExcerpt()) ? GONE : VISIBLE);

app/src/main/java/it/niedermann/owncloud/notes/main/items/grid/NoteViewGridHolderOnlyTitle.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,8 +41,10 @@ public void showSwipe(boolean left) {
4141
public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, int color, @Nullable CharSequence searchQuery) {
4242
super.bind(isSelected, note, showCategory, color, searchQuery);
4343
@NonNull final Context context = itemView.getContext();
44+
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), color);
4445
bindStatus(binding.noteStatus, note.getStatus(), color);
4546
bindFavorite(binding.noteFavorite, note.getFavorite());
47+
bindModified(binding.noteModified, note.getModified());
4648
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
4749
}
4850

app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithExcerpt.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
4141
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), color);
4242
bindStatus(binding.noteStatus, note.getStatus(), color);
4343
bindFavorite(binding.noteFavorite, note.getFavorite());
44+
bindModified(binding.noteModified, note.getModified());
4445

4546
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
4647
bindSearchableContent(context, binding.noteExcerpt, searchQuery, note.getExcerpt(), color);

app/src/main/java/it/niedermann/owncloud/notes/main/items/list/NoteViewHolderWithoutExcerpt.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, i
4141
bindCategory(context, binding.noteCategory, showCategory, note.getCategory(), color);
4242
bindStatus(binding.noteStatus, note.getStatus(), color);
4343
bindFavorite(binding.noteFavorite, note.getFavorite());
44+
bindModified(binding.noteModified, note.getModified());
4445
bindSearchableContent(context, binding.noteTitle, searchQuery, note.getTitle(), color);
4546
}
4647

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

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,6 @@
4949
<LinearLayout
5050
android:layout_width="match_parent"
5151
android:layout_height="wrap_content"
52-
android:baselineAligned="false"
53-
android:gravity="center_vertical"
5452
android:orientation="horizontal">
5553

5654
<FrameLayout
@@ -77,10 +75,11 @@
7775
app:srcCompat="@drawable/ic_sync_blue_18dp" />
7876
</FrameLayout>
7977

80-
<FrameLayout
81-
android:layout_width="0dp"
78+
<LinearLayout
79+
android:layout_width="match_parent"
8280
android:layout_height="wrap_content"
83-
android:layout_weight="1">
81+
android:layout_marginTop="@dimen/spacer_2x"
82+
android:orientation="vertical">
8483

8584
<com.google.android.material.chip.Chip
8685
android:id="@+id/noteCategory"
@@ -104,7 +103,17 @@
104103
app:textStartPadding="0dp"
105104
tools:maxLength="50"
106105
tools:text="@tools:sample/lorem/random" />
107-
</FrameLayout>
106+
107+
<TextView
108+
android:id="@+id/noteModified"
109+
android:layout_width="wrap_content"
110+
android:layout_height="wrap_content"
111+
android:layout_gravity="end"
112+
android:paddingStart="@dimen/spacer_1hx"
113+
android:paddingEnd="@dimen/spacer_2x"
114+
tools:text="27.11." />
115+
116+
</LinearLayout>
108117

109118
<ImageView
110119
android:id="@+id/custom_checkbox"

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

Lines changed: 99 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,112 @@
1515
app:cardCornerRadius="@dimen/card_radius">
1616

1717
<LinearLayout
18-
android:id="@+id/wrapper"
1918
android:layout_width="match_parent"
20-
android:layout_height="match_parent"
21-
android:orientation="horizontal"
22-
android:paddingBottom="@dimen/spacer_1x">
19+
android:layout_height="wrap_content"
20+
android:layout_marginBottom="@dimen/spacer_2x"
21+
android:orientation="vertical">
2322

24-
<FrameLayout
25-
android:layout_width="wrap_content"
26-
android:layout_height="wrap_content"
27-
android:layout_marginTop="@dimen/spacer_1qx">
23+
<LinearLayout
24+
android:id="@+id/wrapper"
25+
android:layout_width="match_parent"
26+
android:layout_height="match_parent"
27+
android:orientation="vertical">
2828

29-
<ImageView
30-
android:id="@+id/noteFavorite"
31-
android:layout_width="wrap_content"
29+
<TextView
30+
android:id="@+id/noteTitle"
31+
android:layout_width="match_parent"
3232
android:layout_height="wrap_content"
33-
android:background="?attr/selectableItemBackgroundBorderless"
34-
android:contentDescription="@string/menu_favorite"
35-
android:padding="@dimen/spacer_2x"
36-
tools:src="@drawable/ic_star_yellow_24dp" />
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>
3742

38-
<androidx.appcompat.widget.AppCompatImageView
39-
android:id="@+id/noteStatus"
43+
<LinearLayout
44+
android:layout_width="match_parent"
45+
android:layout_height="wrap_content"
46+
android:orientation="horizontal">
47+
48+
<FrameLayout
4049
android:layout_width="wrap_content"
50+
android:layout_height="wrap_content">
51+
52+
<ImageView
53+
android:id="@+id/noteFavorite"
54+
android:layout_width="wrap_content"
55+
android:layout_height="wrap_content"
56+
android:background="?attr/selectableItemBackgroundBorderless"
57+
android:contentDescription="@string/menu_favorite"
58+
android:padding="@dimen/spacer_2x"
59+
tools:src="@drawable/ic_star_yellow_24dp" />
60+
61+
<androidx.appcompat.widget.AppCompatImageView
62+
android:id="@+id/noteStatus"
63+
android:layout_width="wrap_content"
64+
android:layout_height="wrap_content"
65+
android:layout_gravity="center_vertical|end"
66+
android:layout_marginTop="12dp"
67+
android:layout_marginEnd="4dp"
68+
android:baseline="14dp"
69+
app:srcCompat="@drawable/ic_sync_blue_18dp" />
70+
</FrameLayout>
71+
72+
<LinearLayout
73+
android:layout_width="match_parent"
4174
android:layout_height="wrap_content"
42-
android:layout_gravity="center_vertical|end"
43-
android:layout_marginTop="12dp"
44-
android:layout_marginEnd="4dp"
45-
android:baseline="14dp"
46-
app:srcCompat="@drawable/ic_sync_blue_18dp" />
47-
</FrameLayout>
75+
android:layout_marginTop="@dimen/spacer_2x"
76+
android:orientation="vertical">
4877

49-
<TextView
50-
android:id="@+id/noteTitle"
51-
android:layout_width="0dp"
52-
android:layout_height="wrap_content"
53-
android:layout_marginStart="0dp"
54-
android:layout_marginTop="@dimen/spacer_2x"
55-
android:layout_marginEnd="@dimen/spacer_2x"
56-
android:layout_marginBottom="@dimen/spacer_1x"
57-
android:layout_weight="1"
58-
android:hyphenationFrequency="full"
59-
android:textAppearance="?attr/textAppearanceHeadline5"
60-
android:textColor="@color/fg_default"
61-
tools:maxLength="50"
62-
tools:text="@tools:sample/lorem/random" />
78+
<com.google.android.material.chip.Chip
79+
android:id="@+id/noteCategory"
80+
android:layout_width="wrap_content"
81+
android:layout_height="wrap_content"
82+
android:layout_gravity="end"
83+
android:layout_marginStart="0dp"
84+
android:layout_marginEnd="@dimen/spacer_2x"
85+
android:ellipsize="middle"
86+
android:padding="@dimen/spacer_1hx"
87+
android:textColor="?android:textColorPrimary"
88+
android:textSize="@dimen/secondary_font_size"
89+
app:chipBackgroundColor="@color/defaultBrand"
90+
app:chipEndPadding="@dimen/spacer_1x"
91+
app:chipMinHeight="0dp"
92+
app:chipStartPadding="@dimen/spacer_1x"
93+
app:chipStrokeColor="@android:color/transparent"
94+
app:chipStrokeWidth="1dp"
95+
app:ensureMinTouchTargetSize="false"
96+
app:textEndPadding="0dp"
97+
app:textStartPadding="0dp"
98+
tools:maxLength="50"
99+
tools:text="@tools:sample/lorem/random" />
63100

64-
<ImageView
65-
android:id="@+id/custom_checkbox"
66-
android:layout_width="wrap_content"
67-
android:layout_height="match_parent"
68-
android:layout_gravity="top"
69-
android:clickable="false"
70-
android:contentDescription="@null"
71-
android:focusable="false"
72-
android:paddingStart="@dimen/spacer_1x"
73-
android:paddingEnd="@dimen/spacer_1x"
74-
android:src="@drawable/ic_checkbox_blank_outline" />
101+
<TextView
102+
android:id="@+id/noteModified"
103+
android:layout_width="wrap_content"
104+
android:layout_height="wrap_content"
105+
android:layout_gravity="end"
106+
android:paddingStart="@dimen/spacer_1hx"
107+
android:paddingEnd="@dimen/spacer_2x"
108+
tools:text="27.11." />
109+
110+
</LinearLayout>
111+
112+
<ImageView
113+
android:id="@+id/custom_checkbox"
114+
android:layout_width="wrap_content"
115+
android:layout_height="match_parent"
116+
android:layout_gravity="top"
117+
android:clickable="false"
118+
android:contentDescription="@null"
119+
android:focusable="false"
120+
android:paddingStart="@dimen/spacer_1x"
121+
android:paddingEnd="@dimen/spacer_1x"
122+
android:src="@drawable/ic_checkbox_blank_outline" />
123+
</LinearLayout>
75124
</LinearLayout>
76-
</com.google.android.material.card.MaterialCardView>
125+
126+
</com.google.android.material.card.MaterialCardView>

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

Lines changed: 36 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -9,11 +9,11 @@
99
xmlns:app="http://schemas.android.com/apk/res-auto"
1010
xmlns:tools="http://schemas.android.com/tools"
1111
android:id="@+id/noteSwipeFrame"
12-
android:clickable="true"
13-
android:focusable="true"
1412
android:layout_width="match_parent"
1513
android:layout_height="wrap_content"
16-
android:background="@color/bg_attention">
14+
android:background="@color/bg_attention"
15+
android:clickable="true"
16+
android:focusable="true">
1717

1818
<ImageView
1919
android:id="@+id/noteFavoriteLeft"
@@ -28,8 +28,9 @@
2828
android:id="@+id/noteDeleteRight"
2929
android:layout_width="wrap_content"
3030
android:layout_height="wrap_content"
31-
android:layout_gravity="end|center_vertical"
32-
android:layout_marginEnd="@dimen/button_padding"
31+
android:layout_gravity="end|top"
32+
android:layout_marginEnd="@dimen/spacer_1x"
33+
android:layout_marginTop="@dimen/spacer_1x"
3334
android:contentDescription="@string/menu_delete"
3435
app:srcCompat="@drawable/ic_delete_white_24dp" />
3536

@@ -72,8 +73,8 @@
7273
android:layout_height="wrap_content"
7374
android:layout_weight="1"
7475
android:orientation="vertical"
75-
android:paddingStart="0dp"
7676
android:paddingVertical="@dimen/spacer_2x"
77+
android:paddingStart="0dp"
7778
android:paddingEnd="@dimen/spacer_2x">
7879

7980
<LinearLayout
@@ -115,8 +116,8 @@
115116
android:layout_marginStart="@dimen/spacer_1x"
116117
android:background="@drawable/border"
117118
android:maxLines="1"
118-
android:paddingVertical="1dp"
119119
android:paddingHorizontal="@dimen/spacer_1x"
120+
android:paddingVertical="1dp"
120121
android:singleLine="true"
121122
android:textColor="?android:textColorPrimary"
122123
android:textSize="@dimen/secondary_font_size"
@@ -125,17 +126,35 @@
125126
</LinearLayout>
126127
</LinearLayout>
127128

128-
<ImageView
129-
android:id="@+id/custom_checkbox"
129+
<LinearLayout
130130
android:layout_width="wrap_content"
131131
android:layout_height="match_parent"
132-
android:layout_gravity="top"
133-
android:clickable="false"
134-
android:contentDescription="@null"
135-
android:focusable="false"
136-
android:paddingStart="@dimen/spacer_1x"
137-
android:paddingEnd="@dimen/spacer_1x"
138-
android:src="@drawable/ic_checkbox_blank_outline" />
139-
</LinearLayout>
132+
android:gravity="bottom"
133+
android:orientation="vertical">
140134

135+
<ImageView
136+
android:id="@+id/custom_checkbox"
137+
android:layout_width="wrap_content"
138+
android:layout_height="wrap_content"
139+
android:layout_gravity="end"
140+
android:clickable="false"
141+
android:contentDescription="@null"
142+
android:focusable="false"
143+
android:paddingStart="@dimen/spacer_1x"
144+
android:paddingEnd="@dimen/spacer_1x"
145+
android:src="@drawable/ic_checkbox_blank_outline" />
146+
147+
<TextView
148+
android:id="@+id/noteModified"
149+
android:layout_width="wrap_content"
150+
android:layout_height="wrap_content"
151+
android:layout_gravity="end"
152+
android:paddingStart="@dimen/zero"
153+
android:paddingTop="@dimen/spacer_1x"
154+
android:paddingEnd="@dimen/spacer_1x"
155+
android:paddingBottom="@dimen/spacer_2x"
156+
tools:text="27.11." />
157+
158+
</LinearLayout>
159+
</LinearLayout>
141160
</FrameLayout>

0 commit comments

Comments
 (0)