Support group membership notifications.

This commit is contained in:
Pierre HUBERT 2018-08-02 09:41:34 +02:00
parent 0e74358dcf
commit fb4b46074a
6 changed files with 69 additions and 0 deletions

View File

@ -86,6 +86,10 @@ public class NotifsList extends ArrayList<Notif> {
&& !IDs.contains(notif.getFrom_container_id()))
IDs.add(notif.getFrom_container_id());
if(notif.getOn_elem_type() == NotifElemType.GROUPS_MEMBERSHIP
&& !IDs.contains(notif.getOn_elem_id()))
IDs.add(notif.getOn_elem_id());
}
return IDs;

View File

@ -44,6 +44,11 @@ public enum NotifElemType {
*/
FRIEND_REQUEST,
/**
* Notifications related to group memberships
*/
GROUPS_MEMBERSHIP,
/**
* Unknown type
*/

View File

@ -39,6 +39,20 @@ public enum NotificationTypes {
*/
ELEM_UPDATED,
/**
* Group membership invitations
*/
SENT_GROUP_MEMBERSHIP_INVITATION,
ACCEPTED_GROUP_MEMBERSHIP_INVITATION,
REJECTED_GROUP_MEMBERSHIP_INVITATION,
/**
* Group membership requests
*/
SENT_GROUP_MEMBERSHIP_REQUEST,
ACCEPTED_GROUP_MEMBERSHIP_REQUEST,
REJECTED_GROUP_MEMBERSHIP_REQUEST,
/**
* Unknown notification type
*/

View File

@ -213,6 +213,9 @@ public class NotificationsHelper {
case "friend_request":
return NotifElemType.FRIEND_REQUEST;
case "group_membership":
return NotifElemType.GROUPS_MEMBERSHIP;
//Default : unknown type of elem
default:
return NotifElemType.UNKNOWN;
@ -248,6 +251,24 @@ public class NotificationsHelper {
case "elem_updated":
return NotificationTypes.ELEM_UPDATED;
case "sent_group_membership_invitation":
return NotificationTypes.SENT_GROUP_MEMBERSHIP_INVITATION;
case "accepted_group_membership_invitation":
return NotificationTypes.ACCEPTED_GROUP_MEMBERSHIP_INVITATION;
case "rejected_group_membership_invitation":
return NotificationTypes.REJECTED_GROUP_MEMBERSHIP_INVITATION;
case "sent_group_membership_request":
return NotificationTypes.SENT_GROUP_MEMBERSHIP_REQUEST;
case "accepted_group_membership_request":
return NotificationTypes.ACCEPTED_GROUP_MEMBERSHIP_REQUEST;
case "rejected_group_membership_request":
return NotificationTypes.REJECTED_GROUP_MEMBERSHIP_REQUEST;
//Default : Unknown notification type
default:
return NotificationTypes.UNKNOWN;

View File

@ -47,6 +47,20 @@ public class NotifsUtils {
if(notif.getType() == NotificationTypes.REJECTED_FRIEND_REQUEST)
message += UiUtils.getString(context, R.string.notif_rejected_friend_request);
//For group membership
if(notif.getType() == NotificationTypes.SENT_GROUP_MEMBERSHIP_INVITATION)
message += UiUtils.getString(context, R.string.notif_sent_group_membership_invitation);
if(notif.getType() == NotificationTypes.ACCEPTED_GROUP_MEMBERSHIP_INVITATION)
message += UiUtils.getString(context, R.string.notif_accepted_group_membership_invitation);
if(notif.getType() == NotificationTypes.REJECTED_GROUP_MEMBERSHIP_INVITATION)
message += UiUtils.getString(context, R.string.notif_rejected_group_membership_invitation);
if(notif.getType() == NotificationTypes.SENT_GROUP_MEMBERSHIP_REQUEST)
message += UiUtils.getString(context, R.string.notif_sent_group_membership_request);
if(notif.getType() == NotificationTypes.ACCEPTED_GROUP_MEMBERSHIP_REQUEST)
message += UiUtils.getString(context, R.string.notif_accepted_group_membership_request);
if(notif.getType() == NotificationTypes.REJECTED_GROUP_MEMBERSHIP_REQUEST)
message += UiUtils.getString(context, R.string.notif_rejected_group_membership_request);
//In case of creation of an element
if(notif.getType() == NotificationTypes.ELEM_CREATED){
@ -83,6 +97,11 @@ public class NotifsUtils {
groupsInfo.get(notif.getFrom_container_id()).getName());
}
//Group membership
else if(notif.getOn_elem_type() == NotifElemType.GROUPS_MEMBERSHIP){
message += groupsInfo.get(notif.getOn_elem_id()).getName();
}
//Return the message
return message;

View File

@ -203,4 +203,10 @@
<string name="notif_on_group_page">on the page of the group %1$s</string>
<string name="err_get_groups_info">Could not get information about groups!</string>
<string name="post_visibility_members">members</string>
<string name="notif_sent_group_membership_invitation">invited you to join the group</string>
<string name="notif_accepted_group_membership_invitation">accepted his invitation to join the group</string>
<string name="notif_rejected_group_membership_invitation">rejected his invitation to join the group</string>
<string name="notif_sent_group_membership_request">sent a request to join the group</string>
<string name="notif_accepted_group_membership_request">accepted your request to join the group</string>
<string name="notif_rejected_group_membership_request">rejected your request to join the group</string>
</resources>