diff --git a/app/src/main/java/org/communiquons/android/comunic/client/data/utils/NotifsUtils.java b/app/src/main/java/org/communiquons/android/comunic/client/data/utils/NotifsUtils.java
index 2a7cfa3..a7b0616 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/data/utils/NotifsUtils.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/data/utils/NotifsUtils.java
@@ -3,10 +3,12 @@ package org.communiquons.android.comunic.client.data.utils;
import android.content.Context;
import android.util.ArrayMap;
+import org.communiquons.android.comunic.client.R;
import org.communiquons.android.comunic.client.data.enums.NotifElemType;
import org.communiquons.android.comunic.client.data.enums.NotificationTypes;
import org.communiquons.android.comunic.client.data.models.Notif;
import org.communiquons.android.comunic.client.data.models.UserInfo;
+import org.communiquons.android.comunic.client.ui.utils.UiUtils;
/**
* Notifications utilities
@@ -34,24 +36,24 @@ public class NotifsUtils {
//For friendship request
if(notif.getType() == NotificationTypes.SENT_FRIEND_REQUEST)
- message += "sent you a friendship request.";
+ message += UiUtils.getString(context, R.string.notif_sent_friend_request);
if(notif.getType() == NotificationTypes.ACCEPTED_FRIEND_REQUEST)
- message += "accepted your friendship request.";
+ message += UiUtils.getString(context, R.string.notif_accepted_friend_request);
if(notif.getType() == NotificationTypes.REJECTED_FRIEND_REQUEST)
- message += "rejected your friendship request.";
+ message += UiUtils.getString(context, R.string.notif_rejected_friend_request);
//In case of creation of an element
if(notif.getType() == NotificationTypes.ELEM_CREATED){
//For the posts
if(notif.getOn_elem_type() == NotifElemType.POST)
- message += "created a new post";
+ message += UiUtils.getString(context, R.string.notif_created_post);
}
//For comments creation
if(notif.getType() == NotificationTypes.COMMENT_CREATED){
- message += "posted a comment";
+ message += UiUtils.getString(context, R.string.notif_posted_comment);
}
//Add a separator
@@ -62,10 +64,10 @@ public class NotifsUtils {
if(notif.getFrom_container_type() == NotifElemType.USER_PAGE){
if(notif.getFrom_user_id() == notif.getFrom_container_id())
- message += "on his / her page";
+ message += UiUtils.getString(context, R.string.notif_on_creator_page);
else
- message += "on " + userInfos.get(notif.getFrom_container_id()).getDisplayFullName()
- + "'s page";
+ message += UiUtils.getString(context, R.string.notif_on_user_page,
+ userInfos.get(notif.getFrom_container_id()).getDisplayFullName());
}
diff --git a/app/src/main/java/org/communiquons/android/comunic/client/ui/utils/UiUtils.java b/app/src/main/java/org/communiquons/android/comunic/client/ui/utils/UiUtils.java
index 1731c25..8edd130 100644
--- a/app/src/main/java/org/communiquons/android/comunic/client/ui/utils/UiUtils.java
+++ b/app/src/main/java/org/communiquons/android/comunic/client/ui/utils/UiUtils.java
@@ -17,10 +17,10 @@ import org.communiquons.android.comunic.client.R;
public class UiUtils {
/**
- * Get a color from ressources
+ * Get a color from resources
*
* @param context The context of the application
- * @param color_id The ID of the ressource
+ * @param color_id The ID of the resource
* @return The ID of the color
*/
public static int getColor(Context context, int color_id){
@@ -34,7 +34,7 @@ public class UiUtils {
}
/**
- * Get a drawable from ressources
+ * Get a drawable from resources
*
* @param context The context of the application
* @param drawable_id The ID of the drawable to get
@@ -44,12 +44,28 @@ public class UiUtils {
}
/**
- * Get a string from ressources
+ * Get a string from resources
+ *
+ * @param context The context of the application
+ * @param res_id The ID of the resource
+ * @return The string
*/
public static String getString(Context context, int res_id){
return context.getResources().getString(res_id);
}
+ /**
+ * Get a string from resources with parameters
+ *
+ * @param context The context of the application
+ * @param res_id Resource ID
+ * @param formatsArgs Additional arguments
+ * @return The string
+ */
+ public static String getString(Context context, int res_id, Object... formatsArgs){
+ return context.getResources().getString(res_id, formatsArgs);
+ }
+
/**
* Create and display a loading dialog
*
diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml
index 1cffa77..d47aa19 100644
--- a/app/src/main/res/values/strings.xml
+++ b/app/src/main/res/values/strings.xml
@@ -157,4 +157,11 @@
An error occurred while trying to delete the entire list of notifications!
All the notifications have been deleted!
An error occurred while trying to get the list of notifications !
+ sent you a friendship request.
+ accepted your friendship request.
+ rejected your friendship request.
+ created a new post
+ posted a comment
+ on his / her page
+ on %1$s\'s page