Added "group members only" visibility level.

This commit is contained in:
Pierre HUBERT 2018-08-01 09:58:18 +02:00
parent b094b196f0
commit eed86ea221
4 changed files with 41 additions and 16 deletions

View File

@ -19,6 +19,11 @@ public enum PostVisibilityLevels {
*/
FRIENDS,
/**
* Groups-members visible posts
*/
MEMBERS,
/**
* Private post
*/

View File

@ -320,22 +320,7 @@ public class PostsHelper {
post.setComments_list(CommentsHelper.parse_json_array(json.getJSONArray("comments")));
//Determine the visibility level of the post
switch (json.getString("visibility_level")){
case "public":
post.setVisibilityLevel(PostVisibilityLevels.PUBLIC);
break;
case "friends":
post.setVisibilityLevel(PostVisibilityLevels.FRIENDS);
break;
case "private":
default :
post.setVisibilityLevel(PostVisibilityLevels.PRIVATE);
break;
}
post.setVisibilityLevel(api_to_visibility_levels(json.getString("visibility_level")));
//Determine the type of the post
switch (json.getString("kind")){
@ -392,6 +377,33 @@ public class PostsHelper {
return post;
}
/**
* Turn API visibility level to PostVisibilityLevel
*
* @param level The level to transform
* @return Matching visibility level
*/
private PostVisibilityLevels api_to_visibility_levels(String level){
switch (level){
case "public":
return PostVisibilityLevels.PUBLIC;
case "friends":
return PostVisibilityLevels.FRIENDS;
case "members":
return PostVisibilityLevels.MEMBERS;
case "private":
return PostVisibilityLevels.PRIVATE;
default:
throw new RuntimeException("Unsupported kind of post visibility " +
"level: '"+level+"' !");
}
}
/**
* Turn a POST visibility level into a string ready for the API
*
@ -407,6 +419,9 @@ public class PostsHelper {
case FRIENDS:
return "friends";
case MEMBERS:
return "members";
case PRIVATE:
return "private";

View File

@ -133,6 +133,10 @@ public class PostsAdapter extends ArrayAdapter<Post>{
visibilityLevel.setText(R.string.post_visibility_friends);
break;
case MEMBERS:
visibilityLevel.setText(R.string.post_visibility_members);
break;
case PRIVATE:
default:
visibilityLevel.setText(R.string.post_visibility_private);

View File

@ -202,4 +202,5 @@
<string name="action_personal_page">My Page</string>
<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>
</resources>