From a759741c861f98ca61e018da872220a7200da57f Mon Sep 17 00:00:00 2001 From: neslihanturan Date: Mon, 10 Sep 2018 18:50:41 +0300 Subject: [PATCH] Add date with year parameter to Notification class, because we will use it on comparasion of dates --- .../fr/free/nrw/commons/notification/Notification.java | 4 +++- .../nrw/commons/notification/NotificationUtils.java | 10 +++++++++- 2 files changed, 12 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/fr/free/nrw/commons/notification/Notification.java b/app/src/main/java/fr/free/nrw/commons/notification/Notification.java index e6d759f66..0116d024c 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/Notification.java +++ b/app/src/main/java/fr/free/nrw/commons/notification/Notification.java @@ -11,13 +11,15 @@ public class Notification { public String description; public String link; public String iconUrl; + public String dateWithYear; - public Notification(NotificationType notificationType, String notificationText, String date, String description, String link, String iconUrl) { + public Notification(NotificationType notificationType, String notificationText, String date, String description, String link, String iconUrl, String dateWithYear) { this.notificationType = notificationType; this.notificationText = notificationText; this.date = date; this.description = description; this.link = link; this.iconUrl = iconUrl; + this.dateWithYear = dateWithYear; } } diff --git a/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java b/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java index e7c87d3f4..24fda5596 100644 --- a/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java +++ b/app/src/main/java/fr/free/nrw/commons/notification/NotificationUtils.java @@ -144,7 +144,7 @@ public class NotificationUtils { notificationText = getWelcomeMessage(context, document); break; } - return new Notification(type, notificationText, getTimestamp(document), description, link, iconUrl); + return new Notification(type, notificationText, getTimestamp(document), description, link, iconUrl, getTimestampWithYear(document)); } private static String getNotificationText(Node document) { @@ -247,6 +247,14 @@ public class NotificationUtils { return ""; } + private static String getTimestampWithYear(Node document) { + Element timestampElement = (Element) getNode(document, "timestamp"); + if (timestampElement != null) { + return timestampElement.getAttribute("utcunix"); + } + return ""; + } + private static String getNotificationDescription(Node document) { Element titleElement = (Element) getNode(document, "title"); if (titleElement != null) {