mirror of
https://github.com/pierre42100/ComunicAndroid
synced 2024-11-23 22:09:30 +00:00
Transferred notification message parts into strings.xml
This commit is contained in:
parent
5798df62bf
commit
711afa46e2
@ -3,10 +3,12 @@ package org.communiquons.android.comunic.client.data.utils;
|
|||||||
import android.content.Context;
|
import android.content.Context;
|
||||||
import android.util.ArrayMap;
|
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.NotifElemType;
|
||||||
import org.communiquons.android.comunic.client.data.enums.NotificationTypes;
|
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.Notif;
|
||||||
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
import org.communiquons.android.comunic.client.data.models.UserInfo;
|
||||||
|
import org.communiquons.android.comunic.client.ui.utils.UiUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Notifications utilities
|
* Notifications utilities
|
||||||
@ -34,24 +36,24 @@ public class NotifsUtils {
|
|||||||
|
|
||||||
//For friendship request
|
//For friendship request
|
||||||
if(notif.getType() == NotificationTypes.SENT_FRIEND_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)
|
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)
|
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
|
//In case of creation of an element
|
||||||
if(notif.getType() == NotificationTypes.ELEM_CREATED){
|
if(notif.getType() == NotificationTypes.ELEM_CREATED){
|
||||||
|
|
||||||
//For the posts
|
//For the posts
|
||||||
if(notif.getOn_elem_type() == NotifElemType.POST)
|
if(notif.getOn_elem_type() == NotifElemType.POST)
|
||||||
message += "created a new post";
|
message += UiUtils.getString(context, R.string.notif_created_post);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
//For comments creation
|
//For comments creation
|
||||||
if(notif.getType() == NotificationTypes.COMMENT_CREATED){
|
if(notif.getType() == NotificationTypes.COMMENT_CREATED){
|
||||||
message += "posted a comment";
|
message += UiUtils.getString(context, R.string.notif_posted_comment);
|
||||||
}
|
}
|
||||||
|
|
||||||
//Add a separator
|
//Add a separator
|
||||||
@ -62,10 +64,10 @@ public class NotifsUtils {
|
|||||||
if(notif.getFrom_container_type() == NotifElemType.USER_PAGE){
|
if(notif.getFrom_container_type() == NotifElemType.USER_PAGE){
|
||||||
|
|
||||||
if(notif.getFrom_user_id() == notif.getFrom_container_id())
|
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
|
else
|
||||||
message += "on " + userInfos.get(notif.getFrom_container_id()).getDisplayFullName()
|
message += UiUtils.getString(context, R.string.notif_on_user_page,
|
||||||
+ "'s page";
|
userInfos.get(notif.getFrom_container_id()).getDisplayFullName());
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -17,10 +17,10 @@ import org.communiquons.android.comunic.client.R;
|
|||||||
public class UiUtils {
|
public class UiUtils {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get a color from ressources
|
* Get a color from resources
|
||||||
*
|
*
|
||||||
* @param context The context of the application
|
* @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
|
* @return The ID of the color
|
||||||
*/
|
*/
|
||||||
public static int getColor(Context context, int color_id){
|
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 context The context of the application
|
||||||
* @param drawable_id The ID of the drawable to get
|
* @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){
|
public static String getString(Context context, int res_id){
|
||||||
return context.getResources().getString(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
|
* Create and display a loading dialog
|
||||||
*
|
*
|
||||||
|
@ -157,4 +157,11 @@
|
|||||||
<string name="err_delete_all_notifs">An error occurred while trying to delete the entire list of notifications!</string>
|
<string name="err_delete_all_notifs">An error occurred while trying to delete the entire list of notifications!</string>
|
||||||
<string name="success_delete_all_notifs">All the notifications have been deleted!</string>
|
<string name="success_delete_all_notifs">All the notifications have been deleted!</string>
|
||||||
<string name="err_get_list_notifs">An error occurred while trying to get the list of notifications !</string>
|
<string name="err_get_list_notifs">An error occurred while trying to get the list of notifications !</string>
|
||||||
|
<string name="notif_sent_friend_request">sent you a friendship request.</string>
|
||||||
|
<string name="notif_accepted_friend_request">accepted your friendship request.</string>
|
||||||
|
<string name="notif_rejected_friend_request">rejected your friendship request.</string>
|
||||||
|
<string name="notif_created_post">created a new post</string>
|
||||||
|
<string name="notif_posted_comment">posted a comment</string>
|
||||||
|
<string name="notif_on_creator_page">on his / her page</string>
|
||||||
|
<string name="notif_on_user_page">on %1$s\'s page</string>
|
||||||
</resources>
|
</resources>
|
||||||
|
Loading…
Reference in New Issue
Block a user