Skip to content

Commit 90e5862

Browse files
Merge pull request #2838 from nextcloud/feat/2835/displayLastEdit
Display the date of last edit
2 parents 5eacc16 + a2d802f commit 90e5862

15 files changed

+866
-131
lines changed

app/build.gradle

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -118,8 +118,10 @@ dependencies {
118118
exclude group: 'org.ogce', module: 'xpp3'
119119
}
120120

121+
implementation("com.github.nextcloud.android-common:ui:$nextcloudAndroidCommonLib")
122+
implementation("com.github.nextcloud.android-common:core:$nextcloudAndroidCommonLib")
123+
121124
// Nextcloud SSO
122-
implementation 'com.github.nextcloud.android-common:ui:0.28.0'
123125
implementation("com.github.nextcloud:Android-SingleSignOn:$singleSignOnVersion") {
124126
version {
125127
strictly(singleSignOnVersion)
@@ -173,6 +175,14 @@ dependencies {
173175
testImplementation 'org.robolectric:robolectric:4.16'
174176
}
175177

178+
configurations.configureEach {
179+
resolutionStrategy.eachDependency { details ->
180+
if (details.requested.group == "com.github.nextcloud.android-common") {
181+
details.useVersion(nextcloudAndroidCommonLib)
182+
}
183+
}
184+
}
185+
176186
// Run the compiler as a separate process
177187
tasks.withType(JavaCompile).configureEach {
178188
options.fork = true

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -181,6 +181,7 @@ public void onBindViewHolder(@NonNull final RecyclerView.ViewHolder holder, int
181181
((ImageView) holder.itemView.findViewById(R.id.custom_checkbox)).setImageResource(R.drawable.ic_checkbox_blank_outline);
182182
}
183183
holder.itemView.findViewById(R.id.custom_checkbox).setVisibility(isMultiSelect ? View.VISIBLE : View.GONE);
184+
holder.itemView.findViewById(R.id.noteFavorite).setVisibility(isMultiSelect ? View.GONE : View.VISIBLE);
184185
((NoteViewHolder) holder).bind(isSelected, (Note) itemList.get(position), showCategory, color, searchQuery);
185186
}
186187
}

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

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,8 +25,11 @@
2525
import androidx.recyclerview.widget.RecyclerView;
2626

2727
import com.google.android.material.chip.Chip;
28+
import com.nextcloud.android.common.core.utils.DateFormatter;
2829
import com.nextcloud.android.common.ui.theme.utils.ColorRole;
2930

31+
import java.util.Calendar;
32+
3033
import it.niedermann.owncloud.notes.R;
3134
import it.niedermann.owncloud.notes.branding.BrandingUtil;
3235
import it.niedermann.owncloud.notes.persistence.entity.Note;
@@ -37,10 +40,14 @@ public abstract class NoteViewHolder extends RecyclerView.ViewHolder {
3740
@NonNull
3841
private final NoteClickListener noteClickListener;
3942

43+
@NonNull
44+
private final DateFormatter dateFormatter;
45+
4046
public NoteViewHolder(@NonNull View v, @NonNull NoteClickListener noteClickListener) {
4147
super(v);
4248
this.noteClickListener = noteClickListener;
4349
this.setIsRecyclable(false);
50+
this.dateFormatter = new DateFormatter(v.getContext());
4451
}
4552

4653
@CallSuper
@@ -50,6 +57,15 @@ public void bind(boolean isSelected, @NonNull Note note, boolean showCategory, @
5057
itemView.setOnClickListener((view) -> noteClickListener.onNoteClick(getLayoutPosition(), view));
5158
}
5259

60+
protected void bindModified(@NonNull TextView noteModified, @Nullable Calendar modified) {
61+
if (modified != null && modified.getTimeInMillis() > 0) {
62+
noteModified.setText(dateFormatter.getConditionallyRelativeFormattedTimeSpan(modified));
63+
noteModified.setVisibility(VISIBLE);
64+
} else {
65+
noteModified.setVisibility(INVISIBLE);
66+
}
67+
}
68+
5369
protected void bindStatus(AppCompatImageView noteStatus, DBStatus status, int color) {
5470
noteStatus.setVisibility(DBStatus.VOID.equals(status) ? INVISIBLE : VISIBLE);
5571

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: 25 additions & 17 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
@@ -66,6 +64,17 @@
6664
android:padding="@dimen/spacer_2x"
6765
tools:src="@drawable/ic_star_yellow_24dp" />
6866

67+
<ImageView
68+
android:id="@+id/custom_checkbox"
69+
android:layout_width="wrap_content"
70+
android:layout_height="match_parent"
71+
android:layout_gravity="top"
72+
android:clickable="false"
73+
android:contentDescription="@null"
74+
android:focusable="false"
75+
android:padding="@dimen/spacer_2x"
76+
android:src="@drawable/ic_checkbox_blank_outline" />
77+
6978
<androidx.appcompat.widget.AppCompatImageView
7079
android:id="@+id/noteStatus"
7180
android:layout_width="wrap_content"
@@ -77,10 +86,11 @@
7786
app:srcCompat="@drawable/ic_sync_blue_18dp" />
7887
</FrameLayout>
7988

80-
<FrameLayout
81-
android:layout_width="0dp"
89+
<LinearLayout
90+
android:layout_width="match_parent"
8291
android:layout_height="wrap_content"
83-
android:layout_weight="1">
92+
android:layout_marginTop="@dimen/spacer_2x"
93+
android:orientation="vertical">
8494

8595
<com.google.android.material.chip.Chip
8696
android:id="@+id/noteCategory"
@@ -104,19 +114,17 @@
104114
app:textStartPadding="0dp"
105115
tools:maxLength="50"
106116
tools:text="@tools:sample/lorem/random" />
107-
</FrameLayout>
108117

109-
<ImageView
110-
android:id="@+id/custom_checkbox"
111-
android:layout_width="wrap_content"
112-
android:layout_height="match_parent"
113-
android:layout_gravity="top"
114-
android:clickable="false"
115-
android:contentDescription="@null"
116-
android:focusable="false"
117-
android:paddingStart="@dimen/spacer_1x"
118-
android:paddingEnd="@dimen/spacer_1x"
119-
android:src="@drawable/ic_checkbox_blank_outline" />
118+
<TextView
119+
android:id="@+id/noteModified"
120+
android:layout_width="wrap_content"
121+
android:layout_height="wrap_content"
122+
android:layout_gravity="end"
123+
android:paddingStart="@dimen/spacer_1hx"
124+
android:paddingEnd="@dimen/spacer_2x"
125+
tools:text="27.11." />
126+
127+
</LinearLayout>
120128
</LinearLayout>
121129
</LinearLayout>
122130
</com.google.android.material.card.MaterialCardView>

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

Lines changed: 97 additions & 49 deletions
Original file line numberDiff line numberDiff line change
@@ -15,62 +15,110 @@
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+
<ImageView
62+
android:id="@+id/custom_checkbox"
63+
android:layout_width="wrap_content"
64+
android:layout_height="match_parent"
65+
android:clickable="false"
66+
android:contentDescription="@null"
67+
android:focusable="false"
68+
android:padding="@dimen/spacer_2x"
69+
android:src="@drawable/ic_checkbox_blank_outline" />
70+
71+
<androidx.appcompat.widget.AppCompatImageView
72+
android:id="@+id/noteStatus"
73+
android:layout_width="wrap_content"
74+
android:layout_height="wrap_content"
75+
android:layout_gravity="center_vertical|end"
76+
android:layout_marginTop="12dp"
77+
android:layout_marginEnd="4dp"
78+
android:baseline="14dp"
79+
app:srcCompat="@drawable/ic_sync_blue_18dp" />
80+
</FrameLayout>
81+
82+
<LinearLayout
83+
android:layout_width="match_parent"
4184
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>
85+
android:layout_marginTop="@dimen/spacer_2x"
86+
android:orientation="vertical">
4887

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" />
88+
<com.google.android.material.chip.Chip
89+
android:id="@+id/noteCategory"
90+
android:layout_width="wrap_content"
91+
android:layout_height="wrap_content"
92+
android:layout_gravity="end"
93+
android:layout_marginStart="0dp"
94+
android:layout_marginEnd="@dimen/spacer_2x"
95+
android:ellipsize="middle"
96+
android:padding="@dimen/spacer_1hx"
97+
android:textColor="?android:textColorPrimary"
98+
android:textSize="@dimen/secondary_font_size"
99+
app:chipBackgroundColor="@color/defaultBrand"
100+
app:chipEndPadding="@dimen/spacer_1x"
101+
app:chipMinHeight="0dp"
102+
app:chipStartPadding="@dimen/spacer_1x"
103+
app:chipStrokeColor="@android:color/transparent"
104+
app:chipStrokeWidth="1dp"
105+
app:ensureMinTouchTargetSize="false"
106+
app:textEndPadding="0dp"
107+
app:textStartPadding="0dp"
108+
tools:maxLength="50"
109+
tools:text="@tools:sample/lorem/random" />
63110

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" />
111+
<TextView
112+
android:id="@+id/noteModified"
113+
android:layout_width="wrap_content"
114+
android:layout_height="wrap_content"
115+
android:layout_gravity="end"
116+
android:paddingStart="@dimen/spacer_1hx"
117+
android:paddingEnd="@dimen/spacer_2x"
118+
tools:text="27.11." />
119+
120+
</LinearLayout>
121+
</LinearLayout>
75122
</LinearLayout>
76-
</com.google.android.material.card.MaterialCardView>
123+
124+
</com.google.android.material.card.MaterialCardView>

0 commit comments

Comments
 (0)